-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from vnsamsonov/main
Add cleanup for tests and remove deprecating `--record` option for kubectl
- Loading branch information
Showing
3 changed files
with
59 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,61 @@ | ||
#!/bin/sh | ||
|
||
docker stop deployer_runner | ||
docker rm deployer_runner | ||
need_cleanup=false | ||
|
||
docker build --progress=plain -t deployer -f tests/containers/Dockerfile . | ||
chmod +x tests/containers/integration_tests/integration_entrypoint.sh | ||
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway --entrypoint=tests/containers/integration_tests/integration_entrypoint.sh --name=deployer_runner deployer:latest | ||
cleanup() { | ||
if [ "$need_cleanup" = false ]; then | ||
return | ||
fi | ||
|
||
container_output_fmt="{{.ID}} ({{.Image}})" | ||
|
||
docker ps --format "$container_output_fmt" | while IFS= read -r container_info; do | ||
container_id=$(echo "$container_info" | cut -d ' ' -f 1) | ||
docker stop "$container_id" > /dev/null \ | ||
&& echo "Stopping container $container_info" | ||
done | ||
|
||
docker ps -a --format "$container_output_fmt" | while IFS= read -r container_info; do | ||
container_id=$(echo "$container_info" | cut -d ' ' -f 1) | ||
docker rm "$container_id" > /dev/null \ | ||
&& echo "Removing container $container_info" | ||
done | ||
} | ||
|
||
startup() { | ||
while [ "$#" -gt 0 ] | ||
do | ||
case "$1" in | ||
--rm) | ||
need_cleanup=true | ||
shift | ||
;; | ||
--help|*) | ||
echo "Run integration tests locally. Usage:" | ||
echo " --rm" | ||
echo " Automatically stop and remove all containers when tests done" | ||
echo " --help" | ||
echo " Print usage" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Stop and remove running containers for escape conflicts | ||
cleanup | ||
} | ||
|
||
run() { | ||
docker build --progress=plain -t deployer -f tests/containers/Dockerfile . | ||
chmod +x tests/containers/integration_tests/integration_entrypoint.sh | ||
docker run --rm \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
--add-host=host.docker.internal:host-gateway \ | ||
--entrypoint=tests/containers/integration_tests/integration_entrypoint.sh \ | ||
--name=deployer_runner deployer:latest | ||
} | ||
|
||
|
||
startup "$@" | ||
run | ||
cleanup |