]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/docker-test: Allow persistent containers 37404/head
authorBrad Hubbard <bhubbard@redhat.com>
Fri, 25 Sep 2020 02:26:34 +0000 (12:26 +1000)
committerBrad Hubbard <bhubbard@redhat.com>
Fri, 23 Oct 2020 06:07:07 +0000 (16:07 +1000)
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 <bhubbard@redhat.com>
src/test/docker-test-helper.sh

index 8459962758990accebb361f5d24543c5d4382d4d..ce7beb19f5ec96ce9df15eedbbd9318ab932ea3d 100755 (executable)
@@ -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