laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/docker-playground/+/27284 )

Change subject: ttcn3-fr-test/jenkins.sh: make use of clean_up()
......................................................................

ttcn3-fr-test/jenkins.sh: make use of clean_up()

Move cleaning up logic to clean_up(), so it runs as part of the
clean_up_trap if any command in the previous code fails.

For example, if the first docker container started properly, but the
second docker container failed to start: without this patch, it would
just stop the script without running the clean up code.

Change-Id: I4624e37d5d2fa90b71b32d72067b3645f69805da
---
M ttcn3-fr-test/jenkins.sh
1 file changed, 12 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/ttcn3-fr-test/jenkins.sh b/ttcn3-fr-test/jenkins.sh
index 4531e3a..182f512 100755
--- a/ttcn3-fr-test/jenkins.sh
+++ b/ttcn3-fr-test/jenkins.sh
@@ -8,6 +8,16 @@
 set_clean_up_trap
 set -e

+clean_up() {
+       # kill the frnet container to avoid "You cannot remove a running 
container " below in 'rm'
+       docker kill ${BUILD_TAG}-frnet || true
+
+       # store execution logs for both containers
+       docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test > 
$VOL_BASE_DIR/fr-tester/exec.log || true
+       docker logs --timestamps ${BUILD_TAG}-frnet > 
$VOL_BASE_DIR/frnet/exec.log || true
+       docker container rm ${BUILD_TAG}-frnet ${BUILD_TAG}-ttcn3-fr-test
+}
+
 SUBNET=26
 network_create $SUBNET

@@ -25,7 +35,7 @@

 echo Starting container with FRNET
 docker run     \
-               `# --rm is done in below` \
+               `# --rm is done in clean_up()` \
                --cap-add=NET_RAW --cap-add=SYS_RAWIO \
                $(docker_network_params $SUBNET 10) \
                --ulimit core=-1 \
@@ -45,7 +55,7 @@

 echo Starting container with FR testsuite
 docker run     \
-               `# --rm is done in below` \
+               `# --rm is done in clean_up()` \
                --cap-add=NET_RAW --cap-add=SYS_RAWIO \
                $(docker_network_params $SUBNET 103) \
                --ulimit core=-1 \
@@ -66,10 +76,3 @@
 # emulate running container in foreground, which is no longer possible as we
 # must shift the net-devices into the container _after_ it is started
 docker logs    -f ${BUILD_TAG}-ttcn3-fr-test
-# kill the frnet container to avoid "You cannot remove a running container " 
below in 'rm'
-docker kill ${BUILD_TAG}-frnet
-
-# store execution logs for both containers
-docker logs --timestamps ${BUILD_TAG}-ttcn3-fr-test > 
$VOL_BASE_DIR/fr-tester/exec.log
-docker logs --timestamps ${BUILD_TAG}-frnet > $VOL_BASE_DIR/frnet/exec.log
-docker container rm ${BUILD_TAG}-frnet ${BUILD_TAG}-ttcn3-fr-test

--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/27284
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I4624e37d5d2fa90b71b32d72067b3645f69805da
Gerrit-Change-Number: 27284
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to