diff --git a/deploy/ci/travis/check-e2e-pr.sh b/deploy/ci/travis/check-e2e-pr.sh new file mode 100755 index 0000000000..89ab5b6346 --- /dev/null +++ b/deploy/ci/travis/check-e2e-pr.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ -n "${TRAVIS_PULL_REQUEST}" ]; then + if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then + echo "Checking labels on ${TRAVIS_PULL_REQUEST_SLUG} #${TRAVIS_PULL_REQUEST}" + LABEL=$(curl -s "https://api.github.com/repos/${TRAVIS_PULL_REQUEST_SLUG}/pulls/${TRAVIS_PULL_REQUEST}" | jq -r '.labels[] | select(.name == "e2e-debug") | .name') + if [ "${LABEL}" == "e2e-debug" ]; then + echo "PR has the 'e2e-debug' label - enabling debug logging for E2E tests" + export STRATOS_E2E_DEBUG=true + fi + fi +fi diff --git a/deploy/ci/travis/run-e2e-tests.sh b/deploy/ci/travis/run-e2e-tests.sh index 857930c1ee..0d8017bf06 100755 --- a/deploy/ci/travis/run-e2e-tests.sh +++ b/deploy/ci/travis/run-e2e-tests.sh @@ -5,6 +5,8 @@ set -e echo "Stratos e2e tests" echo "=================" +DIRPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../../.. && pwd)" + echo "Checking docker version" docker version @@ -64,6 +66,9 @@ export STRATOS_E2E_BASE_URL="https://127.0.0.1:5443" E2E_TARGET="e2e -- --no-webdriver-update --dev-server-target= --base-url=https://127.0.0.1:5443 --suite=${SUITE}" +# Set Stratos debug if running a PR with the appropriate label +source "${DIRPATH}/deploy/ci/travis/check-e2e-pr.sh" + # Capture video if configured if [ "$CAPTURE_VIDEO" == "video" ]; then echo "Waiting for ffmpeg install to complete..." diff --git a/src/test-e2e/helpers/request-helpers.ts b/src/test-e2e/helpers/request-helpers.ts index 8567263a7e..24290b3037 100644 --- a/src/test-e2e/helpers/request-helpers.ts +++ b/src/test-e2e/helpers/request-helpers.ts @@ -85,7 +85,7 @@ export class RequestHelpers { } E2E.debugLog('REQ: ' + options.method + ' ' + options.url); - E2E.debugLog(' > ' + JSON.stringify(options)); + this.showOptions(options); reqObj(options).then((response) => { E2E.debugLog('OK'); @@ -96,15 +96,33 @@ export class RequestHelpers { } p.fulfill(response.body); }).catch((e) => { - E2E.debugLog('ERROR'); - E2E.debugLog(e); - E2E.debugLog(e.statusCode + ' : ' + e.message); + E2E.debugLog('ERR: ' + e.statusCode + ' : ' + e.message); p.reject(e); }); return p.promise; } + showOptions(options: any) { + if (!options) { + return; + } + const cpy = JSON.parse(JSON.stringify(options)); + this.sanitizeOption(cpy); + E2E.debugLog(' > ' + JSON.stringify(cpy)); + } + + sanitizeOption(options) { + Object.keys(options).forEach(key => { + const v = options[key]; + if (typeof v === 'string' && key === 'password') { + options[key] = '******'; + } else if (typeof v === 'object') { + this.sanitizeOption(options[key]); + } + }); + } + /** * @createSession * @description Create a session