From f5696e9f1122d118a2d0708f1891aaa294e66ed1 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Mon, 11 Jan 2021 10:53:57 -0800 Subject: [PATCH] Add optional parameter for using repolist --- test/framework/kubetest/run.go | 35 +++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/framework/kubetest/run.go b/test/framework/kubetest/run.go index 8ae6ad643ada..920e57f0875e 100644 --- a/test/framework/kubetest/run.go +++ b/test/framework/kubetest/run.go @@ -63,6 +63,9 @@ type RunInput struct { KubernetesVersion string // ConformanceImage is an optional field to specify an exact conformance image ConformanceImage string + // KubeTestRepoListPath is optional file for specifying custom image repositories + // https://github.com/kubernetes/kubernetes/blob/master/test/images/README.md#testing-the-new-image + KubeTestRepoListPath string } // Run executes kube-test given an artifact directory, and sets settings @@ -118,6 +121,14 @@ func Run(ctx context.Context, input RunInput) error { return err } + var testRepoListVolumeArgs []string + if input.KubeTestRepoListPath != "" { + testRepoListVolumeArgs, err = buildKubeTestRepoListArgs(kubetestConfigDir, input.KubeTestRepoListPath) + if err != nil { + return err + } + } + e2eVars := map[string]string{ "kubeconfig": "/tmp/kubeconfig", "provider": "skeleton", @@ -142,7 +153,11 @@ func Run(ctx context.Context, input RunInput) error { } userArg := user.Uid + ":" + user.Gid networkArg := "--network=kind" - e2eCmd := exec.Command("docker", "run", "--user", userArg, kubeConfigVolumeMount, outputVolumeMount, viperVolumeMount, "-t", networkArg, input.ConformanceImage) + e2eCmd := exec.Command("docker", "run", "--user", userArg, kubeConfigVolumeMount, outputVolumeMount, viperVolumeMount, "-t", networkArg) + if len(testRepoListVolumeArgs) > 0 { + e2eCmd.Args = append(e2eCmd.Args, testRepoListVolumeArgs...) + } + e2eCmd.Args = append(e2eCmd.Args, input.ConformanceImage) e2eCmd.Args = append(e2eCmd.Args, "/usr/local/bin/ginkgo") e2eCmd.Args = append(e2eCmd.Args, ginkgoArgs...) e2eCmd.Args = append(e2eCmd.Args, "/usr/local/bin/e2e.test") @@ -220,6 +235,11 @@ func volumeArg(src, dest string) string { return volumeArg } +func envArg(key, value string) string { + envArg := "-e" + key + "=" + value + return envArg +} + func versionToConformanceImage(kubernetesVersion string) string { k8sVersion := strings.ReplaceAll(kubernetesVersion, "+", "_") if isUsingCIArtifactsVersion(kubernetesVersion) { @@ -238,3 +258,16 @@ func buildArgs(kv map[string]string, flagMarker string) []string { } return args } + +func buildKubeTestRepoListArgs(kubetestConfigDir, kubeTestRepoListPath string) ([]string, error) { + args := make([]string, 2) + + tmpKubeTestRepoListPath := path.Join(kubetestConfigDir, "repo_list.yaml") + if err := copyFile(kubeTestRepoListPath, tmpKubeTestRepoListPath); err != nil { + return nil, err + } + dest := "/tmp/repo_list.yaml" + args[0] = envArg("KUBE_TEST_REPO_LIST", dest) + args[1] = volumeArg(tmpKubeTestRepoListPath, dest) + return args, nil +}