Fix clean up data dir failed for TestEtcdRestartLoad (#15506)

Signed-off-by: yun.zhang <yun.zhang@zilliz.com>
pull/15515/head
jaime 2022-02-09 18:37:45 +08:00 committed by GitHub
parent 0ae0a1a75b
commit 87dd4e8f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -29,16 +29,18 @@ import (
)
func TestEtcdRestartLoad(te *testing.T) {
etcdDataDir := "/tmp/_etcd_data"
os.Setenv(metricsinfo.DeployModeEnvKey, metricsinfo.StandaloneDeployMode)
param := new(paramtable.ServiceParam)
param.Init()
param.BaseTable.Save("etcd.use.embed", "true")
// TODO, not sure if the relative path works for ci environment
param.BaseTable.Save("etcd.config.path", "../../../configs/advanced/etcd.yaml")
param.BaseTable.Save("etcd.data.dir", "etcd.test.data.dir")
param.BaseTable.Save("etcd.data.dir", etcdDataDir)
//clean up data
defer func() {
os.RemoveAll("etcd.test.data.dir")
err := os.RemoveAll(etcdDataDir)
assert.NoError(te, err)
}()
param.EtcdCfg.LoadCfgToMemory()
te.Run("EtcdKV SaveRestartAndLoad", func(t *testing.T) {
@ -87,5 +89,7 @@ func TestEtcdRestartLoad(te *testing.T) {
assert.NoError(t, err)
assert.Equal(t, test.value, val)
}
metaKv.Close()
})
}