Skip to content

Commit

Permalink
Merge pull request #10426 from k8s-infra-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-10424-to-release-1.7

[release-1.7] 🐛 e2e: fix kubetest to allow parallel execution on different clusters
  • Loading branch information
k8s-ci-robot committed Apr 12, 2024
2 parents 1432bbe + b39ebbf commit f4cdfac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
ArtifactsDirectory: input.ArtifactFolder,
ConfigFilePath: kubetestConfigFilePath,
GinkgoNodes: int(clusterResources.ExpectedWorkerNodes()),
ClusterName: clusterResources.Cluster.GetName(),
},
)
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")
Expand Down
1 change: 1 addition & 0 deletions test/e2e/k8s_conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
ArtifactsDirectory: input.ArtifactFolder,
ConfigFilePath: kubetestConfigFilePath,
GinkgoNodes: ginkgoNodes,
ClusterName: clusterResources.Cluster.GetName(),
},
)
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/quick_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
ClusterProxy: proxy.GetWorkloadCluster(ctx, namespace, clusterName),
ArtifactsDirectory: artifactFolder,
ConfigFilePath: "./data/kubetest/dualstack.yaml",
ClusterName: clusterName,
},
)).To(Succeed())
},
Expand All @@ -183,6 +184,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
ClusterProxy: proxy.GetWorkloadCluster(ctx, namespace, clusterName),
ArtifactsDirectory: artifactFolder,
ConfigFilePath: "./data/kubetest/dualstack.yaml",
ClusterName: clusterName,
},
)).To(Succeed())
},
Expand Down
13 changes: 11 additions & 2 deletions test/framework/kubetest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/onsi/ginkgo/v2"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/discovery"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -73,6 +74,8 @@ type RunInput struct {
// 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
// ClusterName is the name of the cluster to run the test at
ClusterName string
}

// Run executes kube-test given an artifact directory, and sets settings
Expand All @@ -82,6 +85,12 @@ func Run(ctx context.Context, input RunInput) error {
if input.ClusterProxy == nil {
return errors.New("ClusterProxy must be provided")
}
// If input.ClusterName is not set use a random string to allow parallel execution
// of kubetest on different clusters.
if input.ClusterName == "" {
input.ClusterName = rand.String(10)
}

if input.GinkgoNodes == 0 {
input.GinkgoNodes = DefaultGinkgoNodes
}
Expand All @@ -103,7 +112,7 @@ func Run(ctx context.Context, input RunInput) error {
input.KubernetesVersion = discoveredVersion
}
input.ArtifactsDirectory = framework.ResolveArtifactsDirectory(input.ArtifactsDirectory)
reportDir := path.Join(input.ArtifactsDirectory, "kubetest")
reportDir := path.Join(input.ArtifactsDirectory, "kubetest", input.ClusterName)
outputDir := path.Join(reportDir, "e2e-output")
kubetestConfigDir := path.Join(reportDir, "config")
if err := os.MkdirAll(outputDir, 0o750); err != nil {
Expand Down Expand Up @@ -133,7 +142,7 @@ func Run(ctx context.Context, input RunInput) error {
"report-dir": "/output",
"e2e-output-dir": "/output/e2e-output",
"dump-logs-on-failure": "false",
"report-prefix": "kubetest.",
"report-prefix": fmt.Sprintf("kubetest.%s.", input.ClusterName),
"num-nodes": strconv.FormatInt(int64(input.NumberOfNodes), 10),
}
ginkgoArgs := buildArgs(ginkgoVars, "-")
Expand Down

0 comments on commit f4cdfac

Please sign in to comment.