-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 Refactor testenv and remove unused ones #3159
Conversation
1278ec0
to
8d0239d
Compare
/milestone v0.3.7 |
Nice cleanup! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini, vincepri 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 |
@fabriziopandini @benmoss pls lgtm :) |
/lgtm |
/hold |
/hold |
holding, in the middle of a review, I think there are potential issues outside of the api change. |
|
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.
If I'm understanding these changes correctly, this should allow for re-use of the same envtest environment across tests that are running under the same test process.
One gotcha is that Ginkgo-based parallel tests are actually running under separate processes, so if the goal is to re-use the same envtest for parallel ginkgo tests, then the calls to start/stop the test environment in BeforeSuite
/AfterSuite
will need to be moved into SyncronizedBeforeSuite
/SynchronizedAfterSuite
.
/retitle 🌱 Refactor testenv and remove unused ones Addressed all comments, I've opted to clean everything up and avoid finding a complex solution to reuse envtest across packages, few things I've noticed/discovered:
Cleaning everything up resulted in faster local runs. In general, we should be mindful that each time we spin up a new test environment in a new package it might affect the overall runtime of tests. |
/hold cancel |
9ad1c3c
to
4f97eed
Compare
@@ -24,9 +24,10 @@ cd "${REPO_ROOT}" || exit 1 | |||
# shellcheck source=./hack/ensure-go.sh | |||
source "${REPO_ROOT}/hack/ensure-go.sh" | |||
|
|||
make generate test |
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've removed the generate pre-req from here, given that we're already checking it in pr-verify
presubmit. This reduced the runtime for tests in CI from ~12 minutes to ~3 mins
c7f1638
to
a8e2a42
Compare
/test pull-cluster-api-test |
Signed-off-by: Vince Prignano <[email protected]>
@vincepri: The following test failed, say
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. |
Doesn't look like this has much of an impact on my machine (8 cores, 32gb ram). I ran
|
still a good cleanup though! |
/lgtm |
@@ -60,7 +60,7 @@ var _ = Describe("KubeadmControlPlaneReconciler", func() { | |||
|
|||
Context("Reconcile a KubeadmControlPlane", func() { | |||
It("should return error if owner cluster is missing", func() { | |||
clusterName, clusterNamespace := "foo", "default" | |||
clusterName, clusterNamespace := "foo-1", "default" |
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.
It seems like this should be using a generated namespace rather than "default", possibly one created in BeforeEach
and deleted in AfterEach
Eventually(func() error { | ||
_, err := r.Reconcile(ctrl.Request{NamespacedName: util.ObjectKey(kcp)}) | ||
return err | ||
}, 10*time.Second).Should(HaveOccurred()) |
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.
Why the switch to eventually here? Would it be better to have an eventually on the deletion being fully completed and then retrying the reconcile call instead?
} | ||
|
||
func (t *TestEnvironment) StartManager() error { | ||
return t.Manager.Start(t.doneMgr) | ||
} | ||
|
||
func (t *TestEnvironment) Stop() error { | ||
close(t.doneMgr) | ||
return t.Environment.Stop() | ||
t.doneMgr <- struct{}{} |
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.
Does this actually stop the Manager? It looks like based on the docs that the manager is expected to stay running until the channel is closed: https://godoc.org/sigs.k8s.io/controller-runtime/pkg/manager#Runnable
Signed-off-by: Vince Prignano [email protected]
What this PR does / why we need it:
This PR makes it so we can reuse one envtest across all our packages.
/assign @detiber @fabriziopandini