diff options
Diffstat (limited to 'libpod/state_test.go')
-rw-r--r-- | libpod/state_test.go | 908 |
1 files changed, 452 insertions, 456 deletions
diff --git a/libpod/state_test.go b/libpod/state_test.go index 4bd00ab55..d93a371f3 100644 --- a/libpod/state_test.go +++ b/libpod/state_test.go @@ -8,17 +8,16 @@ import ( "testing" "time" - "github.com/containers/libpod/libpod/lock" "github.com/containers/storage" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -// Returns state, tmp directory containing all state files, lock manager, and -// error. +// Returns state, tmp directory containing all state files, locks directory +// (subdirectory of tmp dir), and error // Closing the state and removing the given tmp directory should be sufficient -// to clean up. -type emptyStateFunc func() (State, string, lock.Manager, error) +// to clean up +type emptyStateFunc func() (State, string, string, error) const ( tmpDirPrefix = "libpod_state_test_" @@ -32,10 +31,10 @@ var ( ) // Get an empty BoltDB state for use in tests -func getEmptyBoltState() (s State, p string, m lock.Manager, err error) { +func getEmptyBoltState() (s State, p string, p2 string, err error) { tmpDir, err := ioutil.TempDir("", tmpDirPrefix) if err != nil { - return nil, "", nil, err + return nil, "", "", err } defer func() { if err != nil { @@ -44,30 +43,30 @@ func getEmptyBoltState() (s State, p string, m lock.Manager, err error) { }() dbPath := filepath.Join(tmpDir, "db.sql") + lockDir := filepath.Join(tmpDir, "locks") - lockManager, err := lock.NewInMemoryManager(16) - if err != nil { - return nil, "", nil, err + if err := os.Mkdir(lockDir, 0755); err != nil { + return nil, "", "", err } runtime := new(Runtime) runtime.config = new(RuntimeConfig) runtime.config.StorageConfig = storage.StoreOptions{} - runtime.lockManager = lockManager + runtime.lockDir = lockDir state, err := NewBoltState(dbPath, runtime) if err != nil { - return nil, "", nil, err + return nil, "", "", err } - return state, tmpDir, lockManager, nil + return state, tmpDir, lockDir, nil } // Get an empty in-memory state for use in tests -func getEmptyInMemoryState() (s State, p string, m lock.Manager, err error) { +func getEmptyInMemoryState() (s State, p string, p2 string, err error) { tmpDir, err := ioutil.TempDir("", tmpDirPrefix) if err != nil { - return nil, "", nil, err + return nil, "", "", err } defer func() { if err != nil { @@ -77,20 +76,17 @@ func getEmptyInMemoryState() (s State, p string, m lock.Manager, err error) { state, err := NewInMemoryState() if err != nil { - return nil, "", nil, err - } - - lockManager, err := lock.NewInMemoryManager(16) - if err != nil { - return nil, "", nil, err + return nil, "", "", err } - return state, tmpDir, lockManager, nil + // Don't need a separate locks dir as InMemoryState stores nothing on + // disk + return state, tmpDir, tmpDir, nil } -func runForAllStates(t *testing.T, testFunc func(*testing.T, State, lock.Manager)) { +func runForAllStates(t *testing.T, testFunc func(*testing.T, State, string)) { for stateName, stateFunc := range testedStates { - state, path, manager, err := stateFunc() + state, path, lockPath, err := stateFunc() if err != nil { t.Fatalf("Error initializing state %s: %v", stateName, err) } @@ -98,7 +94,7 @@ func runForAllStates(t *testing.T, testFunc func(*testing.T, State, lock.Manager defer state.Close() success := t.Run(stateName, func(t *testing.T) { - testFunc(t, state, manager) + testFunc(t, state, lockPath) }) if !success { t.Fail() @@ -107,8 +103,8 @@ func runForAllStates(t *testing.T, testFunc func(*testing.T, State, lock.Manager } func TestAddAndGetContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -122,10 +118,10 @@ func TestAddAndGetContainer(t *testing.T) { } func TestAddAndGetContainerFromMultiple(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -142,8 +138,8 @@ func TestAddAndGetContainerFromMultiple(t *testing.T) { } func TestGetContainerPodSameIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -155,17 +151,17 @@ func TestGetContainerPodSameIDFails(t *testing.T) { } func TestAddInvalidContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.AddContainer(&Container{config: &ContainerConfig{ID: "1234"}}) assert.Error(t, err) }) } func TestAddDuplicateCtrIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(testCtr1.ID(), "test2", manager) + testCtr2, err := getTestContainer(testCtr1.ID(), "test2", lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -181,10 +177,10 @@ func TestAddDuplicateCtrIDFails(t *testing.T) { } func TestAddDuplicateCtrNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(strings.Repeat("2", 32), testCtr1.Name(), manager) + testCtr2, err := getTestContainer(strings.Repeat("2", 32), testCtr1.Name(), lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -200,10 +196,10 @@ func TestAddDuplicateCtrNameFails(t *testing.T) { } func TestAddCtrPodDupIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(testPod.ID(), "testCtr", manager) + testCtr, err := getTestContainer(testPod.ID(), "testCtr", lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -219,10 +215,10 @@ func TestAddCtrPodDupIDFails(t *testing.T) { } func TestAddCtrPodDupNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), manager) + testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -238,11 +234,11 @@ func TestAddCtrPodDupNameFails(t *testing.T) { } func TestAddCtrInPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -260,16 +256,16 @@ func TestAddCtrInPodFails(t *testing.T) { } func TestAddCtrDepInPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.ID() @@ -292,10 +288,10 @@ func TestAddCtrDepInPodFails(t *testing.T) { } func TestAddCtrDepInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -316,10 +312,10 @@ func TestAddCtrDepInSameNamespaceSucceeds(t *testing.T) { } func TestAddCtrDepInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -342,8 +338,8 @@ func TestAddCtrDepInDifferentNamespaceFails(t *testing.T) { } func TestAddCtrSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -361,8 +357,8 @@ func TestAddCtrSameNamespaceSucceeds(t *testing.T) { } func TestAddCtrDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -381,22 +377,22 @@ func TestAddCtrDifferentNamespaceFails(t *testing.T) { } func TestGetNonexistentContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Container("does not exist") assert.Error(t, err) }) } func TestGetContainerWithEmptyIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Container("") assert.Error(t, err) }) } func TestGetContainerInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test2" @@ -412,8 +408,8 @@ func TestGetContainerInDifferentNamespaceFails(t *testing.T) { } func TestGetContainerInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -431,8 +427,8 @@ func TestGetContainerInSameNamespaceSucceeds(t *testing.T) { } func TestGetContainerInNamespaceWhileNotInNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -448,22 +444,22 @@ func TestGetContainerInNamespaceWhileNotInNamespaceSucceeds(t *testing.T) { } func TestLookupContainerWithEmptyIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupContainer("") assert.Error(t, err) }) } func TestLookupNonexistentContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupContainer("does not exist") assert.Error(t, err) }) } func TestLookupContainerByFullID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -477,8 +473,8 @@ func TestLookupContainerByFullID(t *testing.T) { } func TestLookupContainerByUniquePartialID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -492,10 +488,10 @@ func TestLookupContainerByUniquePartialID(t *testing.T) { } func TestLookupContainerByNonUniquePartialIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", manager) + testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -510,8 +506,8 @@ func TestLookupContainerByNonUniquePartialIDFails(t *testing.T) { } func TestLookupContainerByName(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -525,8 +521,8 @@ func TestLookupContainerByName(t *testing.T) { } func TestLookupCtrByPodNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -538,8 +534,8 @@ func TestLookupCtrByPodNameFails(t *testing.T) { } func TestLookupCtrByPodIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -551,8 +547,8 @@ func TestLookupCtrByPodIDFails(t *testing.T) { } func TestLookupCtrInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -570,8 +566,8 @@ func TestLookupCtrInSameNamespaceSucceeds(t *testing.T) { } func TestLookupCtrInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -587,11 +583,11 @@ func TestLookupCtrInDifferentNamespaceFails(t *testing.T) { } func TestLookupContainerMatchInDifferentNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestContainer(strings.Repeat("0", 32), "test1", lockPath) assert.NoError(t, err) testCtr1.config.Namespace = "test2" - testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", manager) + testCtr2, err := getTestContainer(strings.Repeat("0", 31)+"1", "test2", lockPath) assert.NoError(t, err) testCtr2.config.Namespace = "test1" @@ -611,14 +607,14 @@ func TestLookupContainerMatchInDifferentNamespaceSucceeds(t *testing.T) { } func TestHasContainerEmptyIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.HasContainer("") assert.Error(t, err) }) } func TestHasContainerNoSuchContainerReturnsFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { exists, err := state.HasContainer("does not exist") assert.NoError(t, err) assert.False(t, exists) @@ -626,8 +622,8 @@ func TestHasContainerNoSuchContainerReturnsFalse(t *testing.T) { } func TestHasContainerFindsContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -640,8 +636,8 @@ func TestHasContainerFindsContainer(t *testing.T) { } func TestHasContainerPodIDIsFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -654,8 +650,8 @@ func TestHasContainerPodIDIsFalse(t *testing.T) { } func TestHasContainerSameNamespaceIsTrue(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -672,8 +668,8 @@ func TestHasContainerSameNamespaceIsTrue(t *testing.T) { } func TestHasContainerDifferentNamespaceIsFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -690,8 +686,8 @@ func TestHasContainerDifferentNamespaceIsFalse(t *testing.T) { } func TestSaveAndUpdateContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -715,8 +711,8 @@ func TestSaveAndUpdateContainer(t *testing.T) { } func TestSaveAndUpdateContainerSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -744,8 +740,8 @@ func TestSaveAndUpdateContainerSameNamespaceSucceeds(t *testing.T) { } func TestUpdateContainerNotInDatabaseReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.UpdateContainer(testCtr) @@ -755,15 +751,15 @@ func TestUpdateContainerNotInDatabaseReturnsError(t *testing.T) { } func TestUpdateInvalidContainerReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.UpdateContainer(&Container{config: &ContainerConfig{ID: "1234"}}) assert.Error(t, err) }) } func TestUpdateContainerNotInNamespaceReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -779,15 +775,15 @@ func TestUpdateContainerNotInNamespaceReturnsError(t *testing.T) { } func TestSaveInvalidContainerReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.SaveContainer(&Container{config: &ContainerConfig{ID: "1234"}}) assert.Error(t, err) }) } func TestSaveContainerNotInStateReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.SaveContainer(testCtr) @@ -797,8 +793,8 @@ func TestSaveContainerNotInStateReturnsError(t *testing.T) { } func TestSaveContainerNotInNamespaceReturnsError(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -814,8 +810,8 @@ func TestSaveContainerNotInNamespaceReturnsError(t *testing.T) { } func TestRemoveContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -835,8 +831,8 @@ func TestRemoveContainer(t *testing.T) { } func TestRemoveNonexistantContainerFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.RemoveContainer(testCtr) @@ -846,8 +842,8 @@ func TestRemoveNonexistantContainerFails(t *testing.T) { } func TestRemoveContainerNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -873,7 +869,7 @@ func TestRemoveContainerNotInNamespaceFails(t *testing.T) { } func TestGetAllContainersOnNewStateIsEmpty(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { ctrs, err := state.AllContainers() assert.NoError(t, err) assert.Equal(t, 0, len(ctrs)) @@ -881,8 +877,8 @@ func TestGetAllContainersOnNewStateIsEmpty(t *testing.T) { } func TestGetAllContainersWithOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -897,10 +893,10 @@ func TestGetAllContainersWithOneContainer(t *testing.T) { } func TestGetAllContainersTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -916,8 +912,8 @@ func TestGetAllContainersTwoContainers(t *testing.T) { } func TestGetAllContainersNoContainerInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -934,13 +930,13 @@ func TestGetAllContainersNoContainerInNamespace(t *testing.T) { } func TestGetContainerOneContainerInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr1.config.Namespace = "test1" - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr1) @@ -960,15 +956,15 @@ func TestGetContainerOneContainerInNamespace(t *testing.T) { } func TestContainerInUseInvalidContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.ContainerInUse(&Container{}) assert.Error(t, err) }) } func TestContainerInUseCtrNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) _, err = state.ContainerInUse(testCtr) assert.Error(t, err) @@ -976,8 +972,8 @@ func TestContainerInUseCtrNotInState(t *testing.T) { } func TestContainerInUseCtrNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -993,10 +989,10 @@ func TestContainerInUseCtrNotInNamespace(t *testing.T) { } func TestContainerInUseOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1015,12 +1011,12 @@ func TestContainerInUseOneContainer(t *testing.T) { } func TestContainerInUseTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr3, err := getTestCtrN("3", manager) + testCtr3, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1042,10 +1038,10 @@ func TestContainerInUseTwoContainers(t *testing.T) { } func TestContainerInUseOneContainerMultipleDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1065,10 +1061,10 @@ func TestContainerInUseOneContainerMultipleDependencies(t *testing.T) { } func TestContainerInUseGenericDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.Dependencies = []string{testCtr1.config.ID} @@ -1087,12 +1083,12 @@ func TestContainerInUseGenericDependency(t *testing.T) { } func TestContainerInUseMultipleGenericDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr3, err := getTestCtrN("3", manager) + testCtr3, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr3.config.Dependencies = []string{testCtr1.config.ID, testCtr2.config.ID} @@ -1119,10 +1115,10 @@ func TestContainerInUseMultipleGenericDependencies(t *testing.T) { } func TestContainerInUseGenericAndNamespaceDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.Dependencies = []string{testCtr1.config.ID} @@ -1142,10 +1138,10 @@ func TestContainerInUseGenericAndNamespaceDependencies(t *testing.T) { } func TestCannotRemoveContainerWithDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.config.ID @@ -1166,10 +1162,10 @@ func TestCannotRemoveContainerWithDependency(t *testing.T) { } func TestCannotRemoveContainerWithGenericDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.Dependencies = []string{testCtr1.config.ID} @@ -1190,10 +1186,10 @@ func TestCannotRemoveContainerWithGenericDependency(t *testing.T) { } func TestCanRemoveContainerAfterDependencyRemoved(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.ID() @@ -1217,10 +1213,10 @@ func TestCanRemoveContainerAfterDependencyRemoved(t *testing.T) { } func TestCanRemoveContainerAfterDependencyRemovedDuplicate(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr1, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr1, err := getTestCtr1(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtr2(manager) + testCtr2, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr2.config.UserNsCtr = testCtr1.ID() @@ -1245,11 +1241,11 @@ func TestCanRemoveContainerAfterDependencyRemovedDuplicate(t *testing.T) { } func TestCannotUsePodAsDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod2(manager) + testPod, err := getTestPod2(lockPath) assert.NoError(t, err) testCtr.config.UserNsCtr = testPod.ID() @@ -1267,8 +1263,8 @@ func TestCannotUsePodAsDependency(t *testing.T) { } func TestCannotUseBadIDAsDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.UserNsCtr = strings.Repeat("5", 32) @@ -1283,8 +1279,8 @@ func TestCannotUseBadIDAsDependency(t *testing.T) { } func TestCannotUseBadIDAsGenericDependency(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) testCtr.config.Dependencies = []string{strings.Repeat("5", 32)} @@ -1299,22 +1295,22 @@ func TestCannotUseBadIDAsGenericDependency(t *testing.T) { } func TestGetPodDoesNotExist(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Pod("doesnotexist") assert.Error(t, err) }) } func TestGetPodEmptyID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.Pod("") assert.Error(t, err) }) } func TestGetPodOnePod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1328,11 +1324,11 @@ func TestGetPodOnePod(t *testing.T) { } func TestGetOnePodFromTwo(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1349,11 +1345,11 @@ func TestGetOnePodFromTwo(t *testing.T) { } func TestGetNotExistPodWithPods(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1368,8 +1364,8 @@ func TestGetNotExistPodWithPods(t *testing.T) { } func TestGetPodByCtrID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1381,8 +1377,8 @@ func TestGetPodByCtrID(t *testing.T) { } func TestGetPodInNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1400,8 +1396,8 @@ func TestGetPodInNamespaceSucceeds(t *testing.T) { } func TestGetPodPodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1417,22 +1413,22 @@ func TestGetPodPodNotInNamespaceFails(t *testing.T) { } func TestLookupPodEmptyID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupPod("") assert.Error(t, err) }) } func TestLookupNotExistPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.LookupPod("doesnotexist") assert.Error(t, err) }) } func TestLookupPodFullID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1446,8 +1442,8 @@ func TestLookupPodFullID(t *testing.T) { } func TestLookupPodUniquePartialID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1461,11 +1457,11 @@ func TestLookupPodUniquePartialID(t *testing.T) { } func TestLookupPodNonUniquePartialID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", lockPath) assert.NoError(t, err) - testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", manager) + testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1480,8 +1476,8 @@ func TestLookupPodNonUniquePartialID(t *testing.T) { } func TestLookupPodByName(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1495,8 +1491,8 @@ func TestLookupPodByName(t *testing.T) { } func TestLookupPodByCtrID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1508,8 +1504,8 @@ func TestLookupPodByCtrID(t *testing.T) { } func TestLookupPodByCtrName(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1521,8 +1517,8 @@ func TestLookupPodByCtrName(t *testing.T) { } func TestLookupPodInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1540,8 +1536,8 @@ func TestLookupPodInSameNamespaceSucceeds(t *testing.T) { } func TestLookupPodInDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1557,13 +1553,13 @@ func TestLookupPodInDifferentNamespaceFails(t *testing.T) { } func TestLookupPodOneInDifferentNamespaceFindsRightPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod(strings.Repeat("1", 32), "test1", lockPath) assert.NoError(t, err) testPod1.config.Namespace = "test1" - testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", manager) + testPod2, err := getTestPod(strings.Repeat("1", 31)+"2", "test2", lockPath) assert.NoError(t, err) testPod2.config.Namespace = "test2" @@ -1584,14 +1580,14 @@ func TestLookupPodOneInDifferentNamespaceFindsRightPod(t *testing.T) { } func TestHasPodEmptyIDErrors(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.HasPod("") assert.Error(t, err) }) } func TestHasPodNoSuchPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { exist, err := state.HasPod("notexist") assert.NoError(t, err) assert.False(t, exist) @@ -1599,8 +1595,8 @@ func TestHasPodNoSuchPod(t *testing.T) { } func TestHasPodWrongIDFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1613,8 +1609,8 @@ func TestHasPodWrongIDFalse(t *testing.T) { } func TestHasPodRightIDTrue(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1627,8 +1623,8 @@ func TestHasPodRightIDTrue(t *testing.T) { } func TestHasPodCtrIDFalse(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1641,8 +1637,8 @@ func TestHasPodCtrIDFalse(t *testing.T) { } func TestHasPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1659,8 +1655,8 @@ func TestHasPodSameNamespaceSucceeds(t *testing.T) { } func TestHasPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1677,15 +1673,15 @@ func TestHasPodDifferentNamespaceFails(t *testing.T) { } func TestAddPodInvalidPodErrors(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.AddPod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestAddPodValidPodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1700,11 +1696,11 @@ func TestAddPodValidPodSucceeds(t *testing.T) { } func TestAddPodDuplicateIDFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod(testPod1.ID(), "testpod2", manager) + testPod2, err := getTestPod(testPod1.ID(), "testpod2", lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1720,11 +1716,11 @@ func TestAddPodDuplicateIDFails(t *testing.T) { } func TestAddPodDuplicateNameFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod(strings.Repeat("2", 32), testPod1.Name(), manager) + testPod2, err := getTestPod(strings.Repeat("2", 32), testPod1.Name(), lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1740,11 +1736,11 @@ func TestAddPodDuplicateNameFails(t *testing.T) { } func TestAddPodNonDuplicateSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1760,11 +1756,11 @@ func TestAddPodNonDuplicateSucceeds(t *testing.T) { } func TestAddPodCtrIDConflictFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod(testCtr.ID(), "testpod1", manager) + testPod, err := getTestPod(testCtr.ID(), "testpod1", lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1780,11 +1776,11 @@ func TestAddPodCtrIDConflictFails(t *testing.T) { } func TestAddPodCtrNameConflictFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod(strings.Repeat("3", 32), testCtr.Name(), manager) + testPod, err := getTestPod(strings.Repeat("3", 32), testCtr.Name(), lockPath) assert.NoError(t, err) err = state.AddContainer(testCtr) @@ -1800,8 +1796,8 @@ func TestAddPodCtrNameConflictFails(t *testing.T) { } func TestAddPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1820,8 +1816,8 @@ func TestAddPodSameNamespaceSucceeds(t *testing.T) { } func TestAddPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1840,15 +1836,15 @@ func TestAddPodDifferentNamespaceFails(t *testing.T) { } func TestRemovePodInvalidPodErrors(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.RemovePod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestRemovePodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.RemovePod(testPod) @@ -1858,8 +1854,8 @@ func TestRemovePodNotInStateFails(t *testing.T) { } func TestRemovePodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1875,11 +1871,11 @@ func TestRemovePodSucceeds(t *testing.T) { } func TestRemovePodFromPods(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod1) @@ -1900,11 +1896,11 @@ func TestRemovePodFromPods(t *testing.T) { } func TestRemovePodNotEmptyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -1924,11 +1920,11 @@ func TestRemovePodNotEmptyFails(t *testing.T) { } func TestRemovePodAfterEmptySucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -1951,8 +1947,8 @@ func TestRemovePodAfterEmptySucceeds(t *testing.T) { } func TestRemovePodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -1974,7 +1970,7 @@ func TestRemovePodNotInNamespaceFails(t *testing.T) { } func TestAllPodsEmptyOnEmptyState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { allPods, err := state.AllPods() assert.NoError(t, err) assert.Equal(t, 0, len(allPods)) @@ -1982,8 +1978,8 @@ func TestAllPodsEmptyOnEmptyState(t *testing.T) { } func TestAllPodsFindsPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -1998,14 +1994,14 @@ func TestAllPodsFindsPod(t *testing.T) { } func TestAllPodsMultiplePods(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) - testPod3, err := getTestPodN("3", manager) + testPod3, err := getTestPodN("3", lockPath) assert.NoError(t, err) allPods1, err := state.AllPods() @@ -2036,8 +2032,8 @@ func TestAllPodsMultiplePods(t *testing.T) { } func TestAllPodsPodInDifferentNamespaces(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2054,13 +2050,13 @@ func TestAllPodsPodInDifferentNamespaces(t *testing.T) { } func TestAllPodsOnePodInDifferentNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod1, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod1, err := getTestPod1(lockPath) assert.NoError(t, err) testPod1.config.Namespace = "test1" - testPod2, err := getTestPod2(manager) + testPod2, err := getTestPod2(lockPath) assert.NoError(t, err) testPod2.config.Namespace = "test2" @@ -2082,15 +2078,15 @@ func TestAllPodsOnePodInDifferentNamespace(t *testing.T) { } func TestPodHasContainerNoSuchPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.PodHasContainer(&Pod{config: &PodConfig{}}, strings.Repeat("0", 32)) assert.Error(t, err) }) } func TestPodHasContainerEmptyCtrID(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2102,8 +2098,8 @@ func TestPodHasContainerEmptyCtrID(t *testing.T) { } func TestPodHasContainerNoSuchCtr(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2116,11 +2112,11 @@ func TestPodHasContainerNoSuchCtr(t *testing.T) { } func TestPodHasContainerCtrNotInPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2136,11 +2132,11 @@ func TestPodHasContainerCtrNotInPod(t *testing.T) { } func TestPodHasContainerSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2158,8 +2154,8 @@ func TestPodHasContainerSucceeds(t *testing.T) { } func TestPodHasContainerPodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2175,15 +2171,15 @@ func TestPodHasContainerPodNotInNamespaceFails(t *testing.T) { } func TestPodContainersByIDInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.PodContainersByID(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestPodContainerdByIDPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) _, err = state.PodContainersByID(testPod) @@ -2193,8 +2189,8 @@ func TestPodContainerdByIDPodNotInState(t *testing.T) { } func TestPodContainersByIDEmptyPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2207,11 +2203,11 @@ func TestPodContainersByIDEmptyPod(t *testing.T) { } func TestPodContainersByIDOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2230,19 +2226,19 @@ func TestPodContainersByIDOneContainer(t *testing.T) { } func TestPodContainersByIDMultipleContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() - testCtr3, err := getTestCtrN("4", manager) + testCtr3, err := getTestCtrN("4", lockPath) assert.NoError(t, err) testCtr3.config.Pod = testPod.ID() @@ -2277,8 +2273,8 @@ func TestPodContainersByIDMultipleContainers(t *testing.T) { } func TestPodContainerByIDPodNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2294,15 +2290,15 @@ func TestPodContainerByIDPodNotInNamespace(t *testing.T) { } func TestPodContainersInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { _, err := state.PodContainers(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestPodContainersPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) _, err = state.PodContainers(testPod) @@ -2312,8 +2308,8 @@ func TestPodContainersPodNotInState(t *testing.T) { } func TestPodContainersEmptyPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2326,11 +2322,11 @@ func TestPodContainersEmptyPod(t *testing.T) { } func TestPodContainersOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2350,19 +2346,19 @@ func TestPodContainersOneContainer(t *testing.T) { } func TestPodContainersMultipleContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() - testCtr3, err := getTestCtrN("4", manager) + testCtr3, err := getTestCtrN("4", lockPath) assert.NoError(t, err) testCtr3.config.Pod = testPod.ID() @@ -2397,8 +2393,8 @@ func TestPodContainersMultipleContainers(t *testing.T) { } func TestPodContainersPodNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2414,15 +2410,15 @@ func TestPodContainersPodNotInNamespace(t *testing.T) { } func TestRemovePodContainersInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.RemovePodContainers(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestRemovePodContainersPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.RemovePodContainers(testPod) @@ -2432,8 +2428,8 @@ func TestRemovePodContainersPodNotInState(t *testing.T) { } func TestRemovePodContainersNoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2449,11 +2445,11 @@ func TestRemovePodContainersNoContainers(t *testing.T) { } func TestRemovePodContainersOneContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2473,15 +2469,15 @@ func TestRemovePodContainersOneContainer(t *testing.T) { } func TestRemovePodContainersPreservesCtrOutsidePod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2507,15 +2503,15 @@ func TestRemovePodContainersPreservesCtrOutsidePod(t *testing.T) { } func TestRemovePodContainersTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2538,15 +2534,15 @@ func TestRemovePodContainersTwoContainers(t *testing.T) { } func TestRemovePodContainerDependencyInPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2570,8 +2566,8 @@ func TestRemovePodContainerDependencyInPod(t *testing.T) { } func TestRemoveContainersNotInNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -2587,8 +2583,8 @@ func TestRemoveContainersNotInNamespace(t *testing.T) { } func TestAddContainerToPodInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.AddContainerToPod(&Pod{config: &PodConfig{}}, testCtr) @@ -2597,8 +2593,8 @@ func TestAddContainerToPodInvalidPod(t *testing.T) { } func TestAddContainerToPodInvalidCtr(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2614,11 +2610,11 @@ func TestAddContainerToPodInvalidCtr(t *testing.T) { } func TestAddContainerToPodPodNotInState(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2629,11 +2625,11 @@ func TestAddContainerToPodPodNotInState(t *testing.T) { } func TestAddContainerToPodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2657,15 +2653,15 @@ func TestAddContainerToPodSucceeds(t *testing.T) { } func TestAddContainerToPodTwoContainers(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2689,15 +2685,15 @@ func TestAddContainerToPodTwoContainers(t *testing.T) { } func TestAddContainerToPodWithAddContainer(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -2722,14 +2718,14 @@ func TestAddContainerToPodWithAddContainer(t *testing.T) { } func TestAddContainerToPodCtrIDConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(testCtr1.ID(), "testCtr3", manager) + testCtr2, err := getTestContainer(testCtr1.ID(), "testCtr3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2753,14 +2749,14 @@ func TestAddContainerToPodCtrIDConflict(t *testing.T) { } func TestAddContainerToPodCtrNameConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr2, err := getTestContainer(strings.Repeat("4", 32), testCtr1.Name(), manager) + testCtr2, err := getTestContainer(strings.Repeat("4", 32), testCtr1.Name(), lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() @@ -2784,11 +2780,11 @@ func TestAddContainerToPodCtrNameConflict(t *testing.T) { } func TestAddContainerToPodPodIDConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(testPod.ID(), "testCtr", manager) + testCtr, err := getTestContainer(testPod.ID(), "testCtr", lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2809,11 +2805,11 @@ func TestAddContainerToPodPodIDConflict(t *testing.T) { } func TestAddContainerToPodPodNameConflict(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), manager) + testCtr, err := getTestContainer(strings.Repeat("2", 32), testPod.Name(), lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -2834,15 +2830,15 @@ func TestAddContainerToPodPodNameConflict(t *testing.T) { } func TestAddContainerToPodAddsDependencies(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2864,11 +2860,11 @@ func TestAddContainerToPodAddsDependencies(t *testing.T) { } func TestAddContainerToPodPodDependencyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() testCtr.config.IPCNsCtr = testPod.ID() @@ -2886,11 +2882,11 @@ func TestAddContainerToPodPodDependencyFails(t *testing.T) { } func TestAddContainerToPodBadDependencyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() testCtr.config.IPCNsCtr = strings.Repeat("8", 32) @@ -2908,14 +2904,14 @@ func TestAddContainerToPodBadDependencyFails(t *testing.T) { } func TestAddContainerToPodDependencyOutsidePodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2944,17 +2940,17 @@ func TestAddContainerToPodDependencyOutsidePodFails(t *testing.T) { } func TestAddContainerToPodDependencyInSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() testCtr1.config.Namespace = "test1" - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -2977,17 +2973,17 @@ func TestAddContainerToPodDependencyInSameNamespaceSucceeds(t *testing.T) { } func TestAddContainerToPodDependencyInSeparateNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() testCtr1.config.Namespace = "test1" - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -3017,12 +3013,12 @@ func TestAddContainerToPodDependencyInSeparateNamespaceFails(t *testing.T) { } func TestAddContainerToPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" testCtr.config.Pod = testPod.ID() @@ -3041,12 +3037,12 @@ func TestAddContainerToPodSameNamespaceSucceeds(t *testing.T) { } func TestAddContainerToPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test2" testCtr.config.Pod = testPod.ID() @@ -3064,11 +3060,11 @@ func TestAddContainerToPodDifferentNamespaceFails(t *testing.T) { } func TestAddContainerToPodNamespaceOnCtrFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" testCtr.config.Pod = testPod.ID() @@ -3086,12 +3082,12 @@ func TestAddContainerToPodNamespaceOnCtrFails(t *testing.T) { } func TestAddContainerToPodNamespaceOnPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3108,11 +3104,11 @@ func TestAddContainerToPodNamespaceOnPodFails(t *testing.T) { } func TestAddCtrToPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod2(manager) + testPod, err := getTestPod2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -3135,11 +3131,11 @@ func TestAddCtrToPodSameNamespaceSucceeds(t *testing.T) { } func TestAddCtrToPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) - testPod, err := getTestPod2(manager) + testPod, err := getTestPod2(lockPath) assert.NoError(t, err) testCtr.config.Namespace = "test1" @@ -3163,8 +3159,8 @@ func TestAddCtrToPodDifferentNamespaceFails(t *testing.T) { } func TestRemoveContainerFromPodBadPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testCtr, err := getTestCtr1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testCtr, err := getTestCtr1(lockPath) assert.NoError(t, err) err = state.RemoveContainerFromPod(&Pod{config: &PodConfig{}}, testCtr) @@ -3173,11 +3169,11 @@ func TestRemoveContainerFromPodBadPodFails(t *testing.T) { } func TestRemoveContainerFromPodPodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3189,11 +3185,11 @@ func TestRemoveContainerFromPodPodNotInStateFails(t *testing.T) { } func TestRemoveContainerFromPodCtrNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3208,11 +3204,11 @@ func TestRemoveContainerFromPodCtrNotInStateFails(t *testing.T) { } func TestRemoveContainerFromPodCtrNotInPodFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -3233,11 +3229,11 @@ func TestRemoveContainerFromPodCtrNotInPodFails(t *testing.T) { } func TestRemoveContainerFromPodSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3261,15 +3257,15 @@ func TestRemoveContainerFromPodSucceeds(t *testing.T) { } func TestRemoveContainerFromPodWithDependencyFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -3297,15 +3293,15 @@ func TestRemoveContainerFromPodWithDependencyFails(t *testing.T) { } func TestRemoveContainerFromPodWithDependencySucceedsAfterDepRemoved(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) - testCtr1, err := getTestCtr2(manager) + testCtr1, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr1.config.Pod = testPod.ID() - testCtr2, err := getTestCtrN("3", manager) + testCtr2, err := getTestCtrN("3", lockPath) assert.NoError(t, err) testCtr2.config.Pod = testPod.ID() testCtr2.config.IPCNsCtr = testCtr1.ID() @@ -3336,13 +3332,13 @@ func TestRemoveContainerFromPodWithDependencySucceedsAfterDepRemoved(t *testing. } func TestRemoveContainerFromPodSameNamespaceSucceeds(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3370,13 +3366,13 @@ func TestRemoveContainerFromPodSameNamespaceSucceeds(t *testing.T) { } func TestRemoveContainerFromPodDifferentNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" - testCtr, err := getTestCtr2(manager) + testCtr, err := getTestCtr2(lockPath) assert.NoError(t, err) testCtr.config.Pod = testPod.ID() @@ -3406,15 +3402,15 @@ func TestRemoveContainerFromPodDifferentNamespaceFails(t *testing.T) { } func TestUpdatePodInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.UpdatePod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestUpdatePodPodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.UpdatePod(testPod) @@ -3423,8 +3419,8 @@ func TestUpdatePodPodNotInStateFails(t *testing.T) { } func TestUpdatePodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -3440,15 +3436,15 @@ func TestUpdatePodNotInNamespaceFails(t *testing.T) { } func TestSavePodInvalidPod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { + runForAllStates(t, func(t *testing.T, state State, lockPath string) { err := state.SavePod(&Pod{config: &PodConfig{}}) assert.Error(t, err) }) } func TestSavePodPodNotInStateFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.SavePod(testPod) @@ -3457,8 +3453,8 @@ func TestSavePodPodNotInStateFails(t *testing.T) { } func TestSavePodNotInNamespaceFails(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" @@ -3474,8 +3470,8 @@ func TestSavePodNotInNamespaceFails(t *testing.T) { } func TestSaveAndUpdatePod(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) err = state.AddPod(testPod) @@ -3499,8 +3495,8 @@ func TestSaveAndUpdatePod(t *testing.T) { } func TestSaveAndUpdatePodSameNamespace(t *testing.T) { - runForAllStates(t, func(t *testing.T, state State, manager lock.Manager) { - testPod, err := getTestPod1(manager) + runForAllStates(t, func(t *testing.T, state State, lockPath string) { + testPod, err := getTestPod1(lockPath) assert.NoError(t, err) testPod.config.Namespace = "test1" |