Skip to content

Commit 5a9314d

Browse files
committed
fix config path not exist issue
Signed-off-by: rayo1uo <[email protected]>
1 parent d066251 commit 5a9314d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

test/e2e/suites/init/init_with_config_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var _ = ginkgo.Describe("Custom E2E: initialize karmada control plane with confi
8383
tempPki = filepath.Join(karmadaDataPath, "pki")
8484
etcdDataPath = filepath.Join(karmadaDataPath, "etcd-data")
8585

86-
configFilePath = filepath.Join(karmadaDataPath, "karmada-config.yaml")
86+
configFilePath = filepath.Join(karmadaConfigPath, "karmada-config.yaml")
8787
})
8888

8989
ginkgo.It("Deploy karmada control plane with config file", func() {
@@ -100,7 +100,12 @@ var _ = ginkgo.Describe("Custom E2E: initialize karmada control plane with confi
100100
}
101101

102102
renderedContent := renderTemplateWithGenericMap(configTemplate, configVariables)
103-
err := os.WriteFile(configFilePath, []byte(renderedContent), 0600)
103+
104+
dir := filepath.Dir(configFilePath)
105+
err := os.MkdirAll(dir, os.FileMode(0700))
106+
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
107+
108+
err = os.WriteFile(configFilePath, []byte(renderedContent), os.FileMode(0700))
104109
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
105110
})
106111

test/e2e/suites/init/suite_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var (
6666
crdsPath string
6767
karmadaAPIServerNodePort string
6868
karmadaDataPath string
69+
karmadaConfigPath string
6970
)
7071

7172
// image
@@ -135,6 +136,8 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { return nil }, func([]byte
135136

136137
karmadaDataPath = filepath.Join(os.TempDir(), KarmadaInstanceNamePrefix+rand.String(RandomStrLength))
137138
karmadaAPIServerNodePort = strconv.Itoa(rand.IntnRange(30000, 31000))
139+
140+
karmadaConfigPath = filepath.Join(os.TempDir(), KarmadaInstanceNamePrefix+rand.String(RandomStrLength))
138141
})
139142

140143
var _ = ginkgo.SynchronizedAfterSuite(func() {
@@ -146,7 +149,10 @@ var _ = ginkgo.SynchronizedAfterSuite(func() {
146149
}
147150

148151
err := os.RemoveAll(karmadaDataPath)
149-
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), fmt.Sprintf("Failed to remove temp dir %s", karmadaDataPath))
152+
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), fmt.Sprintf("Failed to remove temp data dir %s", karmadaDataPath))
153+
154+
err = os.RemoveAll(karmadaConfigPath)
155+
gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), fmt.Sprintf("Failed to remove temp config dir %s", karmadaConfigPath))
150156
}, func() {})
151157

152158
// setupTestNamespace will create a namespace in control plane and all member clusters, most of cases will run against it.

0 commit comments

Comments
 (0)