Skip to content

Commit

Permalink
Merge pull request #4069 from jsturtevant/add-kubetestrepolist
Browse files Browse the repository at this point in the history
🌱 Add optional parameter for using repolist to the kubetest library
  • Loading branch information
k8s-ci-robot authored Jan 19, 2021
2 parents aa86bbb + 03d92d1 commit 18473b7
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/framework/kubetest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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")
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}

0 comments on commit 18473b7

Please sign in to comment.