ci: cleanup base directory code

Fix the following minor bugs.

- The wrong description of TEST_BASE_DIR environment variable.
- baseTestDir() don't handle error properly

Signed-off-by: tenzen-y <toyonomajyutushi@yahoo.co.jp>
Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
This commit is contained in:
tenzen-y authored and Satoru Takeuchi committed 2020-10-15 14:14:23 +00:00
1 parent f0b2c6eacf
commit 356f21569f
2 files changed
+16 -6

No files matched your search

+7 -2
View File
@@ -406,11 +406,16 @@ func (h *CephInstaller) GetRookExternalClusterMonSecret(namespace string) (*v1.S
}
func (h *CephInstaller) initTestDir(namespace string) (string, error) {
h.hostPathToDelete = path.Join(baseTestDir(), "rook-test")
val, err := baseTestDir()
if err != nil {
return "", err
}
h.hostPathToDelete = path.Join(val, "rook-test")
testDir := path.Join(h.hostPathToDelete, namespace)
// skip the test dir creation if we are not running under "/data"
if baseTestDir() != "/data" {
if val != "/data" {
// Create the test dir on the local host
if err := os.MkdirAll(testDir, 0777); err != nil {
return "", err
+9 -4
View File
@@ -50,13 +50,18 @@ func UsePVC() bool {
}
// baseTestDir gets the base test directory
func baseTestDir() string {
// If the base test directory is actively set to empty (as in CI), we use the current working directory.
func baseTestDir() (string, error) {
// If the base test directory is actively set to WORKING_DIR (as in CI),
// we use the current working directory.
val := getEnvVarWithDefault("TEST_BASE_DIR", "/data")
if val == "WORKING_DIR" {
val, _ = os.Getwd()
var err error
val, err = os.Getwd()
if err != nil {
return "", err
}
}
return val
return val, nil
}
// TestScratchDevice get the scratch device to be used for OSD