Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Unit tests could not run #252

Closed
mochizuki875 opened this issue Jan 30, 2023 · 2 comments · Fixed by #257
Closed

Unit tests could not run #252

mochizuki875 opened this issue Jan 30, 2023 · 2 comments · Fixed by #257
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@mochizuki875
Copy link
Contributor

What happened?

Unit tests (make test as shown in Development Workflow) could not run because the controlplane could not be started using testenv.

What did you expect to happen?

I expect the controlplane to start using envtest and the unit tests are able to run.

How can we reproduce it (as minimally and precisely as possible)?

Run unit tests by executing make test.
The error will occur as below.

$ make test
...
[BeforeSuite] [FAILED] [10.006 seconds]
[BeforeSuite] 
/home/ubuntu-user/go/hierarchical-namespaces/internal/anchor/reconciler_test.go:20

  Begin Captured GinkgoWriter Output >>
    STEP: configuring test environment 01/26/23 13:21:34.371
    STEP: starting test environment 01/26/23 13:21:34.371
    1.6747069043722517e+09	DEBUG	controller-runtime.test-env	starting control plane
    1.674706904375007e+09	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 0, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:330
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:260
    sigs.k8s.io/hierarchical-namespaces/internal/integtest.HNCBeforeSuite
    	/home/ubuntu-user/go/hierarchical-namespaces/internal/integtest/setup.go:82
    github.com/onsi/ginkgo/v2/internal.(*Suite).runNode.func2
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/github.com/onsi/ginkgo/v2/internal/suite.go:605
    1.6747069043755567e+09	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 1, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:330
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:260
    sigs.k8s.io/hierarchical-namespaces/internal/integtest.HNCBeforeSuite
    	/home/ubuntu-user/go/hierarchical-namespaces/internal/integtest/setup.go:82
    github.com/onsi/ginkgo/v2/internal.(*Suite).runNode.func2
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/github.com/onsi/ginkgo/v2/internal/suite.go:605
    1.6747069043761888e+09	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 2, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:330
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:260
    sigs.k8s.io/hierarchical-namespaces/internal/integtest.HNCBeforeSuite
    	/home/ubuntu-user/go/hierarchical-namespaces/internal/integtest/setup.go:82
    github.com/onsi/ginkgo/v2/internal.(*Suite).runNode.func2
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/github.com/onsi/ginkgo/v2/internal/suite.go:605
    1.6747069043765535e+09	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 3, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:330
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:260
    sigs.k8s.io/hierarchical-namespaces/internal/integtest.HNCBeforeSuite
    	/home/ubuntu-user/go/hierarchical-namespaces/internal/integtest/setup.go:82
    github.com/onsi/ginkgo/v2/internal.(*Suite).runNode.func2
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/github.com/onsi/ginkgo/v2/internal/suite.go:605
    1.6747069043768306e+09	ERROR	controller-runtime.test-env	unable to start the controlplane	{"tries": 4, "error": "fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory"}
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).startControlPlane
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:330
    sigs.k8s.io/controller-runtime/pkg/envtest.(*Environment).Start
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go:260
    sigs.k8s.io/hierarchical-namespaces/internal/integtest.HNCBeforeSuite
    	/home/ubuntu-user/go/hierarchical-namespaces/internal/integtest/setup.go:82
    github.com/onsi/ginkgo/v2/internal.(*Suite).runNode.func2
    	/home/ubuntu-user/go/hierarchical-namespaces/vendor/github.com/onsi/ginkgo/v2/internal/suite.go:605
  << End Captured GinkgoWriter Output

  Unexpected error:
      <*fmt.wrapError | 0xc00033e400>: {
          msg: "unable to start control plane itself: failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory",
          err: <*fmt.wrapError | 0xc00033e3e0>{
              msg: "failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory",
              err: <*fs.PathError | 0xc00012cd50>{
                  Op: "fork/exec",
                  Path: "/usr/local/kubebuilder/bin/etcd",
                  Err: <syscall.Errno>0x2,
              },
          },
      }
      unable to start control plane itself: failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory
  occurred
  In [BeforeSuite] at: /home/ubuntu-user/go/hierarchical-namespaces/internal/integtest/setup.go:83
...

Kubernetes version

$ kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.1", GitCommit:"8f94681cd294aa8cfd3407b8191f6c70214973a4", GitTreeState:"clean", BuildDate:"2023-01-18T15:58:16Z", GoVersion:"go1.19.5", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.3", GitCommit:"434bfd82814af038ad94d62ebe59b133fcb50506", GitTreeState:"clean", BuildDate:"2022-10-25T19:35:11Z", GoVersion:"go1.19.2", Compiler:"gc", Platform:"linux/amd64"}

OS version

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ uname -a
Linux ubuntu-server01 5.15.0-57-generic #63-Ubuntu SMP Thu Nov 24 13:43:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Install tools

$ docker version
Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.7
 Git commit:        baeda1f
 Built:             Tue Oct 25 18:01:58 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.7
  Git commit:       3056208
  Built:            Tue Oct 25 17:59:49 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.9
  GitCommit:        1c90a442489720eec95342e1789ee8a5e1b9536f
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ kind version
kind v0.17.0 go1.19.2 linux/amd64
@mochizuki875
Copy link
Contributor Author

/assign @mochizuki875

@mochizuki875
Copy link
Contributor Author

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 6, 2023
adrianludwin added a commit to adrianludwin/hierarchical-namespaces that referenced this issue Feb 15, 2023
E2Es broke a few days ago, likely when test-infra upgraded to 1.20. I
also couldn't run staticcheck on my Google workstation, which has 1.20,
with the same failure message. Upgrading staticcheck fixed the problem;
I also took the opportunity to match the test-infra krte image as well
as the Golang version (which caused some minor reformatting), and also
made the integ tests hermetic by including the setup-envtest tool (bug
 kubernetes-retired#252, based on an approach suggested in kubernetes-retired#253).

Tested: couldn't build on my workstation on Go 1.20 before this change;
can after it. Can also run integ tests after deleting local output of
setup-envtest.
adrianludwin added a commit to adrianludwin/hierarchical-namespaces that referenced this issue Feb 15, 2023
E2Es broke a few days ago, likely when test-infra upgraded to 1.20. I
also couldn't run staticcheck on my Google workstation, which has 1.20,
with the same failure message. Upgrading staticcheck fixed the problem;
I also took the opportunity to match the test-infra krte image as well
as the Golang version (which caused some minor reformatting), and also
made the integ tests hermetic by including the setup-envtest tool (bug
 kubernetes-retired#252, based on an approach suggested in kubernetes-retired#253).

Tested: couldn't build on my workstation on Go 1.20 before this change;
can after it. Can also run integ tests after deleting local output of
setup-envtest.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants