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 tests for gcp_machine_controller #260

Closed
wants to merge 1 commit into from
Closed

🏃 add tests for gcp_machine_controller #260

wants to merge 1 commit into from

Conversation

nader-ziada
Copy link
Contributor

What this PR does / why we need it:

  • improve test coverage
  • create a mock gcp compute service to be able to mock out the calls to gcp in the test
  • change the controller to allow for passing of the mock service

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 3, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @nader-ziada. 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 k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 3, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nader-ziada
To complete the pull request process, please assign justinsb
You can assign the PR to them by writing /assign @justinsb in a comment when ready.

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

@nader-ziada
Copy link
Contributor Author

@detiber @wfernandes since you looked at this code, can one of you give this PR an ok-to-test if you think it makes sense. Thanks

@vincepri
Copy link
Member

vincepri commented Dec 4, 2019

/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 Dec 4, 2019
@nader-ziada
Copy link
Contributor Author

I've had a chat with @wfernandes and explained why checking that a func has not been called yet in the test might not guarantee that the required validation happened since all these validation happen in sequence in the same reconcile method.

is there anything else I should be changing here?

Thanks

@nader-ziada
Copy link
Contributor Author

/test pull-cluster-api-provider-gcp-make-conformance

1 similar comment
@nader-ziada
Copy link
Contributor Author

/test pull-cluster-api-provider-gcp-make-conformance

Expect(k8sClient.Delete(ctx, machineScope.GCPMachine)).Should(Succeed())
})

It("should return early if gcp machine is in error state", func() {

Choose a reason for hiding this comment

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

Can we change the test title to better reflect what is being tested? Currently it doesn't seem like we are testing early return. Is there a way to assert that reconciliation hasn't happened? Maybe verifying if ProviderID isn't set. since that is a mandatory step in reconciliation. WDYT?

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'm not sure I understand your point? returning early is just another way of saying reconciliation didn't happen and since there is an error message it also means reconciliation didn't happen

Expect(buf.String()).To(ContainSubstring("Error state detected, skipping reconciliation"))
})

It("should return if infrastructure is not ready", func() {

Choose a reason for hiding this comment

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

Same comment as above.

Expect(buf.String()).To(ContainSubstring("Cluster infrastructure is not ready yet"))
})

It("should return if bootstrap data is not available", func() {

Choose a reason for hiding this comment

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

Same comment as above.

- create a mock gcp compute service to be able to mock out the calls to gcp
in the test
- change the controller to allow for passing of the mock service
@nader-ziada
Copy link
Contributor Author

nader-ziada commented Dec 18, 2019

@vincepri @wfernandes any comments of this PR? I'm not aware of any outstanding changes I should still make. Thanks

@nader-ziada
Copy link
Contributor Author

I don't think the failure in the conformance tests are related to the changes in this PR, will investigate further anyways

@nader-ziada
Copy link
Contributor Author

/retest

@nader-ziada
Copy link
Contributor Author

/test pull-cluster-api-provider-gcp-make-conformance

@k8s-ci-robot
Copy link
Contributor

@nader-ziada: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cluster-api-provider-gcp-make-conformance d34a6b0 link /test pull-cluster-api-provider-gcp-make-conformance

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.

@nader-ziada
Copy link
Contributor Author

/close

@k8s-ci-robot
Copy link
Contributor

@nader-ziada: Closed this PR.

In response to this:

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants