Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WIP] refactor: watch test cleanup #131457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
Loading
from

Conversation

karlkfi
Copy link
Contributor

@karlkfi karlkfi commented Apr 25, 2025

What type of PR is this?

/kind cleanup
/kind flake

What this PR does / why we need it:

  • Fix flaky watch tests that were not waiting for the storage watcher to be started by the server watch endpoint
  • Use testify in watch tests to make the tests easier to read/debug
  • Remove unnecessary test names from errors

Does this PR introduce a user-facing change?

NONE

Dependencies

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. kind/flake Categorizes issue or PR as related to a flaky test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 25, 2025
@k8s-ci-robot k8s-ci-robot requested review from deads2k and jpbetz April 25, 2025 03:43
@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 25, 2025
@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch from 27362ea to 4a7f3e7 Compare April 26, 2025 05:29
@karlkfi
Copy link
Contributor Author

karlkfi commented Apr 26, 2025

/assign @wojtek-t

@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch 2 times, most recently from 6a3066b to 027ecc2 Compare April 26, 2025 09:11
@siyuanfoundation
Copy link
Contributor

@karlkfi Thanks for the refactor. Is it possible to break this huge PR to smaller PRs or even commits?

@karlkfi
Copy link
Contributor Author

karlkfi commented Apr 29, 2025

@karlkfi Thanks for the refactor. Is it possible to break this huge PR to smaller PRs or even commits?

Sure. I'll see what i can do.

Might have to mostly just be separate commits tho, because making changes to the file causes it to be linted, which requires fixing a lot of different things in the same PR.

@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch from 027ecc2 to 410e6e3 Compare April 30, 2025 00:36
@karlkfi
Copy link
Contributor Author

karlkfi commented Apr 30, 2025

Split into three commits for a first pass. This modifies more files tho, which might surface other hidden linter errors.

I can probably split the third commit down a bit more, pulling out the sub-tests, close helpers, and testify usage.

@yongruilin
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 1, 2025
@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch from 410e6e3 to 55fb9c7 Compare May 1, 2025 22:49
@karlkfi
Copy link
Contributor Author

karlkfi commented May 1, 2025

I split up the commits a bit more.

@karlkfi
Copy link
Contributor Author

karlkfi commented May 7, 2025

Surprisingly, the request methods didn't cause additional linter failures by themselves, so i pulled those out to a seperate PR: #131656 You can approve that one first or this whole one. Whichever you prefer. If that one merges first, I'll rebase this one.

@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch 3 times, most recently from c629d9c to f99076c Compare May 9, 2025 18:35
@karlkfi karlkfi changed the title refactor: watch test cleanup [WIP] refactor: watch test cleanup May 9, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 9, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 17, 2025
@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch from f99076c to 408f782 Compare May 19, 2025 23:01
karlkfi added 4 commits May 19, 2025 16:01
- Add channel test helpers to k8s.io/client-go/util/testing
- Use the new channel test helpers in the client and server watch
  tests to validate that the result channels closes without error
  when the client stops the watcher.
- Use the new channel test helpers in the client watcher decoder
  tests to validate that encoded watch events can be decoded and
  that the decoder errors with EOF when stopped asynchronously.

These new tests uncovered existing errors (added TODOs):
1.  The watch client doesn't close the response body when it
    encounters a NegotiateError.
2.  The watch client sometimes sends a decode error on the result
    channel after the client watcher has been stopped.
3.  StreamWatcher.receive uses %v instead of %w when wrapping errors.
- Wait for storage watcher to be created by the watcher server
  before trying to send events to it in the tests.
- Use require and assert to make the tests easier to read and debug
@karlkfi karlkfi force-pushed the karl-fake-watcher-wait branch from 408f782 to 3c5acfa Compare May 19, 2025 23:45
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: karlkfi
Once this PR has been reviewed and has the lgtm label, please ask for approval from wojtek-t. For more information see the Code Review Process.

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

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

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 20, 2025

@karlkfi: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-linter-hints 3c5acfa link false /test pull-kubernetes-linter-hints

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

"sync"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aojea
Copy link
Member

aojea commented May 20, 2025

  • Use testify in watch tests to make the tests easier to read/debug

this is not true #130346 , tests are not easier to read and debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/flake Categorizes issue or PR as related to a flaky test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.