Skip to content

test(watch): clean up test_pod_log_empty_lines to properly test Watch.stream - #2813

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
anisayakmitra-in:fix-watch-pod-log-test-cleanup
Nov 27, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
anisayakmitra-in:fix-watch-pod-log-test-cleanup

Conversation

@anisayakmitra-in

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

In kubernetes/watch/watch_test.py, est_pod_log_empty_lines had several issues:

  1. It mocked out w.stream directly (w.stream = Mock(return_value=[...])), which meant the actual generator and line-splitting logic of Watch.stream() was never executed or tested.
  2. It defined a @classmethod def setUpClass(cls) midway through the test class which created unnecessary test fixture state.
  3. It contained a fake 60-second polling wait loop (while time.time() - start_time < timeout: ... time.sleep(2)), commented-out assertions, and debug print() statements that polluted unit test output.

This PR cleans up est_pod_log_empty_lines:

  • Directly exercises Watch.stream(fake_api.read_namespaced_pod_log, follow=True) against a mock streaming response returning empty and newline-delimited chunks.
  • Verifies empty log lines are yielded correctly and connection cleanup (
    esp.close() and
    esp.release_conn()) occurs as expected.
  • Removes dead polling loops, ime.sleep(), stray setUpClass, and stdout print() calls.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

elease-note NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

….stream

Signed-off-by: ANISAYAK MITRA <266799942+anisayakmitra-in@users.noreply.github.com>
@kubernetes-prow kubernetes-prow Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 27, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog November 27, 2026 18:57
@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 27, 2026
@anisayakmitra-in

Copy link
Copy Markdown
Contributor Author

/release-note-none

@kubernetes-prow kubernetes-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 27, 2026
@yliaog

yliaog commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

thanks for the PR
/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 27, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anisayakmitra-in, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 27, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 46ad25d into kubernetes-client:master Nov 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants