mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-24 01:24:26 +01:00
exec: Allow to exec a process on a ready container
If a container is not running, but created/ready instead, this means a container process exists and that we can actually exec another process inside this container. The container does not have to be in running state. Fixes #120 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -89,7 +89,7 @@ func TestExecuteErrors(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.False(vcmock.IsMockError(err))
|
||||
|
||||
// Container not running
|
||||
// Container state undefined
|
||||
configPath := testConfigSetup(t)
|
||||
configJSON, err := readOCIConfigJSON(configPath)
|
||||
assert.NoError(err)
|
||||
@@ -99,13 +99,34 @@ func TestExecuteErrors(t *testing.T) {
|
||||
vcAnnotations.ConfigJSONKey: configJSON,
|
||||
}
|
||||
|
||||
containerState := vc.State{}
|
||||
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
||||
return newSingleContainerPodStatusList(testPodID, testContainerID, vc.State{}, vc.State{}, annotations), nil
|
||||
return newSingleContainerPodStatusList(testPodID, testContainerID, vc.State{}, containerState, annotations), nil
|
||||
}
|
||||
|
||||
defer func() {
|
||||
testingImpl.ListPodFunc = nil
|
||||
}()
|
||||
err = execute(ctx)
|
||||
assert.Error(err)
|
||||
assert.False(vcmock.IsMockError(err))
|
||||
|
||||
// Container paused
|
||||
containerState = vc.State{
|
||||
State: vc.StatePaused,
|
||||
}
|
||||
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
||||
return newSingleContainerPodStatusList(testPodID, testContainerID, vc.State{}, containerState, annotations), nil
|
||||
}
|
||||
|
||||
err = execute(ctx)
|
||||
assert.Error(err)
|
||||
assert.False(vcmock.IsMockError(err))
|
||||
|
||||
// Container stopped
|
||||
containerState = vc.State{
|
||||
State: vc.StateStopped,
|
||||
}
|
||||
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
||||
return newSingleContainerPodStatusList(testPodID, testContainerID, vc.State{}, containerState, annotations), nil
|
||||
}
|
||||
|
||||
err = execute(ctx)
|
||||
assert.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user