From b9dafe6652a973377f9a0e865187fc73b94be30c Mon Sep 17 00:00:00 2001 From: shirady <57721533+shirady@users.noreply.github.com> Date: Sun, 9 Mar 2025 08:49:40 +0200 Subject: [PATCH] separate to 2 titles: single test and run all tests + add notes Signed-off-by: shirady <57721533+shirady@users.noreply.github.com> --- docs/dev_guide/run_coretest_locally.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/dev_guide/run_coretest_locally.md b/docs/dev_guide/run_coretest_locally.md index bdee095eb4..9592016039 100644 --- a/docs/dev_guide/run_coretest_locally.md +++ b/docs/dev_guide/run_coretest_locally.md @@ -1,19 +1,21 @@ -# Run a Single Test From coretest Locally +# Run Tests From coretest Locally + +## Run a Single Test If you have a single coretest that you want to run, for example: `src/test/unit_tests/test_s3_bucket_policy.js`. The options for running it are: NC deployment (no DB) and containerized deployment (with DB) -## 1) NC deployment (No DB) +### A) NC deployment (No DB) Run simply with `sudo NC_CORETEST=true node ./node_modules/mocha/bin/mocha .src/test/unit_tests/test_s3_bucket_policy.js` More info can be found in [CI & Tests](#ci--tests). -## 2) Containerized deployment (With DB) +### B) Containerized deployment (With DB) One way is to run it with: `make run-single-test testname=test_s3_bucket_policy.js` but it would take time to build the needed images, therefore we will focus on another way. Another way is to create a postgres container and then run the test with the following steps: -### First Tab - Run the Container +#### First Tab - Run the Container 1. Pull postgres image version 15: `docker pull quay.io/sclorg/postgresql-15-c9s` - We use postgres with version 15. @@ -35,7 +37,7 @@ Starting server... 2025-03-05 13:43:57.600 UTC [1] HINT: Future log output will appear in directory "log" ``` -## Second Tab - Run the Test +### Second Tab - Run the Test 3. Run the test: - If you run on Rancher Desktop: 3.1. Run with: `./node_modules/mocha/bin/mocha.js src/test/unit_tests/test_s3_bucket_policy.js` @@ -56,4 +58,9 @@ Another option, which is less recommended, is to connect to postgres container a Notes: * For running `psql` commands you would need to install it on your machine (better with the matching version of postgres). * In case you already run postgres on your machine (not the mentioned container) it might raise some issues, better remove it (in MacOs using the Activity Monitor and search for postgres). +* In case a test failed with "error: database "coretest" already exists" it means that you probably forgot to drop the DB table, and you can stop (ctrl + c) and rerun the `docker run` command mentioned above and then run the test again. +* If you want to run the test with higher debug level you can add the `NOOBAA_LOG_LEVEL=all`, for example: `NOOBAA_LOG_LEVEL=all ./node_modules/mocha/bin/mocha.js src/test/unit_tests/test_s3_bucket_policy.js` (notice that you can printings that are not only from `LOG`, `L0`, `WARN` and `ERROR`, for example: `L1`, `L2`, `L3`, etc.) + +## Run All Tests +If you want to run all the mocha tests using the DB on the second tab you can simply run `npm test`.