Skip to content

Commit

Permalink
separate to 2 titles: single test and run all tests + add notes
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <[email protected]>
  • Loading branch information
shirady committed Mar 9, 2025
1 parent dadf094 commit b9dafe6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions docs/dev_guide/run_coretest_locally.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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`
Expand All @@ -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`.

0 comments on commit b9dafe6

Please sign in to comment.