Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.5] 🐛 test: fix kubetest to allow parallel execution on different clusters #10432

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,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 @@ -127,6 +127,7 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
ArtifactsDirectory: input.ArtifactFolder,
ConfigFilePath: kubetestConfigFilePath,
GinkgoNodes: int(workerMachineCount),
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 @@ -146,6 +146,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
// Pin the conformance image to workaround https://github.com/kubernetes-sigs/cluster-api/issues/9240 .
// This should get dropped again when bumping to a version post v1.28.0 in `test/e2e/config/docker.yaml`.
ConformanceImage: "gcr.io/k8s-staging-ci-images/conformance:v1.29.0-alpha.0.190_18290bfdc8fbe1",
ClusterName: clusterName,
},
)).To(Succeed())
},
Expand Down Expand Up @@ -175,6 +176,7 @@ var _ = Describe("When following the Cluster API quick-start with dualstack and
// Pin the conformance image to workaround https://github.com/kubernetes-sigs/cluster-api/issues/9240 .
// This should get dropped again when bumping to a version post v1.28.0 in `test/e2e/config/docker.yaml`.
ConformanceImage: "gcr.io/k8s-staging-ci-images/conformance:v1.29.0-alpha.0.190_18290bfdc8fbe1",
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 @@ -30,6 +30,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 @@ -72,6 +73,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 @@ -81,6 +84,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 @@ -102,7 +111,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 @@ -132,7 +141,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
Loading