Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Cherry-pick: Add optional parameter for using repolist #4102

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion test/framework/kubetest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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
Expand Down Expand Up @@ -117,6 +120,14 @@ func Run(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",
Expand All @@ -140,7 +151,11 @@ func Run(input RunInput) error {
return errors.Wrap(err, "unable to determine current user")
}
userArg := user.Uid + ":" + user.Gid
e2eCmd := exec.Command("docker", "run", "--user", userArg, kubeConfigVolumeMount, outputVolumeMount, viperVolumeMount, "-t", input.ConformanceImage)
e2eCmd := exec.Command("docker", "run", "--user", userArg, kubeConfigVolumeMount, outputVolumeMount, viperVolumeMount, "-t")
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")
Expand Down Expand Up @@ -218,6 +233,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) {
Expand All @@ -236,3 +256,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
}