mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: Refactor getting test results directory
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
2afaddd5b7
commit
d0e5c44f67
@ -412,10 +412,7 @@ func longestHistory(histories [][]watchEvent) []watchEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkOperationsAndPersistResults(t *testing.T, lg *zap.Logger, operations []porcupine.Operation, clus *e2e.EtcdProcessCluster) {
|
func checkOperationsAndPersistResults(t *testing.T, lg *zap.Logger, operations []porcupine.Operation, clus *e2e.EtcdProcessCluster) {
|
||||||
path, err := testResultsDirectory(t)
|
path := testResultsDirectory(t)
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
linearizable, info := porcupine.CheckOperationsVerbose(model.Etcd, operations, 5*time.Minute)
|
linearizable, info := porcupine.CheckOperationsVerbose(model.Etcd, operations, 5*time.Minute)
|
||||||
if linearizable == porcupine.Illegal {
|
if linearizable == porcupine.Illegal {
|
||||||
@ -431,7 +428,7 @@ func checkOperationsAndPersistResults(t *testing.T, lg *zap.Logger, operations [
|
|||||||
|
|
||||||
visualizationPath := filepath.Join(path, "history.html")
|
visualizationPath := filepath.Join(path, "history.html")
|
||||||
lg.Info("Saving visualization", zap.String("path", visualizationPath))
|
lg.Info("Saving visualization", zap.String("path", visualizationPath))
|
||||||
err = porcupine.VisualizePath(model.Etcd, info, visualizationPath)
|
err := porcupine.VisualizePath(model.Etcd, info, visualizationPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to visualize, err: %v", err)
|
t.Errorf("Failed to visualize, err: %v", err)
|
||||||
}
|
}
|
||||||
@ -470,16 +467,20 @@ func persistMemberDataDir(t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessClu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testResultsDirectory(t *testing.T) (string, error) {
|
func testResultsDirectory(t *testing.T) string {
|
||||||
path, err := filepath.Abs(filepath.Join(resultsDirectory, strings.ReplaceAll(t.Name(), "/", "_")))
|
path, err := filepath.Abs(filepath.Join(resultsDirectory, strings.ReplaceAll(t.Name(), "/", "_")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return path, err
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = os.RemoveAll(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(path, 0700)
|
err = os.MkdirAll(path, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return path, err
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
return path, nil
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
// forcestopCluster stops the etcd member with signal kill.
|
// forcestopCluster stops the etcd member with signal kill.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user