-
Notifications
You must be signed in to change notification settings - Fork 263
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 cluster controller #1199
🏃 Add tests for cluster controller #1199
Conversation
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Hi @lentzi90. 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 Once the patch is verified, the new status will be reflected by the 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. |
/ok-to-test |
adcb133
to
8a6c46f
Compare
/test pull-cluster-api-provider-openstack-test |
8a6c46f
to
b967fd7
Compare
/test pull-cluster-api-provider-openstack-test |
b967fd7
to
3c516e3
Compare
/test pull-cluster-api-provider-openstack-test |
3c516e3
to
4a6cbfe
Compare
/test pull-cluster-api-provider-openstack-test |
/test pull-cluster-api-provider-openstack-build |
/hold cancel |
Alright I think this is ready for review now. Note that there are 3 commits. This is to make it easy to remove some of them if we decide to not take them in. Alternatively I can make separate PRs also for each. |
}) | ||
|
||
// TODO: This test is set to pending (PIt instead of It) since it is not working. | ||
PIt("should be able to reconcile when basition disabled", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at this test specifically. I'm not sure how to move forward here. The basic tests above does not require any interaction with the Openstack API, but this one does and I didn't find a good way to fake it. Am I missing something? Is it possible to get a fake/mock scope or dummy openstack API to use in tests like these?
@@ -57,6 +59,11 @@ var _ = BeforeSuite(func() { | |||
CRDDirectoryPaths: []string{ | |||
filepath.Join("..", "config", "crd", "bases"), | |||
}, | |||
// Add fake CAPI CRDs that we reference | |||
CRDs: []*apiextensionsv1.CustomResourceDefinition{ | |||
external.TestClusterCRD.DeepCopy(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the benefit of faking the CRDs instead of including the actual ones? (I have not really worked with envtest before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main benefit is that we don't have to include the CAPI CRDs either in the repo or automatically download them to be able to run the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, because this expects CustomResourceDefinition
objects, but we currently only import the API types (from sigs.k8s.io/cluster-api/api/*
.
That makes sense. Thank you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also make use of "sigs.k8s.io/cluster-api/internal/test/envtest"
if it makes sense. It also includes some helper ufnctions which may be handy.
I have split this up into two now. The first part is #1239 and this is the second. I'll rebase this once the first is merged. /hold |
4a6cbfe
to
65e0c82
Compare
In order to use envtest for these tests, it was necessary to add the CRDs for CAPI clusters and machines. Luckily I found a way to only include the minimal required parts instead of the full thing. This solution is taken from CAPA.
@mdbooth this is now rebased and ready to go in I think. The only thing I'm wondering is if I should remove the disabled test for now or keep it there as a TODO. What do you think? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lentzi90, mdbooth 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 |
I don't think it's important. It's a little messy but it's documented why it's messy and we have a plan to fix it up soon. |
/lgtm |
/hold cancel |
What this PR does / why we need it:
This adds some simple tests for the OpenStackCluster controller.
Special notes for your reviewer:
TODOs:
/hold