Skip to content

Commit eb02b6f

Browse files
authored
Merge pull request #1727 from microbiomedata/pass-gcs-endpoint-to-tests
Use GCS env vars in testing environment
2 parents 5b97a8d + afe09ae commit eb02b6f

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

docs/development.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Follow the steps below to configure the necessary settings.
5151
NMDC_SESSION_SECRET_KEY=changeme
5252
NMDC_API_JWT_SECRET=changeme
5353
```
54-
54+
5555
### NERSC Credentials
5656

5757
To load production data or to run an ingest locally, you will need NERSC credentials.
@@ -196,7 +196,7 @@ Although the project is designed to be run in Docker, having the dependencies in
196196
source .venv/bin/activate
197197
pip install -e .
198198
```
199-
199+
200200
### Frontend dependencies
201201
202202
1. Install the frontend dependencies.
@@ -212,7 +212,7 @@ Run the full stack via Docker Compose:
212212
<!-- TODO: Consider adding `--build` to this command so that Docker Compose builds
213213
the containers, rather than pulling from from GHCR (unless you
214214
want to use the versions that happen to currently be on GHCR).
215-
This has to do with the fact that the `docker-compose.yml` file
215+
This has to do with the fact that the `docker-compose.yml` file
216216
contains service specs having both an `image` and `build` section. -->
217217
218218
```bash
@@ -250,16 +250,16 @@ yarn serve
250250
<details>
251251
<summary>Running yarn via npx?</summary>
252252
253-
When you run `$ npx yarn serve` while using a Node.js version newer than 17, the frontend development server may fail to start and may, instead, display the error code "`ERR_OSSL_EVP_UNSUPPORTED`".
253+
When you run `$ npx yarn serve` while using a Node.js version newer than 17, the frontend development server may fail to start and may, instead, display the error code "`ERR_OSSL_EVP_UNSUPPORTED`".
254254
255-
You can work around that error by prefixing the command with "`NODE_OPTIONS=--openssl-legacy-provider`", as explained [here](https://stackoverflow.com/a/70582385) and shown below:
255+
You can work around that error by prefixing the command with "`NODE_OPTIONS=--openssl-legacy-provider`", as explained [here](https://stackoverflow.com/a/70582385) and shown below:
256256
257257
```bash
258258
NODE_OPTIONS=--openssl-legacy-provider npx yarn serve
259259
```
260260
</details>
261261
262-
View the main application at `http://127.0.0.1:8081/`. Changes to files in the `web` directory will automatically trigger a reload in your browser.
262+
View the main application at `http://127.0.0.1:8081/`. Changes to files in the `web` directory will automatically trigger a reload in your browser.
263263
264264
> **Note**: An instance of the frontend application will continue to be served via Docker Compose on port `8080`, but that instance will not pick up changes to the `web` directory automatically. Be aware of which port you are accessing when doing frontend development.
265265
@@ -271,7 +271,7 @@ It is recommended to use `127.0.0.1` instead of `localhost` for local developmen
271271
272272
> **Note**: This is not generally required unless you are specifically working on the ingest code. If you are working on the web application, simply [loading from a recent production backup](#load-production-data) is sufficient.
273273
274-
1. Ensure that you have completed the sections above about configuring your [NERSC credentials](#nersc-credentials) and [MongoDB credentials](#mongodb-credentials).
274+
1. Ensure that you have completed the sections above about configuring your [NERSC credentials](#nersc-credentials) and [MongoDB credentials](#mongodb-credentials).
275275
2. Obtain a new SSH key from NERSC if you haven't done so in the last 24 hours.
276276
```bash
277277
sshproxy.sh -u $NERSC_USER
@@ -288,8 +288,8 @@ It is recommended to use `127.0.0.1` instead of `localhost` for local developmen
288288
-i ~/.ssh/nersc \
289289
dtn01.nersc.gov
290290
```
291-
> That command will set up SSH port forwarding such that your computer can access the dev MongoDB server at `localhost:37018` and the prod MongoDB server at `localhost:37019`.
292-
291+
> That command will set up SSH port forwarding such that your computer can access the dev MongoDB server at `localhost:37018` and the prod MongoDB server at `localhost:37019`.
292+
293293
> From within a Docker container `host.docker.internal` can be used to access the `localhost` of your computer. When ingesting from the dev or prod MongoDB instances, be sure to set `NMDC_MONGO_HOST=host.docker.internal` in your `.env` file.
294294
295295
> See https://github.com/microbiomedata/infra-admin/blob/main/mongodb/connection-guide.md (internal) for more information on connecting to the MongoDB instances.
@@ -305,7 +305,7 @@ It is recommended to use `127.0.0.1` instead of `localhost` for local developmen
305305
```bash
306306
docker-compose run backend nmdc-server ingest -vv --function-limit 100
307307
```
308-
308+
309309
> **Note**: The `--function-limit` flag is optional. It is used to reduce the time that the ingest takes by limiting the number of certain types of objects loaded. This can be useful for testing purposes. For more information on options run `nmdc-server ingest --help`.
310310
311311
## Testing
@@ -314,6 +314,19 @@ It is recommended to use `127.0.0.1` instead of `localhost` for local developmen
314314
tox
315315
```
316316
317+
In order for the `py312` test suite to run properly, it needs to be able to communicate with a running `postgres` server and the fake GCS service. You can use the docker configuration to get these services up and running:
318+
319+
```bash
320+
docker compose up db storage
321+
```
322+
323+
You'll also need to set environment variables so the tests know where these resources can be found. If you're running the services via `docker compose`, then you can use the following values:
324+
325+
```bash
326+
export NMDC_TESTING_DATABASE_URI=postgresql://postgres:postgres@localhost:5432/nmdc_testing
327+
export NMDC_GCS_FAKE_API_ENDPOINT=http://localhost:4443
328+
```
329+
317330
## Generating new migrations
318331
319332
```bash

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ deps =
1515
setenv =
1616
NMDC_ENVIRONMENT = testing
1717
SQLALCHEMY_SILENCE_UBER_WARNING=1
18+
NMDC_GCS_USE_FAKE = true
1819
passenv =
1920
NMDC_TESTING_DATABASE_URI
21+
NMDC_GCS_FAKE_API_ENDPOINT
2022
commands =
2123
nmdc-server generate-static-files --remove-existing
2224
nmdc-server storage init

0 commit comments

Comments
 (0)