Docker: Allow to start shell with variable
Make it possible to enter a shell in the integration test docker image before it would exit with: debug_exit_shell=1 ./automation/run-integration-tests.sh` This makes it easier to debug/develop integration tests. Signed-off-by: Till Maas <opensource@till.name>
This commit is contained in:
parent
0499443ce5
commit
902377210e
@ -35,8 +35,17 @@ just run:
|
||||
## Development
|
||||
|
||||
### Run the tests manually in the container
|
||||
For debugging, it is convenient to run the container and then
|
||||
connect to it in order to run the tests.
|
||||
For debugging, it is convenient to run the container and then connect to it in
|
||||
order to run the tests. Setting the environment variable `debug_exit_shell`
|
||||
will make the script start a shell instead of exiting the script after an error
|
||||
or running the scripts:
|
||||
|
||||
`debug_exit_shell=1 ./automation/run-integration-tests.sh`
|
||||
|
||||
|
||||
After closing the shell, the container will be removed. Alternatively, the
|
||||
following commands start the container manually:
|
||||
|
||||
```
|
||||
DOCKER_IMAGE="nmstate/centos7-nmstate-dev"
|
||||
NET0="nmstate-net0"
|
||||
|
@ -85,13 +85,22 @@ function run_exit {
|
||||
remove_container
|
||||
}
|
||||
|
||||
function open_shell {
|
||||
res=$?
|
||||
[ "$res" -ne 0 ] && echo "*** ERROR: $res"
|
||||
set +o errexit
|
||||
docker_exec 'echo "pytest tests/integration --pdb" >> ~/.bash_history'
|
||||
docker_exec 'cd /workspace/nmstate; exec /bin/bash'
|
||||
run_exit
|
||||
}
|
||||
|
||||
cd $EXEC_PATH
|
||||
docker --version && cat /etc/resolv.conf && ping -c 1 github.com
|
||||
|
||||
mkdir -p $EXPORT_DIR
|
||||
|
||||
CONTAINER_ID="$(docker run --privileged -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v $PROJECT_PATH:/workspace/nmstate -v $EXPORT_DIR:$CONT_EXPORT_DIR $DOCKER_IMAGE)"
|
||||
trap run_exit EXIT
|
||||
[ -n "$debug_exit_shell" ] && trap open_shell EXIT || trap run_exit EXIT
|
||||
docker_exec 'while ! systemctl is-active dbus; do sleep 1; done'
|
||||
pyclean
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user