Skip to content

Commit

Permalink
Add variability for test suite (#19343)
Browse files Browse the repository at this point in the history
  • Loading branch information
Katka92 committed Mar 22, 2021
1 parent aaf2403 commit 0cf4275
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dockerfiles/e2e/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ else
fi

# Launch tests
if [ $TEST_SUITE == "load-test" ]; then
if [ $TS_LOAD_TESTS ]; then
timestamp=$(date +%s)
user_folder="$TS_SELENIUM_USERNAME-$timestamp"
export TS_SELENIUM_REPORT_FOLDER="./$user_folder/report"
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/TestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ export const TestConstants = {
/**
* URL of the workspace created by devworkspace-controller
*/
TS_SELENIUM_DEVWORKSPACE_URL: process.env.TS_SELENIUM_DEVWORKSPACE_URL
TS_SELENIUM_DEVWORKSPACE_URL: process.env.TS_SELENIUM_DEVWORKSPACE_URL,

/**
* This variable specifies that run test is used for load testing and that all artifacts will be sent to ftp client.
*/
TS_LOAD_TESTS: process.env.TS_LOAD_TESTS || 'false'

};
2 changes: 1 addition & 1 deletion tests/e2e/driver/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CheReporter extends mocha.reporters.Spec {
});

runner.on('pass', async (test: mocha.Test) => {
if (TestConstants.TEST_SUITE === 'load-test') {
if (TestConstants.TS_LOAD_TESTS) {
const loadTestReportFolder: string = TestConstants.TS_SELENIUM_LOAD_TEST_REPORT_FOLDER;
const loadTestFilePath: string = loadTestReportFolder + '/load-test-results.txt';
const report = test.title + ': ' + test.duration + '\r';
Expand Down
21 changes: 17 additions & 4 deletions tests/performance/load-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TIMESTAMP=$(date +%s)
TEST_FOLDER=$(pwd)
LOG_LEVEL="INFO"
SERVER_SETTING="oauth"
TEST_SUITE="load-test"

function printHelp {
YELLOW="\\033[93;1m"
Expand All @@ -26,7 +27,8 @@ function printHelp {
echo -e "-t count on how many times one user should run a workspace"
echo -e "-l log level for test [ 'INFO' (default), 'DEBUG', 'TRACE' ]"
echo -e "-s setting of CRW [ 'oauth' (default), 'no-oauth'] "
echo -e "-v cluster URL to obtain OC user token"${NC}
echo -e "-v cluster URL to obtain OC user token"
echo -e "-w test suite ${NC} default to load-test"${NC}
}

oc whoami 1>/dev/null
Expand All @@ -36,7 +38,7 @@ if [ $? -gt 0 ] ; then
fi

echo "You are logged in OC: $(oc whoami -c)"
while getopts "c:f:hi:l:n:p:r:t:u:s:v:" opt; do
while getopts "c:f:hi:l:n:p:r:t:u:s:v:w:" opt; do
case $opt in
h) printHelp
exit 0
Expand All @@ -63,6 +65,8 @@ while getopts "c:f:hi:l:n:p:r:t:u:s:v:" opt; do
;;
v) export cheClusterUrl=$OPTARG
;;
w) export TEST_SUITE=$OPTARG
;;
\?) # invalid option
exit 1
;;
Expand Down Expand Up @@ -173,7 +177,17 @@ sed -i "s/REPLACE_URL/\"$parsed_url\"/g" template.yaml
sed -i "s/REPLACE_TIMESTAMP/\"$TIMESTAMP\"/g" template.yaml
sed -i "s/REPLACE_IMAGE/\"$parsed_image\"/g" template.yaml
sed -i "s/REPLACE_LOG_LEVEL/$LOG_LEVEL/g" template.yaml

if [ $TEST_SUITE == "load-test" ]; then
sed -i_.bak '/USERSTORY/d' template.yaml
sed -i "s/REPLACE_TEST_SUITE/$TEST_SUITE/g" template.yaml
sed -i "s/MEMORY_REQUEST/\"900Mi\"/g" template.yaml
sed -i "s/MEMORY_LIMIT/\"900Mi\"/g" template.yaml
else
sed -i_.bak '/TEST_SUITE/d' template.yaml
sed -i "s/REPLACE_USERSTORY/$TEST_SUITE/g" template.yaml
sed -i "s/MEMORY_REQUEST/\"1Gi\"/g" template.yaml
sed -i "s/MEMORY_LIMIT/\"1Gi\"/g" template.yaml
fi

# ----------- RUNNING TEST ----------- #
echo "-- Running pods with tests."
Expand Down Expand Up @@ -249,7 +263,6 @@ echo "Pods ended with those statuses: $statuses"
# ----------- GATHERING LOGS ----------- #
echo "-- Gathering logs."

set -x
echo "Syncing files from PVC to local folder."
mkdir $FOLDER/$TIMESTAMP
cd $FOLDER/$TIMESTAMP
Expand Down
12 changes: 9 additions & 3 deletions tests/performance/pod-oauth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ spec:
- name: TS_SELENIUM_BASE_URL
value: REPLACE_URL
- name: TEST_SUITE
value: load-test
value: REPLACE_TEST_SUITE
- name: USERSTORY
value: REPLACE_USERSTORY
- name: TIMESTAMP
value: REPLACE_TIMESTAMP
- name: TS_SELENIUM_MULTIUSER
Expand All @@ -43,6 +45,8 @@ spec:
value: REPLACE_USERNAME
- name: TS_SELENIUM_OCP_PASSWORD
value: REPLACE_PASSWORD
- name: TS_SELENIUM_PASSWORD
value: REPLACE_PASSWORD
- name: E2E_OPENSHIFT_TOKEN
value: REPLACE_TOKEN
- name: E2E_OCP_CLUSTER_VERSION
Expand All @@ -59,14 +63,16 @@ spec:
value: "1000000"
- name: TS_SELENIUM_WORKSPACE_STATUS_POLLING
value: "500000"
- name: TS_LOAD_TESTS
value: "true"
image: REPLACE_IMAGE
imagePullPolicy: Always
name: load-testing-container
resources:
requests:
memory: "900Mi"
memory: MEMORY_REQUEST
cpu: "250m"
limits:
memory: "900Mi"
memory: MEMORY_LIMIT
cpu: "700m"
restartPolicy: Never

0 comments on commit 0cf4275

Please sign in to comment.