Skip to content

Commit d3e2ff0

Browse files
authored
Merge pull request #345 from davidz627/fix/numNodes
Add forced variable num-nodes so that we can give it to kubetest to force tests to run that have high node requirements
2 parents f293474 + af0fe08 commit d3e2ff0

6 files changed

+25
-12
lines changed

test/k8s-integration/cluster.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"os/exec"
77
"path/filepath"
8+
"strconv"
89

910
"k8s.io/klog"
1011
)
@@ -37,7 +38,7 @@ func buildKubernetes(k8sDir, command string) error {
3738
return nil
3839
}
3940

40-
func clusterUpGCE(k8sDir, gceZone string) error {
41+
func clusterUpGCE(k8sDir, gceZone string, numNodes int) error {
4142
kshPath := filepath.Join(k8sDir, "cluster", "kubectl.sh")
4243
_, err := os.Stat(kshPath)
4344
if err == nil {
@@ -58,6 +59,11 @@ func clusterUpGCE(k8sDir, gceZone string) error {
5859
klog.V(4).Infof("Set Kubernetes feature gates: %v", *kubeFeatureGates)
5960
}
6061

62+
err = os.Setenv("NUM_NODES", strconv.Itoa(numNodes))
63+
if err != nil {
64+
return err
65+
}
66+
6167
err = os.Setenv("KUBE_GCE_ZONE", gceZone)
6268
if err != nil {
6369
return err
@@ -71,7 +77,7 @@ func clusterUpGCE(k8sDir, gceZone string) error {
7177
return nil
7278
}
7379

74-
func clusterUpGKE(gceZone string) error {
80+
func clusterUpGKE(gceZone string, numNodes int) error {
7581
out, err := exec.Command("gcloud", "container", "clusters", "list", "--zone", gceZone,
7682
"--filter", fmt.Sprintf("name=%s", gkeTestClusterName)).CombinedOutput()
7783
if err != nil {
@@ -85,7 +91,7 @@ func clusterUpGKE(gceZone string) error {
8591
}
8692
}
8793
cmd := exec.Command("gcloud", "container", "clusters", "create", gkeTestClusterName,
88-
"--zone", gceZone, "--cluster-version", *gkeClusterVer, "--quiet")
94+
"--zone", gceZone, "--cluster-version", *gkeClusterVer, "--num-nodes", strconv.Itoa(numNodes), "--quiet")
8995
err = runCommand("Staring E2E Cluster on GKE", cmd)
9096
if err != nil {
9197
return fmt.Errorf("failed to bring up kubernetes e2e cluster on gke: %v", err)

test/k8s-integration/main.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var (
4040
localK8sDir = flag.String("local-k8s-dir", "", "local prebuilt kubernetes/kubernetes directory to use for cluster and test binaries")
4141
deploymentStrat = flag.String("deployment-strategy", "", "choose between deploying on gce or gke")
4242
gkeClusterVer = flag.String("gke-cluster-version", "", "version of Kubernetes master and node for gke")
43+
numNodes = flag.Int("num-nodes", -1, "the number of nodes in the test cluster")
4344
// Test infrastructure flags
4445
boskosResourceType = flag.String("boskos-resource-type", "gce-project", "name of the boskos resource type to reserve")
4546
storageClassFile = flag.String("storageclass-file", "", "name of storageclass yaml file to use for test relative to test/k8s-integration/config")
@@ -110,6 +111,10 @@ func main() {
110111
ensureVariable(testVersion, false, "Cannot set a test version when using a local k8s dir.")
111112
}
112113

114+
if *numNodes == -1 {
115+
klog.Fatalf("num-nodes must be set to number of nodes in cluster")
116+
}
117+
113118
err := handle()
114119
if err != nil {
115120
klog.Fatalf("Failed to run integration test: %v", err)
@@ -226,9 +231,9 @@ func handle() error {
226231
var err error = nil
227232
switch *deploymentStrat {
228233
case "gce":
229-
err = clusterUpGCE(k8sDir, *gceZone)
234+
err = clusterUpGCE(k8sDir, *gceZone, *numNodes)
230235
case "gke":
231-
err = clusterUpGKE(*gceZone)
236+
err = clusterUpGKE(*gceZone, *numNodes)
232237
default:
233238
err = fmt.Errorf("deployment-strategy must be set to 'gce' or 'gke', but is: %s", *deploymentStrat)
234239
}
@@ -339,6 +344,7 @@ func runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg string) err
339344
reportArg,
340345
"-provider=gce",
341346
"-node-os-distro=cos",
347+
fmt.Sprintf("-num-nodes=%v", *numNodes),
342348
fmt.Sprintf("-gce-zone=%s", gceZone),
343349
testConfigArg)
344350

test/run-k8s-integration-local.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ make -C ${PKGDIR} test-k8s-integration
2323
# --deploy-overlay-name=dev --storageclass-file=sc-standard.yaml \
2424
# --test-focus="External.Storage" --gce-zone="us-central1-b" \
2525
# --deployment-strategy=gke --gke-cluster-version=${gke_cluster_version} \
26-
# --test-version=${test_version}
26+
# --test-version=${test_version} --num-nodes=3
2727

2828
# This version of the command creates a GCE cluster. It downloads and builds two k8s releases,
2929
# one for the cluster and one for the tests, unless the cluster and test versioning is the same.
@@ -33,7 +33,7 @@ make -C ${PKGDIR} test-k8s-integration
3333
# --deploy-overlay-name=dev --storageclass-file=sc-standard.yaml \
3434
# --test-focus="External.Storage" --gce-zone="us-central1-b" \
3535
# --deployment-strategy=gce --kube-version=${kube_version} \
36-
# --test-version=${test_version}
36+
# --test-version=${test_version} --num-nodes=3
3737

3838
# This version of the command does not build the driver or K8s, points to a
3939
# local K8s repo to get the e2e.test binary, and does not bring up or down the cluster
@@ -42,4 +42,4 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
4242
--staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
4343
--deploy-overlay-name=dev --bringup-cluster=false --teardown-cluster=false --local-k8s-dir=$KTOP \
4444
--storageclass-file=sc-standard.yaml --do-driver-build=true --test-focus="External.Storage" \
45-
--gce-zone="us-central1-b"
45+
--gce-zone="us-central1-b" --num-nodes=${NUM_NODES:-3}

test/run-k8s-integration-migration-local.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
1919
--staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
2020
--deploy-overlay-name=dev --test-focus=${GCE_PD_TEST_FOCUS} \
2121
--kube-feature-gates="CSIMigration=true,CSIMigrationGCE=true" --migration-test=true --gce-zone="us-central1-b" \
22-
--deployment-strategy=gce --test-version=${test_version}
22+
--deployment-strategy=gce --test-version=${test_version} --num-nodes=${NUM_NODES:-3}
2323

2424
# This version of the command does not build the driver or K8s, points to a
2525
# local K8s repo to get the e2e.test binary, and does not bring up or down the cluster
@@ -29,4 +29,4 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
2929
# --staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
3030
# --deploy-overlay-name=dev --test-focus=${GCE_PD_TEST_FOCUS} \
3131
# --bringup-cluster=false --teardown-cluster=false --local-k8s-dir=$KTOP --migration-test=true \
32-
# --do-driver-build=true --gce-zone=${GCE_PD_ZONE}
32+
# --do-driver-build=true --gce-zone=${GCE_PD_ZONE} --num-nodes=${NUM_NODES:-3}

test/run-k8s-integration-migration.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=${kube_version} \
3838
--deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} \
3939
--do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type} \
4040
--migration-test=true --test-focus=${GCE_PD_TEST_FOCUS} \
41-
--gce-zone="us-central1-b" --deployment-strategy=${deployment_strategy} --test-version=${test_version}
41+
--gce-zone="us-central1-b" --deployment-strategy=${deployment_strategy} --test-version=${test_version} \
42+
--num-nodes=3

test/run-k8s-integration.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ base_cmd="${PKGDIR}/bin/k8s-integration-test \
2626
--run-in-prow=true --deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} \
2727
--do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type} \
2828
--storageclass-file=sc-standard.yaml --test-focus="External.Storage" --gce-zone="us-central1-b" \
29-
--deployment-strategy=${deployment_strategy} --test-version=${test_version}"
29+
--deployment-strategy=${deployment_strategy} --test-version=${test_version} --num-nodes=3"
3030

3131
if [ "$deployment_strategy" = "gke" ]; then
3232
base_cmd="${base_cmd} --gke-cluster-version=${gke_cluster_version}"

0 commit comments

Comments
 (0)