Skip to content

Commit eb20bb3

Browse files
authored
Merge pull request #338 from hantaowang/correct-k8s-build-bin-path
update the bin path if not using docker to build for test k8s
2 parents ba2ada3 + fdef9c9 commit eb20bb3

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
@@ -57,9 +57,10 @@ var (
5757
)
5858

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

6566
func init() {
@@ -181,6 +182,7 @@ func handle() error {
181182
k8sDir := filepath.Join(k8sParentDir, "kubernetes")
182183
testParentDir := generateUniqueTmpDir()
183184
testDir := filepath.Join(testParentDir, "kubernetes")
185+
k8sBuildBinDir := k8sInDockerBuildBinDir
184186
defer removeDir(k8sParentDir)
185187
defer removeDir(testParentDir)
186188

@@ -214,6 +216,7 @@ func handle() error {
214216
if err != nil {
215217
return fmt.Errorf("failed to build Gingko: %v", err)
216218
}
219+
k8sBuildBinDir = k8sOutOfDockerBuildBinDir
217220
} else {
218221
testDir = k8sDir
219222
}
@@ -269,12 +272,13 @@ func handle() error {
269272
}
270273

271274
// Run the tests using the testDir kubernetes
275+
fullK8sBuildBinPath := filepath.Join(testDir, k8sBuildBinDir)
272276
if len(*storageClassFile) != 0 {
273-
err = runCSITests(pkgDir, testDir, *testFocus, *storageClassFile, *gceZone)
277+
err = runCSITests(pkgDir, fullK8sBuildBinPath, *testFocus, *storageClassFile, *gceZone)
274278
} else if *migrationTest {
275-
err = runMigrationTests(pkgDir, testDir, *testFocus, *gceZone)
279+
err = runMigrationTests(pkgDir, fullK8sBuildBinPath, *testFocus, *gceZone)
276280
} else {
277-
return fmt.Errorf("Did not run either CSI or Migration test")
281+
return fmt.Errorf("did not run either CSI or Migration test")
278282
}
279283

280284
if err != nil {
@@ -297,21 +301,21 @@ func setEnvProject(project string) error {
297301
return nil
298302
}
299303

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

304-
func runCSITests(pkgDir, k8sDir, testFocus, storageClassFile, gceZone string) error {
308+
func runCSITests(pkgDir, k8sBinDir, testFocus, storageClassFile, gceZone string) error {
305309
testDriverConfigFile, err := generateDriverConfigFile(pkgDir, storageClassFile)
306310
if err != nil {
307311
return err
308312
}
309313
testConfigArg := fmt.Sprintf("-storage.testdriver=%s", testDriverConfigFile)
310-
return runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, testConfigArg)
314+
return runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg)
311315
}
312316

313-
func runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, testConfigArg string) error {
314-
err := os.Chdir(k8sDir)
317+
func runTestsWithConfig(k8sBinDir, gceZone, testFocus, testConfigArg string) error {
318+
err := os.Chdir(k8sBinDir)
315319
if err != nil {
316320
return err
317321
}
@@ -324,11 +328,11 @@ func runTestsWithConfig(pkgDir, k8sDir, gceZone, testFocus, testConfigArg string
324328

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

327-
cmd := exec.Command(filepath.Join(k8sBuildBinDir, "ginkgo"),
331+
cmd := exec.Command("./ginkgo",
328332
"-p",
329333
testFocusArg,
330334
"-skip=\\[Disruptive\\]|\\[Serial\\]|\\[Feature:.+\\]",
331-
filepath.Join(k8sBuildBinDir, "e2e.test"),
335+
"e2e.test",
332336
"--",
333337
reportArg,
334338
"-provider=gce",

0 commit comments

Comments
 (0)