5737: Merge branch 'master' into 5737-ruby231
[arvados.git] / sdk / cwl / test_with_arvbox.sh
index 83ba66b2e8d6aebd565fcf28cb874e0f5ea6ac2e..ee8daa1e15cbfc1147a00839b8d7da9f69c7d1fe 100755 (executable)
@@ -1,20 +1,38 @@
 #!/bin/sh
 
+set -x
+
 if ! which arvbox >/dev/null ; then
     export PATH=$PATH:$(readlink -f $(dirname $0)/../../tools/arvbox/bin)
 fi
 
 reset_container=1
 leave_running=0
+config=dev
+tag=""
 
 while test -n "$1" ; do
-    arg="$1"; shift
+    arg="$1"
     case "$arg" in
         --no-reset-container)
             reset_container=0
+            shift
             ;;
         --leave-running)
             leave_running=1
+            shift
+            ;;
+        --config)
+            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
@@ -28,17 +46,20 @@ fi
 
 if test $reset_container = 1 ; then
     arvbox reset -f
-    arvbox build dev
 fi
 
-arvbox start dev
+arvbox start $config $tag
 
 arvbox pipe <<EOF
-set -e
+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
 
 mkdir -p /tmp/cwltest
 cd /tmp/cwltest
@@ -50,8 +71,21 @@ git pull
 export ARVADOS_API_HOST=localhost:8000
 export ARVADOS_API_HOST_INSECURE=1
 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados/superuser_token)
+
+cat >/tmp/cwltest/arv-cwl-jobs <<EOF2
+#!/bin/sh
+exec arvados-cwl-runner --api=jobs --compute-checksum \\\$@
+EOF2
+chmod +x /tmp/cwltest/arv-cwl-jobs
+
+cat >/tmp/cwltest/arv-cwl-containers <<EOF2
+#!/bin/sh
+exec arvados-cwl-runner --api=containers --compute-checksum \\\$@
+EOF2
+chmod +x /tmp/cwltest/arv-cwl-containers
+
 env
-exec ./run_test.sh "$@"
+exec ./run_test.sh $@
 EOF
 
 CODE=$?