From: Brad Hubbard Date: Fri, 25 Sep 2020 02:26:34 +0000 (+1000) Subject: test/docker-test: Allow persistent containers X-Git-Tag: v16.1.0~779^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76eb858e4083a1cb8b1a72abea1a4440d59935bb;p=ceph.git test/docker-test: Allow persistent containers It can be useful to allow the container to persist for debugging purposes. Also show the command used to create the container. Signed-off-by: Brad Hubbard --- diff --git a/src/test/docker-test-helper.sh b/src/test/docker-test-helper.sh index 8459962758990..ce7beb19f5ec9 100755 --- a/src/test/docker-test-helper.sh +++ b/src/test/docker-test-helper.sh @@ -27,6 +27,9 @@ function setup_container() { local dockercmd=$3 local opts="$4" + # rm not valid here + opts=${opts//' --rm'}; + local image=$(get_image_name $os_type $os_version) local build=true if $dockercmd images $image | grep --quiet "^$image " ; then @@ -123,7 +126,7 @@ function run_in_docker() { mkdir -p $HOME/.ccache ccache="--volume $HOME/.ccache:$HOME/.ccache" user="--user $USER" - local cmd="$dockercmd run $opts --rm --name $image --privileged $ccache" + local cmd="$dockercmd run $opts --name $image --privileged $ccache" cmd+=" --volume $downstream:$downstream" cmd+=" --volume $upstream:$upstream" if test "$dockercmd" = "podman" ; then @@ -131,8 +134,10 @@ function run_in_docker() { fi local status=0 if test "$script" = "SHELL" ; then + echo Running: $cmd --tty --interactive --workdir $downstream $user $image bash $cmd --tty --interactive --workdir $downstream $user $image bash else + echo Running: $cmd --workdir $downstream $user $image "$@" if ! $cmd --workdir $downstream $user $image "$@" ; then status=1 fi @@ -169,8 +174,9 @@ $0 [options] command args ... [--shell] run an interactive shell in the container [--remove-all] remove the container and the image for the specified types+versions + [--no-rm] don't remove the container when finished - [--opts options] run the contain with 'options' + [--opts options] run the container with 'options' docker-test.sh must be run from a Ceph clone and it will run the command in a container, using a copy of the clone so that long running @@ -256,7 +262,7 @@ function main_docker() { fi local temp - temp=$(getopt -o scht:v:o:a:r: --long remove-all,verbose,shell,help,os-type:,os-version:,opts:,all:,ref: -n $0 -- "$@") || return 1 + temp=$(getopt -o scht:v:o:a:r: --long remove-all,verbose,shell,no-rm,help,os-type:,os-version:,opts:,all:,ref: -n $0 -- "$@") || return 1 eval set -- "$temp" @@ -267,6 +273,7 @@ function main_docker() { local shell=false local opts local ref=$(git rev-parse HEAD) + local no-rm=false while true ; do case "$1" in @@ -307,6 +314,10 @@ function main_docker() { ref="$2" shift 2 ;; + --no-rm) + no-rm=true + shift + ;; --) shift break @@ -325,6 +336,10 @@ function main_docker() { declare -A os_type2versions eval os_type2versions="$all" + if ! $no-rm ; then + opts+=" --rm" + fi + for os_type in ${!os_type2versions[@]} ; do for os_version in ${os_type2versions[$os_type]} ; do if $remove ; then