Skip to content

Add forced variable num-nodes so that we can give it to kubetest to force tests to run that have high node requirements #345

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

Merged
merged 1 commit into from
Jul 16, 2019
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
12 changes: 9 additions & 3 deletions test/k8s-integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strconv"

"k8s.io/klog"
)
Expand Down Expand Up @@ -37,7 +38,7 @@ func buildKubernetes(k8sDir, command string) error {
return nil
}

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

err = os.Setenv("NUM_NODES", strconv.Itoa(numNodes))
if err != nil {
return err
}

err = os.Setenv("KUBE_GCE_ZONE", gceZone)
if err != nil {
return err
Expand All @@ -71,7 +77,7 @@ func clusterUpGCE(k8sDir, gceZone string) error {
return nil
}

func clusterUpGKE(gceZone string) error {
func clusterUpGKE(gceZone string, numNodes int) error {
out, err := exec.Command("gcloud", "container", "clusters", "list", "--zone", gceZone,
"--filter", fmt.Sprintf("name=%s", gkeTestClusterName)).CombinedOutput()
if err != nil {
Expand All @@ -85,7 +91,7 @@ func clusterUpGKE(gceZone string) error {
}
}
cmd := exec.Command("gcloud", "container", "clusters", "create", gkeTestClusterName,
"--zone", gceZone, "--cluster-version", *gkeClusterVer, "--quiet")
"--zone", gceZone, "--cluster-version", *gkeClusterVer, "--num-nodes", strconv.Itoa(numNodes), "--quiet")
err = runCommand("Staring E2E Cluster on GKE", cmd)
if err != nil {
return fmt.Errorf("failed to bring up kubernetes e2e cluster on gke: %v", err)
Expand Down
10 changes: 8 additions & 2 deletions test/k8s-integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (
localK8sDir = flag.String("local-k8s-dir", "", "local prebuilt kubernetes/kubernetes directory to use for cluster and test binaries")
deploymentStrat = flag.String("deployment-strategy", "", "choose between deploying on gce or gke")
gkeClusterVer = flag.String("gke-cluster-version", "", "version of Kubernetes master and node for gke")
numNodes = flag.Int("num-nodes", -1, "the number of nodes in the test cluster")
// Test infrastructure flags
boskosResourceType = flag.String("boskos-resource-type", "gce-project", "name of the boskos resource type to reserve")
storageClassFile = flag.String("storageclass-file", "", "name of storageclass yaml file to use for test relative to test/k8s-integration/config")
Expand Down Expand Up @@ -110,6 +111,10 @@ func main() {
ensureVariable(testVersion, false, "Cannot set a test version when using a local k8s dir.")
}

if *numNodes == -1 {
klog.Fatalf("num-nodes must be set to number of nodes in cluster")
}

err := handle()
if err != nil {
klog.Fatalf("Failed to run integration test: %v", err)
Expand Down Expand Up @@ -226,9 +231,9 @@ func handle() error {
var err error = nil
switch *deploymentStrat {
case "gce":
err = clusterUpGCE(k8sDir, *gceZone)
err = clusterUpGCE(k8sDir, *gceZone, *numNodes)
case "gke":
err = clusterUpGKE(*gceZone)
err = clusterUpGKE(*gceZone, *numNodes)
default:
err = fmt.Errorf("deployment-strategy must be set to 'gce' or 'gke', but is: %s", *deploymentStrat)
}
Expand Down Expand Up @@ -339,6 +344,7 @@ func runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg string) err
reportArg,
"-provider=gce",
"-node-os-distro=cos",
fmt.Sprintf("-num-nodes=%v", *numNodes),
fmt.Sprintf("-gce-zone=%s", gceZone),
testConfigArg)

Expand Down
6 changes: 3 additions & 3 deletions test/run-k8s-integration-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ make -C ${PKGDIR} test-k8s-integration
# --deploy-overlay-name=dev --storageclass-file=sc-standard.yaml \
# --test-focus="External.Storage" --gce-zone="us-central1-b" \
# --deployment-strategy=gke --gke-cluster-version=${gke_cluster_version} \
# --test-version=${test_version}
# --test-version=${test_version} --num-nodes=3

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

# This version of the command does not build the driver or K8s, points to a
# local K8s repo to get the e2e.test binary, and does not bring up or down the cluster
Expand All @@ -42,4 +42,4 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
--staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
--deploy-overlay-name=dev --bringup-cluster=false --teardown-cluster=false --local-k8s-dir=$KTOP \
--storageclass-file=sc-standard.yaml --do-driver-build=true --test-focus="External.Storage" \
--gce-zone="us-central1-b"
--gce-zone="us-central1-b" --num-nodes=${NUM_NODES:-3}
4 changes: 2 additions & 2 deletions test/run-k8s-integration-migration-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
--staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
--deploy-overlay-name=dev --test-focus=${GCE_PD_TEST_FOCUS} \
--kube-feature-gates="CSIMigration=true,CSIMigrationGCE=true" --migration-test=true --gce-zone="us-central1-b" \
--deployment-strategy=gce --test-version=${test_version}
--deployment-strategy=gce --test-version=${test_version} --num-nodes=${NUM_NODES:-3}

# This version of the command does not build the driver or K8s, points to a
# local K8s repo to get the e2e.test binary, and does not bring up or down the cluster
Expand All @@ -29,4 +29,4 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
# --staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
# --deploy-overlay-name=dev --test-focus=${GCE_PD_TEST_FOCUS} \
# --bringup-cluster=false --teardown-cluster=false --local-k8s-dir=$KTOP --migration-test=true \
# --do-driver-build=true --gce-zone=${GCE_PD_ZONE}
# --do-driver-build=true --gce-zone=${GCE_PD_ZONE} --num-nodes=${NUM_NODES:-3}
3 changes: 2 additions & 1 deletion test/run-k8s-integration-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ ${PKGDIR}/bin/k8s-integration-test --kube-version=${kube_version} \
--deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} \
--do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type} \
--migration-test=true --test-focus=${GCE_PD_TEST_FOCUS} \
--gce-zone="us-central1-b" --deployment-strategy=${deployment_strategy} --test-version=${test_version}
--gce-zone="us-central1-b" --deployment-strategy=${deployment_strategy} --test-version=${test_version} \
--num-nodes=3
2 changes: 1 addition & 1 deletion test/run-k8s-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ base_cmd="${PKGDIR}/bin/k8s-integration-test \
--run-in-prow=true --deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} \
--do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type} \
--storageclass-file=sc-standard.yaml --test-focus="External.Storage" --gce-zone="us-central1-b" \
--deployment-strategy=${deployment_strategy} --test-version=${test_version}"
--deployment-strategy=${deployment_strategy} --test-version=${test_version} --num-nodes=3"

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