From ef5756b5fff64167c328e6017647cf53ed06d289 Mon Sep 17 00:00:00 2001 From: Patrick Nawracay Date: Wed, 30 May 2018 16:00:40 +0200 Subject: [PATCH] mgr/dashboard: Extend dev scripts for API testing Signed-off-by: Patrick Nawracay --- .../mgr/dashboard/run-backend-api-request.sh | 7 +++-- .../mgr/dashboard/run-backend-api-tests.sh | 29 ++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/pybind/mgr/dashboard/run-backend-api-request.sh b/src/pybind/mgr/dashboard/run-backend-api-request.sh index d52bc174b3e1f..1dad7d636d281 100755 --- a/src/pybind/mgr/dashboard/run-backend-api-request.sh +++ b/src/pybind/mgr/dashboard/run-backend-api-request.sh @@ -3,13 +3,16 @@ CURR_DIR=`pwd` cd ../../../../build API_URL=`./bin/ceph mgr services 2>/dev/null | jq .dashboard | sed -e 's/"//g' -e 's!/$!!g'` +if [ "$API_URL" = "null" ]; then + echo "Couldn't retrieve API URL, exiting..." >&2 + exit 1 +fi cd $CURR_DIR curl --insecure -s -c /tmp/cd-cookie.txt -H "Content-Type: application/json" -X POST -d '{"username":"admin","password":"admin"}' $API_URL/api/auth > /dev/null -echo "API_ENDPOINT: $API_URL" echo "METHOD: $1" -echo "PATH: $2" +echo "URL: ${API_URL}${2}" echo "DATA: $3" echo "" diff --git a/src/pybind/mgr/dashboard/run-backend-api-tests.sh b/src/pybind/mgr/dashboard/run-backend-api-tests.sh index e7b78e91269bf..2a3c40eb36c83 100755 --- a/src/pybind/mgr/dashboard/run-backend-api-tests.sh +++ b/src/pybind/mgr/dashboard/run-backend-api-tests.sh @@ -1,18 +1,21 @@ #!/usr/bin/env bash - - -# Usage (run from ./): -# ./run-backend-api-tests.sh -# ./run-backend-api-tests.sh [tests]... -# -# Example: -# ./run-backend-api-tests.sh tasks.mgr.dashboard.test_pool.DashboardTest -# -# Or source this script. Allows to re-run tests faster: -# $ source run-backend-api-tests.sh -# $ run_teuthology_tests [tests]... -# $ cleanup_teuthology +if [[ "$1" = "-h" || "$1" = "--help" ]]; then + echo "Usage (run from ./):" + echo -e "\t./run-backend-api-tests.sh" + echo -e "\t./run-backend-api-tests.sh [tests]..." + echo + echo "Example:" + echo -e "\t./run-backend-api-tests.sh tasks.mgr.dashboard.test_pool.DashboardTest" + echo + echo "Or source this script. This allows to re-run tests faster:" + echo -e "\tsource run-backend-api-tests.sh" + echo -e "\trun_teuthology_tests [tests]..." + echo -e "\tcleanup_teuthology" + echo + + exit 0 +fi # creating temp directory to store virtualenv and teuthology -- 2.39.5