Skip to content

Commit d8fa9f7

Browse files
committed
test/conformance: use environment variables KUBETEST_NUMBER_OF_NODES and KUBETEST_GINKGO_NODES to allow overwriting hardcoded kubetest configuration
1 parent 12c2572 commit d8fa9f7

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

test/e2e/k8s_conformance.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"os"
2323
"path/filepath"
24+
"strconv"
2425

2526
. "github.com/onsi/ginkgo/v2"
2627
. "github.com/onsi/gomega"
@@ -56,6 +57,8 @@ type K8SConformanceSpecInput struct {
5657
func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSpecInput) {
5758
const (
5859
kubetestConfigurationVariable = "KUBETEST_CONFIGURATION"
60+
kubetestNumberOfNodesVariable = "KUBETEST_NUMBER_OF_NODES"
61+
kubetestGinkgoNodesVariable = "KUBETEST_GINKGO_NODES"
5962
)
6063
var (
6164
specName = "k8s-conformance"
@@ -118,15 +121,29 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
118121

119122
workloadProxy := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterResources.Cluster.Name)
120123

124+
var err error
125+
126+
numberOfNodes := int(workerMachineCount)
127+
if s, ok := os.LookupEnv(kubetestNumberOfNodesVariable); ok && s != "" {
128+
numberOfNodes, err = strconv.Atoi(s)
129+
Expect(err).ToNot(HaveOccurred(), "Failed to parse kubetestNumberOfNodesVariable to int")
130+
}
131+
132+
ginkgoNodes := int(workerMachineCount)
133+
if s, ok := os.LookupEnv(kubetestGinkgoNodesVariable); ok && s != "" {
134+
ginkgoNodes, err = strconv.Atoi(s)
135+
Expect(err).ToNot(HaveOccurred(), "Failed to parse kubetestGinkgoNodesVariable to int")
136+
}
137+
121138
// Start running conformance test suites.
122-
err := kubetest.Run(
139+
err = kubetest.Run(
123140
ctx,
124141
kubetest.RunInput{
125142
ClusterProxy: workloadProxy,
126-
NumberOfNodes: int(workerMachineCount),
143+
NumberOfNodes: numberOfNodes,
127144
ArtifactsDirectory: input.ArtifactFolder,
128145
ConfigFilePath: kubetestConfigFilePath,
129-
GinkgoNodes: int(workerMachineCount),
146+
GinkgoNodes: ginkgoNodes,
130147
},
131148
)
132149
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")

0 commit comments

Comments
 (0)