Skip to content

Commit

Permalink
Merge pull request #4766 from randomvariable/remove-viper-release-03
Browse files Browse the repository at this point in the history
🌱 Backport of conformance updates for Kubernetes 1.22
  • Loading branch information
k8s-ci-robot authored Jun 8, 2021
2 parents 3a7cc9e + 091b709 commit 2ac7d74
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions test/framework/kubetest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package kubetest

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -31,6 +32,7 @@ import (
"k8s.io/client-go/discovery"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/yaml"
)

const (
Expand Down Expand Up @@ -109,12 +111,11 @@ func Run(input RunInput) error {
"slowSpecThreshold": strconv.Itoa(input.GinkgoSlowSpecThreshold),
}

// Copy configuration files for kubetest into the artifacts directory
// to avoid issues with volume mounts on MacOS
tmpConfigFilePath := path.Join(kubetestConfigDir, "viper-config.yaml")
if err := copyFile(input.ConfigFilePath, tmpConfigFilePath); err != nil {
config, err := parseKubetestConfig(input.ConfigFilePath)
if err != nil {
return err
}

tmpKubeConfigPath, err := dockeriseKubeconfig(kubetestConfigDir, input.ClusterProxy.GetKubeconfigPath())
if err != nil {
return err
Expand All @@ -136,7 +137,6 @@ func Run(input RunInput) error {
"dump-logs-on-failure": "false",
"report-prefix": "kubetest.",
"num-nodes": strconv.FormatInt(int64(input.NumberOfNodes), 10),
"viper-config": "/tmp/viper-config.yaml",
}
ginkgoArgs := buildArgs(ginkgoVars, "-")
e2eArgs := buildArgs(e2eVars, "--")
Expand All @@ -145,22 +145,22 @@ func Run(input RunInput) error {
}
kubeConfigVolumeMount := volumeArg(tmpKubeConfigPath, "/tmp/kubeconfig")
outputVolumeMount := volumeArg(reportDir, "/output")
viperVolumeMount := volumeArg(tmpConfigFilePath, "/tmp/viper-config.yaml")
user, err := user.Current()
if err != nil {
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")
entrypointArg := "--entrypoint=/usr/local/bin/ginkgo"
e2eCmd := exec.Command("docker", "run", "--user", userArg, entrypointArg, kubeConfigVolumeMount, outputVolumeMount, "-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")
e2eCmd.Args = append(e2eCmd.Args, "--")
e2eCmd.Args = append(e2eCmd.Args, e2eArgs...)
e2eCmd.Args = append(e2eCmd.Args, config.toFlags()...)
e2eCmd = framework.CompleteCommand(e2eCmd, "Running e2e test", false)
if err := e2eCmd.Run(); err != nil {
return errors.Wrap(err, "Unable to run conformance tests")
Expand All @@ -171,6 +171,24 @@ func Run(input RunInput) error {
return nil
}

type kubetestConfig map[string]string

func (c kubetestConfig) toFlags() []string {
return buildArgs(c, "-")
}

func parseKubetestConfig(kubetestConfigFile string) (kubetestConfig, error) {
conf := make(kubetestConfig)
data, err := ioutil.ReadFile(kubetestConfigFile)
if err != nil {
return nil, fmt.Errorf("unable to read kubetest config file %s: %w", kubetestConfigFile, err)
}
if err := yaml.Unmarshal(data, conf); err != nil {
return nil, fmt.Errorf("unable to parse kubetest config file %s as valid, non-nested YAML: %w", kubetestConfigFile, err)
}
return conf, nil
}

func isUsingCIArtifactsVersion(k8sVersion string) bool {
return strings.Contains(k8sVersion, "-")
}
Expand Down

0 comments on commit 2ac7d74

Please sign in to comment.