mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Deflake cpumanager checkpoint unit tests
This commit is contained in:
parent
a23cf7077e
commit
7268b1d557
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@ -30,8 +31,6 @@ import (
|
|||||||
|
|
||||||
const testingCheckpoint = "cpumanager_checkpoint_test"
|
const testingCheckpoint = "cpumanager_checkpoint_test"
|
||||||
|
|
||||||
var testingDir = os.TempDir()
|
|
||||||
|
|
||||||
func TestCheckpointStateRestore(t *testing.T) {
|
func TestCheckpointStateRestore(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
description string
|
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
|
// create checkpoint manager for testing
|
||||||
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
|
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
|
||||||
if err != nil {
|
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)
|
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create testing checkpoint manager: %v", err)
|
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)
|
cpm, err := checkpointmanager.NewCheckpointManager(testingDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create testing checkpoint manager: %v", err)
|
t.Fatalf("could not create testing checkpoint manager: %v", err)
|
||||||
@ -376,6 +395,13 @@ func TestCheckpointStateClear(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.description, func(t *testing.T) {
|
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)
|
state, err := NewCheckpointState(testingDir, testingCheckpoint, "none", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create testing checkpointState instance: %v", err)
|
t.Fatalf("could not create testing checkpointState instance: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user