Skip to content

Commit

Permalink
feat: Add changes to run tests using circle ci for partial reruns (#965)
Browse files Browse the repository at this point in the history
* Add changes to run tests using circle ci for partial reruns

* Update config continue to store results for backend sdk and other tests

* Update config_continue template to fix some syntax issues

* Undo placeholder change to keep things same

* Undo change for removing workflow version based on circleci linter

* Add a print context job to debug circle ci issues

* Remove print context step

* Add some improvements for proper partial re-run support in circle CI

* Update test run commands to make them run without issues

* Remove use of test.mocha.env in tests that don't use it

* Remove use of mocha multi in test runs

* Add some fixes to run tests more accurately in different setups

* Add fixes for exporting env variables properly

* Add fixes to properly store the test results through junit

* Fix mocha tests with free core

* Add some fixes to properly set multi variable

* Install mocha multi-junit-reporter package for tests

* Add changes to not use absolute path for junit results

* Update mocha file environment variable to match other paths

* Use a simple report name for junit result reports

* Add mocha junit file name fixes

* Fix multi variable not being visible to runner

* Add debug steps for checking the junit file

* Add support for printing test-results directory for debugging

* Add fix for the path for test-results

* Add support for proper paths for all tests

* Remove unused parameters from unit-test job
  • Loading branch information
deepjyoti30-st authored Dec 4, 2024
1 parent 7e33a06 commit af56de2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
10 changes: 7 additions & 3 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./doUnitTests.sh << parameters.cdi-version >>)
- store_test_results:
path: ~/test_report/free-core-junit.xml
- slack/status
test-backend-sdk-testing:
docker:
Expand All @@ -75,6 +77,8 @@ jobs:
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./doBackendSDKTests.sh << parameters.cdi-version >> << parameters.fdi-version >>)
- store_test_results:
path: ~/backend-sdk-testing/test-results/junit.xml
- slack/status
test-website:
docker:
Expand All @@ -94,6 +98,8 @@ jobs:
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./website.sh << parameters.fdi-version >>)
- store_test_results:
path: ~/test_report/website-junit.xml
- slack/status
test-authreact:
docker:
Expand All @@ -103,8 +109,6 @@ jobs:
parameters:
fdi-version:
type: string
environment:
MOCHA_FILE: ~/test_report/report_node-<< parameters.fdi-version >>.xml
parallelism: 4
steps:
- checkout
Expand All @@ -125,7 +129,7 @@ jobs:
path: ~/test_report/react-logs
destination: react-logs
- store_test_results:
path: ~/test_report/report_node-<< parameters.fdi-version >>.xml
path: ~/test_report/auth-react-junit.xml
- slack/status
test-success:
docker:
Expand Down
17 changes: 12 additions & 5 deletions .circleci/setupAndTestBackendSDKWithFreeCore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,20 @@ git clone [email protected]:supertokens/backend-sdk-testing.git
cd backend-sdk-testing
git checkout $frontendDriverVersion
npm install
npm i mocha-multi mocha-junit-reporter
npm run build

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi
export API_PORT=$API_PORT
export TEST_MODE=testing
export SUPERTOKENS_CORE_TAG=$coreTag
export NODE_PORT=8081
export INSTALL_PATH=../supertokens-root
export MOCHA_FILE=test-results/junit.xml
export multi="spec=- mocha-junit-reporter=$MOCHA_FILE"

mkdir -p test-results
TEST_FILES=$(circleci tests glob "test/**/*.test.js")
echo "$TEST_FILES" | circleci tests run --command="xargs npx mocha mocha --reporter mocha-multi --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --timeout 500000 --no-config" --verbose --split-by=timings

# kill test-server
kill $(lsof -t -i:$API_PORT)
8 changes: 7 additions & 1 deletion .circleci/setupAndTestWithAuthReact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,14 @@ done
sleep 2 # Because the server is responding does not mean the app is ready. Let's wait another 2secs to make sure the app is up.
echo "Start mocha testing"

export MOCHA_FILE=~/test_report/auth-react-junit.xml
export multi="spec=- mocha-junit-reporter=$MOCHA_FILE"
export TEST_MODE=testing
export APP_SERVER=$apiPort
export SCREENSHOT_ROOT=~/test_report/screenshots

export SPEC_FILES=$(circleci tests glob 'test/end-to-end/**/*.test.js' 'test/unit/**/*.test.js')
echo $SPEC_FILES | SCREENSHOT_ROOT=~/test_report/screenshots APP_SERVER=$apiPort TEST_MODE=testing multi="spec=- mocha-junit-reporter=/dev/null" circleci tests run --command="xargs npx mocha mocha --reporter mocha-multi --require @babel/register --require test/test.mocha.env --timeout 40000 --no-config" --verbose --split-by=timings
echo $SPEC_FILES | circleci tests run --command="xargs npx mocha mocha --reporter mocha-multi --require @babel/register --require test/test.mocha.env --timeout 40000 --no-config" --verbose --split-by=timings

testPassed=$?;
cp ../supertokens-root/logs/error.log ~/test_report/logs/core_error.log
Expand Down
16 changes: 11 additions & 5 deletions .circleci/setupAndTestWithFreeCore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ then
fi
echo "Testing with FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion"

mkdir -p ~/test_report
cd ../../
git clone [email protected]:supertokens/supertokens-root.git
cd supertokens-root
Expand All @@ -84,12 +85,17 @@ cd ../
echo $SUPERTOKENS_API_KEY > apiPassword
./utils/setupTestEnvLocal
cd ../project/
npm i mocha-multi mocha-junit-reporter

# Set the script to exit on error
set -e

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi
export TEST_MODE=testing
export SUPERTOKENS_CORE_TAG=$coreTag
export NODE_PORT=8081
export INSTALL_PATH=../supertokens-root
export MOCHA_FILE=~/test_report/free-core-junit.xml
export multi="spec=- mocha-junit-reporter=$MOCHA_FILE"

TEST_FILES=$(circleci tests glob "test/**/*.test.js")
echo "$TEST_FILES" | circleci tests run --command="xargs npx mocha mocha --reporter mocha-multi --node-option no-experimental-fetch --timeout 40000 --no-config" --verbose --split-by=timings
16 changes: 11 additions & 5 deletions .circleci/setupAndTestWithFrontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ fi

echo "Testing with frontend website: $2, FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion"

mkdir -p ~/test_report

cd ../../
git clone [email protected]:supertokens/supertokens-root.git
cd supertokens-root
Expand Down Expand Up @@ -96,11 +98,15 @@ npm i
cd ../../
npm i -d

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --exit --no-config --require isomorphic-fetch --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/*.test.js')
else
TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi
export TEST_MODE=testing
export SUPERTOKENS_CORE_TAG=$coreTag
export NODE_PORT=8081
export INSTALL_PATH=../supertokens-root
export MOCHA_FILE=~/test_report/website-junit.xml
export multi="spec=- mocha-junit-reporter=$MOCHA_FILE"

TEST_FILES=$(circleci tests glob "test/*.test.js")
echo "$TEST_FILES" | circleci tests run --command="xargs npx mocha npx mocha --exit --reporter mocha-multi --no-config --require isomorphic-fetch --timeout 500000" --verbose --split-by=timings

if [[ $? -ne 0 ]]
then
Expand Down

0 comments on commit af56de2

Please sign in to comment.