forked from vmware/vic
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port layer now uses the vSphere API to send the "kill" command to the container VM guest toolbox. Closes vmware#1267
- Loading branch information
Showing
7 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
tests/test-cases/Group1-Docker-Commands/1-14-Docker-Kill.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
*** Settings *** | ||
Documentation Test 1-14 - Docker Kill | ||
Resource ../../resources/Util.robot | ||
Suite Setup Install VIC Appliance To Test Server | ||
Suite Teardown Cleanup VIC Appliance On Test Server | ||
|
||
*** Keywords *** | ||
Trap Signal Command | ||
# Container command runs an infinite loop, trapping and logging the given signal name | ||
[Arguments] ${sig} | ||
[Return] busybox sh -c "trap 'echo KillSignal${sig}' ${sig}; while true; do date && sleep 1; done" | ||
|
||
Assert Kill Signal | ||
# Assert the docker kill signal was trapped by checking the container output log file | ||
[Arguments] ${id} ${sig} | ||
${rc}= Run And Return Rc govc datastore.download ${id}/${id}.log ${TEMPDIR}/${id}.log | ||
Should Be Equal As Integers ${rc} 0 | ||
${output}= OperatingSystem.Get File ${TEMPDIR}/${id}.log | ||
Remove File ${TEMPDIR}/${id}.log | ||
Should Contain ${output} KillSignal${sig} | ||
|
||
Inspect State Running | ||
[Arguments] ${id} ${expected} | ||
${rc} ${state}= Run And Return Rc And Output docker ${params} inspect --format="{{ .State.Running }}" ${id} | ||
Should Be Equal As Integers ${rc} 0 | ||
Should Be Equal ${state} ${expected} | ||
|
||
*** Test Cases *** | ||
Signal a container with default kill signal | ||
${rc}= Run And Return Rc docker ${params} pull busybox | ||
Should Be Equal As Integers ${rc} 0 | ||
${rc} ${id}= Run And Return Rc And Output docker ${params} create busybox sleep 300 | ||
Should Be Equal As Integers ${rc} 0 | ||
${rc}= Run And Return Rc docker ${params} start ${id} | ||
Should Be Equal As Integers ${rc} 0 | ||
Inspect State Running ${id} true | ||
${rc}= Run And Return Rc docker ${params} kill ${id} | ||
Should Be Equal As Integers ${rc} 0 | ||
# Wait for container VM to stop/powerOff | ||
Wait Until Keyword Succeeds 5x 200 milliseconds Inspect State Running ${id} false | ||
# Cannot send signal to a powered off container VM | ||
${rc} ${output}= Run And Return Rc And Output docker ${params} kill ${id} | ||
Should Be Equal As Integers ${rc} 1 | ||
Should Contain ${output} Cannot kill container ${id} | ||
|
||
Signal a container with SIGHUP | ||
${rc}= Run And Return Rc docker ${params} pull busybox | ||
Should Be Equal As Integers ${rc} 0 | ||
${trap}= Trap Signal Command HUP | ||
${rc} ${id}= Run And Return Rc And Output docker ${params} run -d ${trap} | ||
Should Be Equal As Integers ${rc} 0 | ||
# Expect failure with unknown signal name | ||
${rc}= Run And Return Rc docker ${params} kill -s NOPE ${id} | ||
Should Be Equal As Integers ${rc} 1 | ||
${rc}= Run And Return Rc docker ${params} kill -s HUP ${id} | ||
Should Be Equal As Integers ${rc} 0 | ||
Wait Until Keyword Succeeds 5x 1 seconds Assert Kill Signal ${id} HUP | ||
Inspect State Running ${id} true | ||
${rc}= Run And Return Rc docker ${params} kill -s TERM ${id} | ||
Should Be Equal As Integers ${rc} 0 | ||
Wait Until Keyword Succeeds 5x 200 milliseconds Inspect State Running ${id} false | ||
|
||
Signal a non-existent container | ||
${rc} ${output}= Run And Return Rc And Output docker ${params} kill fakeContainer | ||
Should Be Equal As Integers ${rc} 1 | ||
Should Contain ${output} No such container: fakeContainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters