Skip to content
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

test/integration/client: add TestExecPluginRotationViaInformer #101726

Merged

Conversation

ankeesler
Copy link
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

/cc @enj @liggitt

@k8s-ci-robot k8s-ci-robot requested review from enj and liggitt May 4, 2021 14:27
@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 4, 2021
@ankeesler
Copy link
Contributor Author

/sig auth

@k8s-ci-robot k8s-ci-robot added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label May 4, 2021
@@ -18,4 +18,9 @@ set -o errexit
set -o nounset
set -o pipefail

if [[ -n "${EXEC_PLUGIN_OUTPUT_FILE-""}" ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really wanted to collapse this shell script into a single line: cat "$EXEC_PLUGIN_OUTPUT_FILE". I got a little bit lazy because it would take an hour or two of refactoring the rest of the test file. I was also cognizant of trying to keep the blast radius smaller on this PR. I can certainly do the refactor, though, if you think that would be valuable.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine as-is.

@ankeesler ankeesler force-pushed the exec-plugin-integration-test branch 5 times, most recently from f6706c6 to 3df7846 Compare May 4, 2021 16:29
@enj enj added this to Needs Triage PRs in SIG Auth Old May 7, 2021
@liggitt
Copy link
Member

liggitt commented May 7, 2021

/assign @enj

@liggitt liggitt moved this from Needs Triage PRs to In Review (v1.22) in SIG Auth Old May 7, 2021
@enj
Copy link
Member

enj commented May 11, 2021

/triage accepted
/priority important-soon

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed 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 May 11, 2021
Copy link
Member

@enj enj left a comment

Choose a reason for hiding this comment

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

Minor comments. Please squash into one commit.

I am a bit concerned about how long this would take to run.

Comment on lines +456 to +460
} else {
if !errors.Is(err, wait.ErrWaitTimeout) {
Copy link
Member

Choose a reason for hiding this comment

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

😬 so we wait for 30 seconds in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah :(. Same with waitForInformerSync when !wantSynced. I could shorten the timeout to like 10 seconds when !wantEvents, but I was worried that would produce some false positives. I looked around in other integration test code and it seemed like there was some precedent of 30 second timeouts. I tried changing the timeouts to 20 seconds and the test failed locally...

Comment on lines 667 to 684
func waitForInformerSync(t *testing.T, informer cache.SharedIndexInformer, wantSynced bool, lastSyncResourceVersion string) {
t.Helper()

err := wait.PollImmediate(time.Second, time.Second*30, func() (bool, error) {
return informer.HasSynced(), nil
})
if wantSynced {
if err != nil {
t.Fatalf("wanted sync, but got error: %v", err)
}
} else {
if !errors.Is(err, wait.ErrWaitTimeout) {
if err != nil {
t.Fatalf("wanted no sync, but got error: %v", err)
} else {
t.Fatalf("wanted no sync, but got sync")
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Use WaitForCacheSync?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was originally using WaitForCacheSync, but switched to this way because...I can't remember? I'll switch back to WaitForCacheSync until I remember why I did it this more complicated way...I should really comment my code more...shakes fist at my time in a previous organization where I picked up this habit. Fixed here: 3b447d4a53a.

@@ -18,4 +18,9 @@ set -o errexit
set -o nounset
set -o pipefail

if [[ -n "${EXEC_PLUGIN_OUTPUT_FILE-""}" ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine as-is.

time.Sleep(lifetime)
}

func TestExecPluginRotationViaInformer(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

t.Parallel()? How long does this test take to run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On my machine, make test-integration WHAT="./test/integration/client" KUBE_TEST_ARGS="-run TestExecPluginRotat" runs in 138.622s (before any changes made in response to PR comments).

Is it OK for an integration test to run in parallel that makes writes to the API? I was worried that I would screw up other tests (e.g., we create a Namespace and a ConfigMap in this test). I'm all for adding a t.Parallel() if that wouldn't mess anything else up: e9c17c84b6a.

Copy link
Member

@enj enj May 17, 2021

Choose a reason for hiding this comment

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

Is it OK for an integration test to run in parallel that makes writes to the API?

Each test (or maybe it is only test suite) is supposed to have it own sub section of etcd so it should be fine to run in parallel.

Comment on lines 587 to 588
// Wait for old token to expire.
time.Sleep(lifetime)
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure I understand what this does in the context of the test which always seems to pass in 5 seconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line pauses the test so that the exec authenticator will need to be triggered again to pick up the new token. If we didn't have this, a line like this might fail because the informer recreates its watch within the lifetime of the clientAuthorizedToken: https://github.com/kubernetes/kubernetes/blob/3df78461ad2cdf161d09c681372b3b99412cb435/test/integration/client/exec_test.go#L642.

I suppose everywhere else we could get away without this pause since the informer would eventually pick up the new token over the course of our timeouts (e.g., https://github.com/kubernetes/kubernetes/blob/3df78461ad2cdf161d09c681372b3b99412cb435/test/integration/client/exec_test.go#L631).

I wrote this a different way - do you think this is better? This would get rid of 15s of unnecessary waiting (new test runs in 125.988s) and potentially some confusing test code: 180e7c4aa86.

@ankeesler ankeesler force-pushed the exec-plugin-integration-test branch from 3df7846 to e9c17c8 Compare May 14, 2021 12:59
Signed-off-by: Andrew Keesler <akeesler@vmware.com>
@ankeesler ankeesler force-pushed the exec-plugin-integration-test branch from e9c17c8 to a14cd8e Compare May 17, 2021 21:22
@enj
Copy link
Member

enj commented May 17, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ankeesler, enj

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

The pull request process is described 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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 17, 2021
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

2 similar comments
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 5c58620 into kubernetes:master May 18, 2021
SIG Auth Old automation moved this from In Review (v1.22) to Closed / Done May 18, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone May 18, 2021
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. area/test 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. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
SIG Auth Old
Closed / Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants