Merge pull request #94541 from liggitt/deflake-cpucheckpoint

Deflake cpumanager checkpoint unit tests
This commit is contained in:
Kubernetes Prow Robot 2020-09-04 18:47:40 -07:00 committed by GitHub
commit 60c421b6f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ limitations under the License.
package state
import (
"io/ioutil"
"os"
"reflect"
"strings"
@ -30,8 +31,6 @@ import (
const testingCheckpoint = "cpumanager_checkpoint_test"
var testingDir = os.TempDir()
func TestCheckpointStateRestore(t *testing.T) {
testCases := []struct {
description string
@ -200,6 +199,12 @@ func TestCheckpointStateRestore(t *testing.T) {
},
}
// create temp dir
testingDir, err := ioutil.TempDir("", "cpumanager_state_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(testingDir)
// create checkpoint manager for testing
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
if err != nil {
@ -258,6 +263,13 @@ func TestCheckpointStateStore(t *testing.T) {
},
}
// create temp dir
testingDir, err := ioutil.TempDir("", "cpumanager_state_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(testingDir)
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
if err != nil {
t.Fatalf("could not create testing checkpoint manager: %v", err)
@ -324,6 +336,13 @@ func TestCheckpointStateHelpers(t *testing.T) {
},
}
// create temp dir
testingDir, err := ioutil.TempDir("", "cpumanager_state_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(testingDir)
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
if err != nil {
t.Fatalf("could not create testing checkpoint manager: %v", err)
@ -376,6 +395,13 @@ func TestCheckpointStateClear(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
// create temp dir
testingDir, err := ioutil.TempDir("", "cpumanager_state_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(testingDir)
state, err := NewCheckpointState(testingDir, testingCheckpoint, "none", nil)
if err != nil {
t.Fatalf("could not create testing checkpointState instance: %v", err)