Skip to content

Commit ff3bb27

Browse files
committed
Add just file for better dev experience
1 parent 99454e0 commit ff3bb27

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

TESTING.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Tests can be found in `graphdatascience/tests`. In each of the folders there, `u
77
Please see the section [Specifically for this project](CONTRIBUTING.md#specifically-for-this-project) of our [contribution guidelines](CONTRIBUTING.md) for how to set up an environment for testing and style checking.
88

99
> **_NOTE:_** This document does not cover documentation testing.
10-
Please see the [documentation README](doc/README.md#testing) for that.
11-
10+
> Please see the [documentation README](doc/README.md#testing) for that.
1211
1312
## Unit testing
1413

@@ -20,45 +19,47 @@ To run the unit tests (with default options), simply call:
2019
pytest graphdatascience/tests/unit
2120
```
2221

22+
or for just `just unit-tests`
2323

2424
## Integration testing
2525

2626
In order to run the integration tests one must have a [Neo4j DBMS](https://neo4j.com/docs/getting-started/current/) with the Neo4j Graph Data Science library installed running.
2727

28+
If you want to use just, you can use `just it`.
2829

2930
### V2 endpoints
3031

3132
The integration tests for the V2 endpoints are located in `graphdatascience/tests/integration/v2`.
3233
In order to run the tests, you need to have Docker running.
3334
You also need to either bring two Docker images, or configure authenticated access to the GCP repository where the production Docker images are stored.
3435

36+
If you want to use just, you can use `just it-v2`.
3537

3638
### Bringing your own Docker images
3739

3840
Set the environment variables `NEO4J_DATABASE_IMAGE` and `GDS_SESSION_IMAGE` to the names of the Docker images you want to use.
3941

40-
4142
### Configuring authenticated access to the GCP repository
4243

4344
1. `gcloud init`
4445
2. `gcloud auth login`
4546
3. `gcloud auth configure-docker europe-west1-docker.pkg.dev`
4647

47-
4848
### Configuring
4949

50+
If you do not want to use a custom neo4j db, you can use the test-envs under `scripts/test-envs`.
51+
5052
The tests will through the [Neo4j Python driver](https://neo4j.com/docs/python-manual/current/) connect to a Neo4j database based on the environment variables:
5153

52-
* `NEO4J_URI` (defaulting to "bolt://localhost:7687" if unset),
53-
* `NEO4J_USER`,
54-
* `NEO4J_PASSWORD` (defaulting to "neo4j" if unset),
55-
* `NEO4J_DB` (defaulting to "neo4j" if unset).
54+
- `NEO4J_URI` (defaulting to "bolt://localhost:7687" if unset),
55+
- `NEO4J_USER`,
56+
- `NEO4J_PASSWORD` (defaulting to "neo4j" if unset),
57+
- `NEO4J_DB` (defaulting to "neo4j" if unset).
5658

5759
However, if `NEO4J_USER` is not set the tests will try to connect without authentication.
5860

5961
Once the driver connects successfully to the Neo4j DBMS the tests will go on to execute against the `NEO4J_DB` database.
6062

61-
6263
### Running
6364

6465
To run the integration tests (with default options), simply call:
@@ -75,7 +76,6 @@ Note however that this also requires you to have specified a valid path for the
7576

7677
If the database you are targeting is an AuraDS instance, you should use the option `--target-aura` which makes sure that tests of operations not supported on AuraDS are skipped.
7778

78-
7979
### Running tests that require encrypted connections
8080

8181
In order to run integration tests that test encryption features, you must setup the Neo4j server accordingly:
@@ -99,14 +99,12 @@ To run only integration tests that are marked as `encrypted_only`, call:
9999
pytest graphdatascience/tests/integration --encrypted-only
100100
```
101101

102-
103102
### GDS library versions
104103

105104
There are integration tests that are only compatible with certain versions of the GDS library.
106105
For example, a procedure (which does not follow the standard algorithm procedure pattern) introduced in version 2.1.0 of the library will not exist in version 2.0.3, and so any client side integration tests that call this procedure should not run when testing against server library version 2.0.3.
107106
For this reason only tests compatible with the GDS library server version you are running against will run.
108107

109-
110108
## Style guide
111109

112110
The code and examples use [ruff](hhttps://docs.astral.sh/ruff/) to format and lint.
@@ -116,7 +114,6 @@ Use `SKIP_NOTEBOOKS=true` to only format the code.
116114

117115
See `pyproject.toml` for the configuration.
118116

119-
120117
### Static typing
121118

122119
The code is annotated with type hints in order to provide documentation and allow for static type analysis with [mypy](http://mypy-lang.org/).
@@ -129,18 +126,16 @@ mypy .
129126

130127
from the root. See `mypy.ini` for our custom mypy settings.
131128

132-
133129
## Notebook examples
134130

135131
The notebooks under `/examples` can be run using `scripts/run_notebooks`.
136132

137-
138133
### Cell Tags
139134

140-
*Verify version*
135+
_Verify version_
141136
If you only want to let CI run the notebook given a certain condition, tag a given cell in the notebook with `verify-version`.
142137
As the name suggests, the tag was introduced to only run for given GDS server versions.
143138

144-
*Teardown*
139+
_Teardown_
145140

146141
To make sure certain cells are always run even in case of failure, tag the cell with `teardown`.

justfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
style:
2+
./scripts/makestyle && ./scripts/checkstyle
3+
4+
convert-notebooks:
5+
./scripts/nb2doc/convert.sh
6+
7+
unit-tests:
8+
pytest tests/unit
9+
10+
it filter="" enterprise="true":
11+
#!/usr/bin/env bash
12+
set -e
13+
if [ "{{enterprise}}" = "true" ]; then
14+
ENV_DIR="scripts/test_envs/gds_plugin_enterprise"
15+
EXTRA_FLAGS="--include-model-store-location --include-enterprise"
16+
else
17+
ENV_DIR="scripts/test_envs/gds_plugin_community"
18+
EXTRA_FLAGS=""
19+
fi
20+
trap "cd $ENV_DIR && docker compose down" EXIT
21+
cd $ENV_DIR && docker compose up -d
22+
cd -
23+
pytest tests/integration $EXTRA_FLAGS --basetemp=tmp/ {{ if filter != "" { "-k '" + filter + "'" } else { "" } }}
24+
25+
26+
# such as `just it-v2 wcc`
27+
it-v2 filter="":
28+
pytest tests/integrationV2 --include-integration-v2 --basetemp=tmp/ {{ if filter != "" { "-k '" + filter + "'" } else { "" } }}

0 commit comments

Comments
 (0)