Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4306 from cloudfoundry/e2e-logging-label
Browse files Browse the repository at this point in the history
Allow e2e test logging to be controlled by label on PR
  • Loading branch information
richard-cox committed May 21, 2020
2 parents 4bf6bfc + 0a2b4d1 commit bc92bae
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
12 changes: 12 additions & 0 deletions deploy/ci/travis/check-e2e-pr.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions deploy/ci/travis/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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..."
Expand Down
26 changes: 22 additions & 4 deletions src/test-e2e/helpers/request-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
Expand Down

0 comments on commit bc92bae

Please sign in to comment.