summaryrefslogtreecommitdiff
path: root/libpod/state_test.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-10 15:11:32 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-12 14:28:07 +0000
commitdc6a99df4c5ea7facaca20129b2b6c5b53ddb3c1 (patch)
tree0f1915a7e7e296652b0c4aaabc765b5786cfa9ab /libpod/state_test.go
parent3962d10bd482d1c57707465e8f76e76b4abc9a9f (diff)
downloadpodman-dc6a99df4c5ea7facaca20129b2b6c5b53ddb3c1.tar.gz
podman-dc6a99df4c5ea7facaca20129b2b6c5b53ddb3c1.tar.bz2
podman-dc6a99df4c5ea7facaca20129b2b6c5b53ddb3c1.zip
Containers in a pod can only join namespaces in that pod
This solves some dependency problems in the state, and makes sense from a design standpoint. Containers not in a pod can still depend on the namespaces of containers joined to a pod, which we might also want to change in the future. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #184 Approved by: baude
Diffstat (limited to 'libpod/state_test.go')
-rw-r--r--libpod/state_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/libpod/state_test.go b/libpod/state_test.go
index 718da8392..53930f2d0 100644
--- a/libpod/state_test.go
+++ b/libpod/state_test.go
@@ -2174,6 +2174,42 @@ func TestAddContainerToPodBadDependencyFails(t *testing.T) {
})
}
+func TestAddContainerToPodDependencyOutsidePodFails(t *testing.T) {
+ runForAllStates(t, func(t *testing.T, state State, lockPath string) {
+ testPod, err := getTestPod1(lockPath)
+ assert.NoError(t, err)
+
+ testCtr1, err := getTestCtr2(lockPath)
+ assert.NoError(t, err)
+
+ testCtr2, err := getTestCtrN("3", lockPath)
+ assert.NoError(t, err)
+ testCtr2.config.Pod = testPod.ID()
+ testCtr2.config.IPCNsCtr = testCtr1.ID()
+
+ err = state.AddPod(testPod)
+ assert.NoError(t, err)
+
+ err = state.AddContainer(testCtr1)
+ assert.NoError(t, err)
+
+ err = state.AddContainerToPod(testPod, testCtr2)
+ assert.Error(t, err)
+
+ ctrs, err := state.PodContainers(testPod)
+ assert.NoError(t, err)
+ assert.Equal(t, 0, len(ctrs))
+
+ allCtrs, err := state.AllContainers()
+ assert.NoError(t, err)
+ assert.Equal(t, 1, len(allCtrs))
+
+ deps, err := state.ContainerInUse(testCtr1)
+ assert.NoError(t, err)
+ assert.Equal(t, 0, len(deps))
+ })
+}
+
func TestRemoveContainerFromPodBadPodFails(t *testing.T) {
runForAllStates(t, func(t *testing.T, state State, lockPath string) {
testCtr, err := getTestCtr1(lockPath)