Created
September 4, 2014 06:01
-
-
Save cameron/5a7e7ddd5b1ca2a6084c to your computer and use it in GitHub Desktop.
using expect to automate shells and tests in docker containers
This file contains hidden or 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
#! /usr/bin/expect -f | |
# ssh into the vagrant coreos machine | |
spawn ssh coreos | |
# find a prompt inside the vagrant vm | |
expect "*core@core*" | |
# get a shell inside the docker container | |
send "sudo nsenter --target \$(docker inspect --format '{{.State.Pid}}' \$(docker ps | grep dex_server:latest | awk '{print \$1}')) --mount --uts --ipc --net --pid\r" | |
# find a prompt inside the docker container" | |
expect "*root*" | |
interact |
This file contains hidden or 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
#! /usr/bin/expect | |
cd [ file dirname $argv0] | |
# get a shell in the server container | |
spawn ./shell | |
# find a prompt inside the docker container | |
expect "*root*" | |
# run the tests | |
send "python /srv/app/legalease/tests/document.py\r" | |
# find that the tests have finished | |
expect "*root*" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment