Skip to content

Commit db522fc

Browse files
authored
Merge pull request kubernetes-sigs#10424 from chrischdi/pr-fix-kubetest-parallel
🐛 e2e: fix kubetest to allow parallel execution on different clusters
2 parents 0cb503c + 57eac88 commit db522fc

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

test/e2e/cluster_upgrade.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
256256
ArtifactsDirectory: input.ArtifactFolder,
257257
ConfigFilePath: kubetestConfigFilePath,
258258
GinkgoNodes: int(clusterResources.ExpectedWorkerNodes()),
259+
ClusterName: clusterResources.Cluster.GetName(),
259260
},
260261
)
261262
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")

test/e2e/k8s_conformance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
148148
ArtifactsDirectory: input.ArtifactFolder,
149149
ConfigFilePath: kubetestConfigFilePath,
150150
GinkgoNodes: ginkgoNodes,
151+
ClusterName: clusterResources.Cluster.GetName(),
151152
},
152153
)
153154
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")

test/e2e/quick_start_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
157157
ClusterProxy: proxy.GetWorkloadCluster(ctx, namespace, clusterName),
158158
ArtifactsDirectory: artifactFolder,
159159
ConfigFilePath: "./data/kubetest/dualstack.yaml",
160+
ClusterName: clusterName,
160161
},
161162
)).To(Succeed())
162163
},
@@ -183,6 +184,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
183184
ClusterProxy: proxy.GetWorkloadCluster(ctx, namespace, clusterName),
184185
ArtifactsDirectory: artifactFolder,
185186
ConfigFilePath: "./data/kubetest/dualstack.yaml",
187+
ClusterName: clusterName,
186188
},
187189
)).To(Succeed())
188190
},

test/framework/kubetest/run.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/onsi/ginkgo/v2"
3232
"github.com/pkg/errors"
3333
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34+
"k8s.io/apimachinery/pkg/util/rand"
3435
"k8s.io/client-go/discovery"
3536
"k8s.io/client-go/tools/clientcmd"
3637
"sigs.k8s.io/yaml"
@@ -73,6 +74,8 @@ type RunInput struct {
7374
// KubeTestRepoListPath is optional file for specifying custom image repositories
7475
// https://github.com/kubernetes/kubernetes/blob/master/test/images/README.md#testing-the-new-image
7576
KubeTestRepoListPath string
77+
// ClusterName is the name of the cluster to run the test at
78+
ClusterName string
7679
}
7780

7881
// Run executes kube-test given an artifact directory, and sets settings
@@ -82,6 +85,12 @@ func Run(ctx context.Context, input RunInput) error {
8285
if input.ClusterProxy == nil {
8386
return errors.New("ClusterProxy must be provided")
8487
}
88+
// If input.ClusterName is not set use a random string to allow parallel execution
89+
// of kubetest on different clusters.
90+
if input.ClusterName == "" {
91+
input.ClusterName = rand.String(10)
92+
}
93+
8594
if input.GinkgoNodes == 0 {
8695
input.GinkgoNodes = DefaultGinkgoNodes
8796
}
@@ -103,7 +112,7 @@ func Run(ctx context.Context, input RunInput) error {
103112
input.KubernetesVersion = discoveredVersion
104113
}
105114
input.ArtifactsDirectory = framework.ResolveArtifactsDirectory(input.ArtifactsDirectory)
106-
reportDir := path.Join(input.ArtifactsDirectory, "kubetest")
115+
reportDir := path.Join(input.ArtifactsDirectory, "kubetest", input.ClusterName)
107116
outputDir := path.Join(reportDir, "e2e-output")
108117
kubetestConfigDir := path.Join(reportDir, "config")
109118
if err := os.MkdirAll(outputDir, 0o750); err != nil {
@@ -133,7 +142,7 @@ func Run(ctx context.Context, input RunInput) error {
133142
"report-dir": "/output",
134143
"e2e-output-dir": "/output/e2e-output",
135144
"dump-logs-on-failure": "false",
136-
"report-prefix": "kubetest.",
145+
"report-prefix": fmt.Sprintf("kubetest.%s.", input.ClusterName),
137146
"num-nodes": strconv.FormatInt(int64(input.NumberOfNodes), 10),
138147
}
139148
ginkgoArgs := buildArgs(ginkgoVars, "-")

0 commit comments

Comments
 (0)