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

Add unit tests for add-nodes workflow related to auth tokens #9218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pawanpinjarkar
Copy link
Contributor

No description provided.

Copy link
Contributor

openshift-ci bot commented Nov 19, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from pawanpinjarkar. For more information see the Kubernetes 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

Copy link
Contributor

@rwsu rwsu left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 19, 2024
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 19, 2024
Copy link
Contributor

openshift-ci bot commented Nov 19, 2024

New changes are detected. LGTM label has been removed.

@pawanpinjarkar pawanpinjarkar force-pushed the add-unit-tests branch 3 times, most recently from 29e884d to 9e91897 Compare November 19, 2024 22:09
@rwsu
Copy link
Contributor

rwsu commented Nov 20, 2024

/test e2e-agent-compact-ipv4

@andfasano
Copy link
Contributor

Please add in the description "Requires #9210"

assert.Equal(t, ok, true)
if tc.workflow == workflow.AgentWorkflowTypeAddNodes {
// Retrieve the cluster secret and verify there are no errors
clusterSecret, err := fakeClient.CoreV1().Secrets(authTokenSecretNamespace).Get(context.Background(), authTokenSecretName, metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't enough to reference tc.clusterSecret(t) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

introduces more changes to fake the time

name: "generate-public-key-and-token-install-workflow",
workflow: workflow.AgentWorkflowTypeInstall,
name: "generate-public-key-and-token-for-install-workflow",
ocpVersion: defaultOCPVersion,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me quite misleading to explicitly mention the ocp version, given that the tested code doesn't use it (explicitly). The assumption it's just that in previous versions (than 4.18) some secret datas are not available - and they need to be reconciled.
In theory, this could happen even if (for some obscure reason) the user may decide to delete them. Ofc it's not a realistic code, but the current code is designed to fix this erroneous condition in any case, regardless of the current ocp version - and the test should reflect that.

Copy link
Contributor

Choose a reason for hiding this comment

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

(This very likely could make the test code simpler, but I could be wrong)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ocpVersion in reality has nothing to do but just used as a way to signify the case when there is only 1 token in the secret

Copy link
Contributor

Choose a reason for hiding this comment

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

And that was somehow misleading, as I was expecting something related to the version. I'd feel that by removing it the test will become more clear

Copy link
Contributor Author

@pawanpinjarkar pawanpinjarkar Nov 20, 2024

Choose a reason for hiding this comment

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

thanks, yes removed it, instead used a field, number expected auth tokens

Copy link
Contributor

openshift-ci bot commented Nov 20, 2024

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

Test name Commit Details Required Rerun command
ci/prow/e2e-agent-ha-dualstack 314e71b link false /test e2e-agent-ha-dualstack
ci/prow/e2e-agent-4control-ipv4 314e71b link false /test e2e-agent-4control-ipv4
ci/prow/e2e-agent-compact-ipv4-appliance-diskimage 314e71b link false /test e2e-agent-compact-ipv4-appliance-diskimage
ci/prow/okd-scos-e2e-aws-ovn 314e71b link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-agent-compact-ipv6-minimaliso 314e71b link false /test e2e-agent-compact-ipv6-minimaliso
ci/prow/e2e-agent-5control-ipv4 314e71b link false /test e2e-agent-5control-ipv4

Full PR test history. Your PR dashboard.

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.

@rwsu
Copy link
Contributor

rwsu commented Nov 21, 2024

/test e2e-agent-compact-ipv4
/test e2e-agent-compact-ipv4-add-nodes

})
}
}

func secretWithOnly1Token(expiry time.Time) func(t *testing.T) runtime.Object {
Copy link
Contributor

@rwsu rwsu Nov 21, 2024

Choose a reason for hiding this comment

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

I think the secretWithOnly1Token and secretwith3Tokens functions are circumventing the goal of the unit tests. AuthConfig.Generate and the unit tests should be calling the same sets of functions to create the Secrets or contents of the Secrets that stores the tokens. Otherwise the unit test isn't testing the actual code.

@pawanpinjarkar
Copy link
Contributor Author

/test e2e-agent-compact-ipv4-appliance-diskimage

@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

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.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants