diff --git a/automation/README.md b/automation/README.md index 9e98399f..f7b59b4d 100644 --- a/automation/README.md +++ b/automation/README.md @@ -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" diff --git a/automation/run-integration-tests.sh b/automation/run-integration-tests.sh index 5c79c790..7be7b15a 100755 --- a/automation/run-integration-tests.sh +++ b/automation/run-integration-tests.sh @@ -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