Skip to content

Commit 914238e

Browse files
committed
Kuberneters testing tooling cleanup
Signed-off-by: apostasie <[email protected]>
1 parent 36f7eb9 commit 914238e

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

pkg/testutil/nerdtest/requirements.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ var OnlyIPv6 = &test.Requirement{
6464
var OnlyKubernetes = &test.Requirement{
6565
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
6666
helpers.Write(kubernetes, only)
67+
if _, err := exec.LookPath("kubectl"); err != nil {
68+
return false, fmt.Sprintf("kubectl is not in the path: %+v", err)
69+
}
6770
ret = environmentHasKubernetes()
68-
if !ret {
71+
if ret {
72+
helpers.Write(Namespace, "k8s.io")
73+
} else {
6974
mess = "runner skips Kubernetes compatible tests in the non-Kubernetes environment"
7075
}
7176
return ret, mess

pkg/testutil/nerdtest/third-party.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ func BuildCtlCommand(helpers test.Helpers, args ...string) test.TestableCommand
3535
return cmd
3636
}
3737

38+
func KubeCtlCommand(helpers test.Helpers, args ...string) test.TestableCommand {
39+
kubectl, _ := exec.LookPath("kubectl")
40+
cmd := helpers.Custom(kubectl)
41+
cmd.WithArgs("--namespace=nerdctl-test-k8s")
42+
cmd.WithArgs(args...)
43+
return cmd
44+
}
45+
3846
func RegistryWithTokenAuth(data test.Data, helpers test.Helpers, user, pass string, port int, tls bool) (*registry.Server, *registry.TokenAuthServer) {
3947
rca := ca.New(data, helpers.T())
4048
as := registry.NewCesantaAuthServer(data, helpers, rca, 0, user, pass, tls)

pkg/testutil/testutil.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,6 @@ func NewBaseWithIPv6Compatible(t *testing.T) *Base {
762762
return newBase(t, Namespace, true, false)
763763
}
764764

765-
func NewBaseForKubernetes(t *testing.T) *Base {
766-
base := newBase(t, "k8s.io", false, true)
767-
// NOTE: kubectl namespaces are not the same as containerd namespaces.
768-
// We still want kube test objects segregated in their own Kube API namespace.
769-
KubectlHelper(base, "create", "namespace", Namespace).Run()
770-
return base
771-
}
772-
773765
func NewBase(t *testing.T) *Base {
774766
return newBase(t, Namespace, false, false)
775767
}
@@ -844,13 +836,3 @@ func RegisterBuildCacheCleanup(t *testing.T) {
844836
NewBase(t).Cmd("builder", "prune", "--all", "--force").Run()
845837
})
846838
}
847-
848-
func KubectlHelper(base *Base, args ...string) *Cmd {
849-
base.T.Helper()
850-
icmdCmd := icmd.Command("kubectl", append([]string{"--namespace", Namespace}, args...)...)
851-
icmdCmd.Env = base.Env
852-
return &Cmd{
853-
Cmd: icmdCmd,
854-
Base: base,
855-
}
856-
}

0 commit comments

Comments
 (0)