Skip to content

Commit aa0769d

Browse files
authored
Merge pull request #349 from davidz627/fix/migrateToKubetest
Migrate to k8s integration tests to kubetest
2 parents c9dd259 + 5831038 commit aa0769d

File tree

3 files changed

+32
-45
lines changed

3 files changed

+32
-45
lines changed

test/k8s-integration/main.go

+20-33
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ func handle() error {
187187
k8sDir := filepath.Join(k8sParentDir, "kubernetes")
188188
testParentDir := generateUniqueTmpDir()
189189
testDir := filepath.Join(testParentDir, "kubernetes")
190-
k8sBuildBinDir := k8sInDockerBuildBinDir
191190
defer removeDir(k8sParentDir)
192191
defer removeDir(testParentDir)
193192

@@ -217,11 +216,6 @@ func handle() error {
217216
if err != nil {
218217
return fmt.Errorf("failed to build Kubernetes: %v", err)
219218
}
220-
err = buildKubernetes(testDir, "ginkgo")
221-
if err != nil {
222-
return fmt.Errorf("failed to build Gingko: %v", err)
223-
}
224-
k8sBuildBinDir = k8sOutOfDockerBuildBinDir
225219
} else {
226220
testDir = k8sDir
227221
}
@@ -277,11 +271,10 @@ func handle() error {
277271
}
278272

279273
// Run the tests using the testDir kubernetes
280-
fullK8sBuildBinPath := filepath.Join(testDir, k8sBuildBinDir)
281274
if len(*storageClassFile) != 0 {
282-
err = runCSITests(pkgDir, fullK8sBuildBinPath, *testFocus, *storageClassFile, *gceZone)
275+
err = runCSITests(pkgDir, k8sDir, *testFocus, *storageClassFile)
283276
} else if *migrationTest {
284-
err = runMigrationTests(pkgDir, fullK8sBuildBinPath, *testFocus, *gceZone)
277+
err = runMigrationTests(pkgDir, k8sDir, *testFocus)
285278
} else {
286279
return fmt.Errorf("did not run either CSI or Migration test")
287280
}
@@ -306,21 +299,21 @@ func setEnvProject(project string) error {
306299
return nil
307300
}
308301

309-
func runMigrationTests(pkgDir, k8sBinDir, testFocus, gceZone string) error {
310-
return runTestsWithConfig(k8sBinDir, gceZone, testFocus, "-storage.migratedPlugins=kubernetes.io/gce-pd")
302+
func runMigrationTests(pkgDir, k8sDir, testFocus string) error {
303+
return runTestsWithConfig(k8sDir, testFocus, "--storage.migratedPlugins=kubernetes.io/gce-pd")
311304
}
312305

313-
func runCSITests(pkgDir, k8sBinDir, testFocus, storageClassFile, gceZone string) error {
306+
func runCSITests(pkgDir, k8sDir, testFocus, storageClassFile string) error {
314307
testDriverConfigFile, err := generateDriverConfigFile(pkgDir, storageClassFile)
315308
if err != nil {
316309
return err
317310
}
318-
testConfigArg := fmt.Sprintf("-storage.testdriver=%s", testDriverConfigFile)
319-
return runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg)
311+
testConfigArg := fmt.Sprintf("--storage.testdriver=%s", testDriverConfigFile)
312+
return runTestsWithConfig(k8sDir, testFocus, testConfigArg)
320313
}
321314

322-
func runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg string) error {
323-
err := os.Chdir(k8sBinDir)
315+
func runTestsWithConfig(k8sDir, testFocus, testConfigArg string) error {
316+
err := os.Chdir(k8sDir)
324317
if err != nil {
325318
return err
326319
}
@@ -331,23 +324,17 @@ func runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg string) err
331324
artifactsDir, _ := os.LookupEnv("ARTIFACTS")
332325
reportArg := fmt.Sprintf("-report-dir=%s", artifactsDir)
333326

334-
testFocusArg := fmt.Sprintf("-focus=%s", testFocus)
335-
336-
cmd := exec.Command("./ginkgo",
337-
"-p",
338-
"-v",
339-
testFocusArg,
340-
"-skip=\\[Disruptive\\]|\\[Serial\\]|\\[Feature:.+\\]",
341-
"e2e.test",
342-
"--",
343-
"-v=5",
344-
reportArg,
345-
"-provider=gce",
346-
"-node-os-distro=cos",
347-
fmt.Sprintf("-num-nodes=%v", *numNodes),
348-
fmt.Sprintf("-gce-zone=%s", gceZone),
349-
testConfigArg)
350-
327+
kubetestArgs := fmt.Sprintf("--ginkgo.focus=%s --ginkgo.skip=%s %s %s",
328+
testFocus,
329+
"\\[Disruptive\\]|\\[Serial\\]|\\[Feature:.+\\]",
330+
testConfigArg,
331+
reportArg)
332+
333+
cmd := exec.Command("kubetest",
334+
"--test",
335+
"--ginkgo-parallel",
336+
fmt.Sprintf("--test_args=%s", kubetestArgs),
337+
)
351338
err = runCommand("Running Tests", cmd)
352339
if err != nil {
353340
return fmt.Errorf("failed to run tests on e2e cluster: %v", err)

test/run-k8s-integration-local.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ make -C ${PKGDIR} test-k8s-integration
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
4040

41-
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
41+
${PKGDIR}/bin/k8s-integration-test --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" \

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ ensure_var GCE_PD_SA_DIR
1515

1616
make -C ${PKGDIR} test-k8s-integration
1717

18-
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
19-
--staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
20-
--deploy-overlay-name=dev --test-focus=${GCE_PD_TEST_FOCUS} \
21-
--kube-feature-gates="CSIMigration=true,CSIMigrationGCE=true" --migration-test=true --gce-zone="us-central1-b" \
22-
--deployment-strategy=gce --test-version=${test_version} --num-nodes=${NUM_NODES:-3}
18+
# ${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false \
19+
# --staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json \
20+
# --deploy-overlay-name=dev --test-focus=${GCE_PD_TEST_FOCUS} \
21+
# --kube-feature-gates="CSIMigration=true,CSIMigrationGCE=true" --migration-test=true --gce-zone="us-central1-b" \
22+
# --deployment-strategy=gce --test-version=${test_version} --gce-zone=${GCE_PD_ZONE} \
23+
# --num-nodes=${NUM_NODES:-3}
2324

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

0 commit comments

Comments
 (0)