Merge branch '11917-dont-clear-cache'
[arvados.git] / sdk / cwl / test_with_arvbox.sh
index aef27001e00e1a2b330296a3eafa8decea22f518..236658c1f1e7c0a18b7675078374f33b5e9e7db5 100755 (executable)
@@ -1,4 +1,9 @@
 #!/bin/sh
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+set -x
 
 if ! which arvbox >/dev/null ; then
     export PATH=$PATH:$(readlink -f $(dirname $0)/../../tools/arvbox/bin)
@@ -7,6 +12,7 @@ fi
 reset_container=1
 leave_running=0
 config=dev
+tag="latest"
 
 while test -n "$1" ; do
     arg="$1"
@@ -23,7 +29,15 @@ while test -n "$1" ; do
             config=$2
             shift ; shift
             ;;
-        -*)
+        --tag)
+            tag=$2
+            shift ; shift
+            ;;
+        -h|--help)
+            echo "$0 [--no-reset-container] [--leave-running] [--config dev|localdemo] [--tag docker_tag]"
+            exit
+            ;;
+        *)
             break
             ;;
     esac
@@ -34,19 +48,25 @@ if test -z "$ARVBOX_CONTAINER" ; then
 fi
 
 if test $reset_container = 1 ; then
+    arvbox stop
+    docker rm $ARVBOX_CONTAINER
     arvbox reset -f
 fi
 
-arvbox start $config
+arvbox start $config $tag
 
 arvbox pipe <<EOF
 set -eu -o pipefail
 
 . /usr/local/lib/arvbox/common.sh
 
-cd /usr/src/arvados/sdk/cwl
-python setup.py sdist
-pip_install \$(ls dist/arvados-cwl-runner-*.tar.gz | tail -n1)
+if test $config = dev ; then
+  cd /usr/src/arvados/sdk/cwl
+  python setup.py sdist
+  pip_install \$(ls -r dist/arvados-cwl-runner-*.tar.gz | head -n1)
+fi
+
+pip install cwltest
 
 mkdir -p /tmp/cwltest
 cd /tmp/cwltest
@@ -58,8 +78,31 @@ git pull
 export ARVADOS_API_HOST=localhost:8000
 export ARVADOS_API_HOST_INSECURE=1
 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados/superuser_token)
+
+
+if test "$tag" = "latest" ; then
+  arv-keepdocker --pull arvados/jobs $tag
+else
+  jobsimg=\$(curl http://versions.arvados.org/v1/commit/$tag | python -c "import json; import sys; sys.stdout.write(json.load(sys.stdin)['Versions']['Docker']['arvados/jobs'])")
+  arv-keepdocker --pull arvados/jobs $jobsimg
+  docker tag -f arvados/jobs:$jobsimg arvados/jobs:latest
+  arv-keepdocker arvados/jobs latest
+fi
+
+cat >/tmp/cwltest/arv-cwl-jobs <<EOF2
+#!/bin/sh
+exec arvados-cwl-runner --api=jobs \\\$@
+EOF2
+chmod +x /tmp/cwltest/arv-cwl-jobs
+
+cat >/tmp/cwltest/arv-cwl-containers <<EOF2
+#!/bin/sh
+exec arvados-cwl-runner --api=containers \\\$@
+EOF2
+chmod +x /tmp/cwltest/arv-cwl-containers
+
 env
-exec ./run_test.sh "$@"
+exec ./run_test.sh EXTRA=--compute-checksum $@
 EOF
 
 CODE=$?