13306: test_with_arvbox can select api
[arvados.git] / sdk / cwl / test_with_arvbox.sh
index ee8daa1e15cbfc1147a00839b8d7da9f69c7d1fe..22d47a5d481555ab7b52284eeb263624a0b04bc2 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/sh
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
 
 set -x
 
@@ -9,7 +12,10 @@ fi
 reset_container=1
 leave_running=0
 config=dev
-tag=""
+tag="latest"
+pythoncmd=python
+suite=conformance
+runapi=containers
 
 while test -n "$1" ; do
     arg="$1"
@@ -30,8 +36,24 @@ while test -n "$1" ; do
             tag=$2
             shift ; shift
             ;;
+        --build)
+            build=1
+            shift
+            ;;
+        --pythoncmd)
+            pythoncmd=$2
+            shift ; shift
+            ;;
+        --suite)
+            suite=$2
+            shift ; shift
+            ;;
+       --api)
+           runapi=$2
+            shift ; shift
+            ;;
         -h|--help)
-            echo "$0 [--no-reset-container] [--leave-running] [--config dev|localdemo] [--tag docker_tag]"
+            echo "$0 [--no-reset-container] [--leave-running] [--config dev|localdemo] [--tag docker_tag] [--build] [--pythoncmd python(2|3)] [--suite (integration|conformance)]"
             exit
             ;;
         *)
@@ -45,6 +67,8 @@ if test -z "$ARVBOX_CONTAINER" ; then
 fi
 
 if test $reset_container = 1 ; then
+    arvbox stop
+    docker rm $ARVBOX_CONTAINER
     arvbox reset -f
 fi
 
@@ -55,12 +79,22 @@ set -eu -o pipefail
 
 . /usr/local/lib/arvbox/common.sh
 
+export PYCMD=$pythoncmd
+
 if test $config = dev ; then
   cd /usr/src/arvados/sdk/cwl
-  python setup.py sdist
+  \$PYCMD setup.py sdist
   pip_install \$(ls -r dist/arvados-cwl-runner-*.tar.gz | head -n1)
 fi
 
+set -x
+
+if [ \$PYCMD = "python3" ]; then
+    pip3 install cwltest
+else
+    pip3 install cwltest
+fi
+
 mkdir -p /tmp/cwltest
 cd /tmp/cwltest
 if ! test -d common-workflow-language ; then
@@ -72,20 +106,37 @@ export ARVADOS_API_HOST=localhost:8000
 export ARVADOS_API_HOST_INSECURE=1
 export ARVADOS_API_TOKEN=\$(cat /var/lib/arvados/superuser_token)
 
+
+if test -n "$build" ; then
+   /usr/src/arvados/build/build-dev-docker-jobs-image.sh
+elif test "$tag" = "latest" ; then
+  arv-keepdocker --pull arvados/jobs $tag
+else
+  jobsimg=\$(curl https://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 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 --compute-checksum \\\$@
+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 --compute-checksum \\\$@
+exec arvados-cwl-runner --api=containers \\\$@
 EOF2
 chmod +x /tmp/cwltest/arv-cwl-containers
 
 env
-exec ./run_test.sh $@
+if [[ "$suite" = "conformance" ]] ; then
+   exec ./run_test.sh RUNNER=/tmp/cwltest/arv-cwl-${runapi} EXTRA=--compute-checksum $@
+elif [[ "$suite" = "integration" ]] ; then
+   cd /usr/src/arvados/sdk/cwl/tests
+   exec ./arvados-tests.sh $@
+fi
 EOF
 
 CODE=$?