Skip to content

envtest: Not respecting custom apiserver/etcd paths #3373

@ahmetb

Description

@ahmetb

It appears if I provide custom paths to envtest.Environment struct it ignores them. Minimal repro:

func TestNewEnvironment(t *testing.T) {
	testEnv := &envtest.Environment{
		ControlPlane: envtest.ControlPlane{
			APIServer: &envtest.APIServer{
				Path: "/Users/abalkan/workspace/my-project/bin/kubebuilder_1.30.3_darwin_amd64/kube-apiserver",
			},
			Etcd: &envtest.Etcd{
				Path: "/Users/abalkan/workspace/my-project/bin/kubebuilder_1.30.3_darwin_amd64/etcd",
			},
		},
	}

	// Start the control plane
	cfg, err := testEnv.Start()
	if err != nil {
		t.Fatalf("Failed to start control plane: %v", err)
	}
}

Gives error:

Failed to start control plane: 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

so it's looking at the wrong path despite the provided path override.

Currently one has to do t.Setenv("TEST_ASSET_KUBE_APISERVER", "...") to make this work I think, which is a little less than ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions