docker: make sure to cleanup containers before force exit Observed containers were being left over on the host machine when docker tests were terminated mid way. Due to this, host machine was not able to run anymore containers after a certain threshold of running containers and eventually runs out of available memory. Fix this issue by always cleaning the containers when exiting from the tests. Change-Id: I14056ba1e883a40fbd4251d1565da1ee5b102770
diff --git a/test/docker/run.sh b/test/docker/run.sh index ef6f771..5b1894d 100755 --- a/test/docker/run.sh +++ b/test/docker/run.sh
@@ -85,8 +85,7 @@ usage "$MISSING, did you forget --events-plugin-jar?" fi [ -n "$GERRIT_WAR" ] && cp -f -- "$GERRIT_WAR" "$ARTIFACTS/gerrit.war" -progress "Building docker images" build_images -run_events_plugin_tests ; RESULT=$? -cleanup - -exit "$RESULT" +( trap cleanup EXIT SIGTERM + progress "Building docker images" build_images + run_events_plugin_tests +)