1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Fix the test Make task (#2381)

* Fix the test Make task

Signed-off-by: shuheiktgw <s-kitagawa@mercari.com>

* fix: retry shutdown of testEnv

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>

---------

Signed-off-by: shuheiktgw <s-kitagawa@mercari.com>
Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
Co-authored-by: Moritz Johner <beller.moritz@googlemail.com>
This commit is contained in:
Shuhei Kitagawa 2023-06-06 18:25:51 +09:00 committed by GitHub
parent 36ae1c1a5e
commit 5a6d661c9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View file

@ -161,8 +161,6 @@ jobs:
- name: Run Unit Tests
run: |
export KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true
source <(setup-envtest use ${{env.KUBERNETES_VERSION}} -p env --os $(go env GOOS) --arch $(go env GOARCH))
make test
publish-artifacts:

View file

@ -35,6 +35,8 @@ else
GOBIN=$(shell go env GOBIN)
endif
KUBERNETES_VERSION := '1.24.x'
# check if there are any existing `git tag` values
ifeq ($(shell git tag),)
# no tags found - default to initial tag `v0.0.0`
@ -91,6 +93,7 @@ update-deps:
# Golang
.PHONY: test
test: export KUBEBUILDER_ASSETS := $(shell setup-envtest use $(KUBERNETES_VERSION) -p path --os $(shell go env GOOS) --arch $(shell go env GOARCH))
test: generate ## Run tests
@$(INFO) go test unit-tests
go test -race -v $(shell go list ./... | grep -v e2e) -coverprofile cover.out

View file

@ -106,6 +106,18 @@ var _ = BeforeSuite(func() {
var _ = AfterSuite(func() {
By("tearing down the test environment")
cancel() // stop manager
err := testEnv.Stop()
Expect(err).ToNot(HaveOccurred())
err := (func() (err error) {
// Need to sleep if the first stop fails due to a bug:
// https://github.com/kubernetes-sigs/controller-runtime/issues/1571
sleepTime := 1 * time.Millisecond
for i := 0; i < 12; i++ { // Exponentially sleep up to ~4s
if err = testEnv.Stop(); err == nil {
return
}
sleepTime *= 2
time.Sleep(sleepTime)
}
return
})()
Expect(err).NotTo(HaveOccurred())
})