Skip to content

Implement tests for deferredResponseWriter to validate behavior on multiple writer calls. #130168

@serathius

Description

@serathius

What would you like to be added?

As pointed out in #129334 (comment) existing implementation of deferredResponseWriter assumes a single write when deciding whether gzip encoding is needed. We would extend writes to allow multiple calls to Write but before that we need to test it properly.

We would like to add a new test that tests only the deferredResponseWriter struct, and validates output of response and headers to confirm whether gzip encoding happen. We should have multiple scenarios with different sizes of input (around defaultGzipThresholdBytes) split between multiple writes (1 and 2 should be enough). Example cases:

  • 1 write of size defaultGzipThresholdBytes-1 -> should not be encoded
  • 1 write of size defaultGzipThresholdBytes -> should be encoded
  • 2 writes each of size defaultGzipThresholdBytes -1 -> should not be encoded. This will change after we implement chunking support.
  • 2 writes each of size defaultGzipThresholdBytes -> should be encoded

Please note this is a early PR blocking KEP planned for 1.33 (deadline in April), and there is much more work that needs to follow. If you want to pick up the issue please ensure you can implement it within short time (week).

Why is this needed?

Required to implement response streaming described in https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/5116-streaming-response-encoding#streaming-collections-and-gzip-encoding

Tracked in kubernetes/enhancements#5116

Metadata

Metadata

Assignees

Labels

help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions