Skip to content

Commit cfefa6a

Browse files
authored
Merge pull request kubernetes-sigs#10427 from k8s-infra-cherrypick-robot/cherry-pick-10424-to-release-1.6
[release-1.6] 🐛 e2e: fix kubetest to allow parallel execution on different clusters
2 parents 5001599 + 55e31cc commit cfefa6a

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
@@ -252,6 +252,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
252252
ArtifactsDirectory: input.ArtifactFolder,
253253
ConfigFilePath: kubetestConfigFilePath,
254254
GinkgoNodes: int(clusterResources.ExpectedWorkerNodes()),
255+
ClusterName: clusterResources.Cluster.GetName(),
255256
},
256257
)
257258
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
@@ -144,6 +144,7 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
144144
ArtifactsDirectory: input.ArtifactFolder,
145145
ConfigFilePath: kubetestConfigFilePath,
146146
GinkgoNodes: ginkgoNodes,
147+
ClusterName: clusterResources.Cluster.GetName(),
147148
},
148149
)
149150
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
@@ -143,6 +143,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
143143
ClusterProxy: proxy.GetWorkloadCluster(ctx, namespace, clusterName),
144144
ArtifactsDirectory: artifactFolder,
145145
ConfigFilePath: "./data/kubetest/dualstack.yaml",
146+
ClusterName: clusterName,
146147
},
147148
)).To(Succeed())
148149
},
@@ -169,6 +170,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
169170
ClusterProxy: proxy.GetWorkloadCluster(ctx, namespace, clusterName),
170171
ArtifactsDirectory: artifactFolder,
171172
ConfigFilePath: "./data/kubetest/dualstack.yaml",
173+
ClusterName: clusterName,
172174
},
173175
)).To(Succeed())
174176
},

test/framework/kubetest/run.go

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

7780
// Run executes kube-test given an artifact directory, and sets settings
@@ -81,6 +84,12 @@ func Run(ctx context.Context, input RunInput) error {
8184
if input.ClusterProxy == nil {
8285
return errors.New("ClusterProxy must be provided")
8386
}
87+
// If input.ClusterName is not set use a random string to allow parallel execution
88+
// of kubetest on different clusters.
89+
if input.ClusterName == "" {
90+
input.ClusterName = rand.String(10)
91+
}
92+
8493
if input.GinkgoNodes == 0 {
8594
input.GinkgoNodes = DefaultGinkgoNodes
8695
}
@@ -102,7 +111,7 @@ func Run(ctx context.Context, input RunInput) error {
102111
input.KubernetesVersion = discoveredVersion
103112
}
104113
input.ArtifactsDirectory = framework.ResolveArtifactsDirectory(input.ArtifactsDirectory)
105-
reportDir := path.Join(input.ArtifactsDirectory, "kubetest")
114+
reportDir := path.Join(input.ArtifactsDirectory, "kubetest", input.ClusterName)
106115
outputDir := path.Join(reportDir, "e2e-output")
107116
kubetestConfigDir := path.Join(reportDir, "config")
108117
if err := os.MkdirAll(outputDir, 0o750); err != nil {
@@ -132,7 +141,7 @@ func Run(ctx context.Context, input RunInput) error {
132141
"report-dir": "/output",
133142
"e2e-output-dir": "/output/e2e-output",
134143
"dump-logs-on-failure": "false",
135-
"report-prefix": "kubetest.",
144+
"report-prefix": fmt.Sprintf("kubetest.%s.", input.ClusterName),
136145
"num-nodes": strconv.FormatInt(int64(input.NumberOfNodes), 10),
137146
}
138147
ginkgoArgs := buildArgs(ginkgoVars, "-")

0 commit comments

Comments
 (0)