]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix run-frontend-e2e-tests.sh 28954/head
authorTiago Melo <tmelo@suse.com>
Mon, 19 Nov 2018 15:07:07 +0000 (15:07 +0000)
committerKiefer Chang <kiefer.chang@suse.com>
Wed, 10 Jul 2019 06:34:02 +0000 (14:34 +0800)
e2e tests were always returning positive result, even when they failed.

Fixed problem with jq, where it was failing when it was not receiving a string.

Fixes: http://tracker.ceph.com/issues/40707
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
Signed-off-by: Tiago Melo <tmelo@suse.com>
(cherry picked from commit ad293e1961065ea4b92244c8f059dff0ef73a016)

Conflicts:
src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh

src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh

index 4886c2d43526739eb133d48b5193828223daf3d9..af3f03b1c253caca800ffdfe5e0efbcf92b5508c 100755 (executable)
@@ -7,7 +7,7 @@ stop() {
         cd $BUILD_DIR
         ../src/stop.sh
     fi
-    exit
+    exit $1
 }
 
 BASE_URL=''
@@ -18,7 +18,10 @@ while getopts 'd:r:' flag; do
   case "${flag}" in
     d) DEVICE=$OPTARG;;
     r) REMOTE='true'
-       BASE_URL=$OPTARG;;
+       # jq is expecting a string literal, otherwise it will fail on the url ':'.
+       # We need to ensure that jq gets a json string for assignment; we achieve
+       # that by introducing literal double quotes (i.e., '"').
+       BASE_URL='"'$OPTARG'"';;
   esac
 done
 
@@ -30,7 +33,7 @@ if [ "$DEVICE" == "" ]; then
     else
         echo "ERROR: Chrome and Docker not found. You need to install one of  \
 them to run the e2e frontend tests."
-        stop
+        stop 1
     fi
 fi
 
@@ -44,23 +47,26 @@ if [ "$BASE_URL" == "" ]; then
     sleep 10
 
     BASE_URL=`./bin/ceph mgr services | jq .dashboard`
-    BASE_URL=${BASE_URL//\"}
 fi
 
 cd $DASH_DIR/frontend
+jq .[].target=$BASE_URL proxy.conf.json.sample > proxy.conf.json
+
 . $BUILD_DIR/src/pybind/mgr/dashboard/node-env/bin/activate
 npm ci
 npm run build -- --prod
 
 if [ $DEVICE == "chrome" ]; then
-    npm run e2e -- --serve=false --base-href $BASE_URL || stop
+    npm run e2e || stop 1
+    stop 0
 elif [ $DEVICE == "docker" ]; then
-    docker run -d -v $(pwd):/workdir --net=host --name angular-e2e-container rogargon/angular-e2e || stop
-    docker exec angular-e2e-container npm run e2e -- --serve=false --base-href $BASE_URL
+    failed=0
+    docker run -d -v $(pwd):/workdir --net=host --name angular-e2e-container rogargon/angular-e2e || failed=1
+    docker exec angular-e2e-container npm run e2e || failed=1
     docker stop angular-e2e-container
     docker rm angular-e2e-container
+    stop $failed
 else
     echo "ERROR: Device not recognized. Valid devices are 'chrome' and 'docker'."
+    stop 1
 fi
-
-stop