Kill container directly if timeout is 0.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
@@ -109,6 +109,7 @@ func TestStopContainer(t *testing.T) {
|
||||
killErr error
|
||||
deleteErr error
|
||||
discardEvents int
|
||||
noTimeout bool
|
||||
expectErr bool
|
||||
expectCalls []string
|
||||
}{
|
||||
@@ -155,6 +156,12 @@ func TestStopContainer(t *testing.T) {
|
||||
expectErr: true,
|
||||
expectCalls: []string{"kill"},
|
||||
},
|
||||
"should directly kill container if timeout is 0": {
|
||||
metadata: &testMetadata,
|
||||
containerdContainer: &testContainer,
|
||||
noTimeout: true,
|
||||
expectCalls: []string{"delete", "delete"},
|
||||
},
|
||||
"should return error if delete failed": {
|
||||
metadata: &testMetadata,
|
||||
containerdContainer: &testContainer,
|
||||
@@ -201,11 +208,15 @@ func TestStopContainer(t *testing.T) {
|
||||
}
|
||||
}(eventClient, test.discardEvents)
|
||||
fake.ClearCalls()
|
||||
timeout := int64(1)
|
||||
if test.noTimeout {
|
||||
timeout = 0
|
||||
}
|
||||
// 1 second timeout should be enough for the unit test.
|
||||
// TODO(random-liu): Use fake clock for this test.
|
||||
resp, err := c.StopContainer(context.Background(), &runtime.StopContainerRequest{
|
||||
ContainerId: testID,
|
||||
Timeout: 1,
|
||||
Timeout: timeout,
|
||||
})
|
||||
if test.expectErr {
|
||||
assert.Error(t, err)
|
||||
|
Reference in New Issue
Block a user