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

🌱 Added unit tests for state_test.go #9468

Closed
wants to merge 3 commits into from
Closed

🌱 Added unit tests for state_test.go #9468

wants to merge 3 commits into from

Conversation

abdurrehman107
Copy link
Contributor

What this PR does / why we need it:
This PR adds tests for the new ClusterClass MachinePool implementation for the internal/controllers/topology/cluster/scope/state_test.go

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes part of #5991

/area testing

@k8s-ci-robot k8s-ci-robot added area/testing Issues or PRs related to testing cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 20, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @razashahid107!

It looks like this is your first PR to kubernetes-sigs/cluster-api 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 20, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @razashahid107. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

[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 assign justinsb for approval. 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

@abdurrehman107 abdurrehman107 changed the title Added unit tests for state_test.go 🌱 Added unit tests for state_test.go Sep 20, 2023
@sbueringer
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 20, 2023
func TestMPIsUpgrading(t *testing.T) {
g := NewWithT(t)
scheme := runtime.NewScheme()
g.Expect(clusterv1.AddToScheme(scheme)).To(Succeed())
Copy link
Contributor

Choose a reason for hiding this comment

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

You will need to add expv1 to the scheme as well since MachinePools are part of that package instead of clusterv1.

g.Expect(expv1.AddToScheme(scheme)).To(Succeed())

tests := []struct {
name string
mp *clusterv1.MachinePool
machines []*clusterv1.Machine
Copy link
Contributor

Choose a reason for hiding this comment

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

We will check the noderef's kubelet version instead of the machine's version. Thus, we'll need to add a list of *corev1.Node instead of *clusterv1.Machine. The logic for this is here: https://github.com/kubernetes-sigs/cluster-api/blob/main/internal/controllers/topology/cluster/scope/state.go#L174

func TestMPUpgrading(t *testing.T) {
g := NewWithT(t)
scheme := runtime.NewScheme()
g.Expect(clusterv1.AddToScheme(scheme)).To(Succeed())
Copy link
Contributor

Choose a reason for hiding this comment

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

You will need to add expv1 to the scheme here as well.

g.Expect(expv1.AddToScheme(scheme)).To(Succeed())

@k8s-ci-robot
Copy link
Contributor

@razashahid107: 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-cluster-api-test-main 1f45071 link true /test pull-cluster-api-test-main

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/test-infra repository. I understand the commands that are listed here.

@abdurrehman107 abdurrehman107 closed this by deleting the head repository Oct 5, 2023
@sbueringer
Copy link
Member

@willie-yao Do you have some time to / do you want to take this one over?

@willie-yao
Copy link
Contributor

Do you have some time to / do you want to take this one over?

Yes I can take this over. I do want to check with @razashahid107 if he still wanted to work on this or needed help

@abdurrehman107
Copy link
Contributor Author

Hey @willie-yao and @sbueringer. I'm sorry I have not been able to get done with this. I understand this probably is a relatively easy task, but I keep getting lost with the preset functions that I have to work on before I get on with the actual tests.
Yes @willie-yao I'd love help. I want to allow myself the last try at this issue. If I feel I'll not be able to get through it this time @willie-yao can go through with it.
I think a week sounds okay provided I push for completing the task.

@sbueringer @willie-yao I was working on another PR for this test which did not get completed and I just ended up getting lost with it. I'll raise that PR tomorrow and I'll request some help from you.

Do I proceed with this try or are we short on time? If thats the case @willie-yao can take over. If thats not the case I'd love to allow myself another attempt at this.

@willie-yao
Copy link
Contributor

No problem @razashahid107. You can give it another go if you'd like and please don't hesitate to reach out if you have any questions! I will take a look at your new PR whenever it is posted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Issues or PRs related to testing cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

4 participants