Skip to content

Commit 891544c

Browse files
author
Hantao (Will) Wang
committed
update the bin path if not using docker to build for test k8s
1 parent e66bbfd commit 891544c

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

test/k8s-integration/main.go

+18-14
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ var (
5858
)
5959

6060
const (
61-
pdImagePlaceholder = "gke.gcr.io/gcp-compute-persistent-disk-csi-driver"
62-
k8sBuildBinDir = "_output/dockerized/bin/linux/amd64"
63-
gkeTestClusterName = "gcp-pd-csi-driver-test-cluster"
61+
pdImagePlaceholder = "gke.gcr.io/gcp-compute-persistent-disk-csi-driver"
62+
k8sInDockerBuildBinDir = "_output/dockerized/bin/linux/amd64"
63+
k8sOutOfDockerBuildBinDir = "_output/bin"
64+
gkeTestClusterName = "gcp-pd-csi-driver-test-cluster"
6465
)
6566

6667
func init() {
@@ -182,6 +183,7 @@ func handle() error {
182183
k8sDir := filepath.Join(k8sParentDir, "kubernetes")
183184
testParentDir := generateUniqueTmpDir()
184185
testDir := filepath.Join(testParentDir, "kubernetes")
186+
k8sBuildBinDir := k8sInDockerBuildBinDir
185187
defer removeDir(k8sParentDir)
186188
defer removeDir(testParentDir)
187189

@@ -215,6 +217,7 @@ func handle() error {
215217
if err != nil {
216218
return fmt.Errorf("failed to build Gingko: %v", err)
217219
}
220+
k8sBuildBinDir = k8sOutOfDockerBuildBinDir
218221
} else {
219222
testDir = k8sDir
220223
}
@@ -270,12 +273,13 @@ func handle() error {
270273
}
271274

272275
// Run the tests using the testDir kubernetes
276+
fullK8sBuildBinPath := filepath.Join(testDir, k8sBuildBinDir)
273277
if len(*storageClassFile) != 0 {
274-
err = runCSITests(pkgDir, testDir, *testFocus, *storageClassFile, *gceZone)
278+
err = runCSITests(pkgDir, fullK8sBuildBinPath, *testFocus, *storageClassFile, *gceZone)
275279
} else if *migrationTest {
276-
err = runMigrationTests(pkgDir, testDir, *testFocus, *gceZone)
280+
err = runMigrationTests(pkgDir, fullK8sBuildBinPath, *testFocus, *gceZone)
277281
} else {
278-
return fmt.Errorf("Did not run either CSI or Migration test")
282+
return fmt.Errorf("did not run either CSI or Migration test")
279283
}
280284

281285
if err != nil {
@@ -298,21 +302,21 @@ func setEnvProject(project string) error {
298302
return nil
299303
}
300304

301-
func runMigrationTests(pkgDir, k8sDir, testFocus, gceZone string) error {
302-
return runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, "-storage.migratedPlugins=kubernetes.io/gce-pd")
305+
func runMigrationTests(pkgDir, k8sBinDir, testFocus, gceZone string) error {
306+
return runTestsWithConfig(k8sBinDir, gceZone, testFocus, "-storage.migratedPlugins=kubernetes.io/gce-pd")
303307
}
304308

305-
func runCSITests(pkgDir, k8sDir, testFocus, storageClassFile, gceZone string) error {
309+
func runCSITests(pkgDir, k8sBinDir, testFocus, storageClassFile, gceZone string) error {
306310
testDriverConfigFile, err := generateDriverConfigFile(pkgDir, storageClassFile)
307311
if err != nil {
308312
return err
309313
}
310314
testConfigArg := fmt.Sprintf("-storage.testdriver=%s", testDriverConfigFile)
311-
return runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, testConfigArg)
315+
return runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg)
312316
}
313317

314-
func runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, testConfigArg string) error {
315-
err := os.Chdir(k8sDir)
318+
func runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg string) error {
319+
err := os.Chdir(k8sBinDir)
316320
if err != nil {
317321
return err
318322
}
@@ -325,11 +329,11 @@ func runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, testConfigArg string
325329

326330
testFocusArg := fmt.Sprintf("-focus=%s", testFocus)
327331

328-
cmd := exec.Command(filepath.Join(k8sBuildBinDir, "ginkgo"),
332+
cmd := exec.Command("./ginkgo",
329333
"-p",
330334
testFocusArg,
331335
"-skip=\\[Disruptive\\]|\\[Serial\\]|\\[Feature:.+\\]",
332-
filepath.Join(k8sBuildBinDir, "e2e.test"),
336+
"e2e.test",
333337
"--",
334338
reportArg,
335339
"-provider=gce",

0 commit comments

Comments
 (0)