API: add sandbox waitprocess api

It waits a process inside the container of a sandbox.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao
2018-04-25 15:57:45 +08:00
parent 992c895eaa
commit 45970ba796
11 changed files with 116 additions and 1 deletions

View File

@@ -1408,3 +1408,33 @@ func TestMonitor(t *testing.T) {
s.monitor.stop()
}
func TestWaitProcess(t *testing.T) {
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NoopNetworkModel, NetworkConfig{}, nil, nil)
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
defer cleanUp()
contID := "foo"
execID := "bar"
_, err = s.WaitProcess(contID, execID)
assert.NotNil(t, err, "Wait process in stopped sandbox should fail")
err = s.start()
assert.Nil(t, err, "Failed to start sandbox: %v", err)
_, err = s.WaitProcess(contID, execID)
assert.NotNil(t, err, "Wait process in non-existing container should fail")
contConfig := newTestContainerConfigNoop(contID)
_, err = s.CreateContainer(contConfig)
assert.Nil(t, err, "Failed to create container %+v in sandbox %+v: %v", contConfig, s, err)
_, err = s.WaitProcess(contID, execID)
assert.Nil(t, err, "Wait process in ready container failed: %v", err)
_, err = s.StartContainer(contID)
assert.Nil(t, err, "Start container failed: %v", err)
_, err = s.WaitProcess(contID, execID)
assert.Nil(t, err, "Wait process failed: %v", err)
}