Skip to content

Commit 1e5e848

Browse files
authored
Modified integration tests to be compatible with neptune analytics (aws#113)
Integration tests will fail if they are being executed against a neptune analytics graph. The integration tests were originally written against the assumption that they would be executing against a neptune db cluster that has been seeded with the airports gremlin sample data. However, neptune analytics graphs can only be seeded with the airports cypher sample data. There are slight differences between the two datasets, which were not handled by the integration tests. This change modifies the integration tests such that they can execute against neptune db or neptune analytics successfully: * modified queries that return ids to exclude the ids as they can differ between the datasets * modified queries that retrieved count of outbound routes to use a different set of departure and arrival airports which have a consistent value between the datasets * modified query which retrieved connecting route between airports to use more obscure departure and arrival airports such that there is only one possible connecting route and consistency across datasets * marked queries that use gremlin to be 'neptune-db' only as neptune graphs do not yet support gremlin * marked update of seattle airport query as 'neptune-db' only as this query requires an airport node id as input however for neptune analytics, the id is a uuid that is generated on creation and inconsistent across graphs * created separate file for expected neptune analytics graphQL schema * added configuration of axios interceptor so that aws credentials are passed correctly as part of the request (required for IAM) * added documentation for test execution
1 parent 6963a35 commit 1e5e848

19 files changed

Lines changed: 291 additions & 18 deletions

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ permissions and limitations under the License.
6464
event handlers to improve
6565
performance ([#111](https://github.com/aws/amazon-neptune-for-graphql/pull/111))
6666
* Updated and proofread outdated
67-
documentation ([#112](https://github.com/aws/amazon-neptune-for-graphql/pull/107), [#107](https://github.com/aws/amazon-neptune-for-graphql/pull/112))
67+
documentation ([#107](https://github.com/aws/amazon-neptune-for-graphql/pull/107), [#112](https://github.com/aws/amazon-neptune-for-graphql/pull/112))
68+
* Fixed integration tests such that they are successful when executed against a
69+
neptune analytics graph and added testing
70+
documentation ([#113](https://github.com/aws/amazon-neptune-for-graphql/pull/113))
6871

6972
### Bug Fixes
7073

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To send us a pull request, please:
3939
2. Modify the source; please focus on the specific change you are contributing.
4040
If you also reformat all the code, it will be hard for us to focus on your
4141
change.
42-
3. Ensure local tests pass.
42+
3. Ensure [local unit and integration tests pass](TESTING.md).
4343
4. Commit to your fork using clear commit messages.
4444
5. Send us a pull request, answering any default questions in the pull request
4545
interface.

TESTING.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# **Amazon Neptune Utility for GraphQL™ Tests**
2+
3+
The Amazon Neptune Utility for GraphQL project contains unit and integration
4+
tests. When contributing changes to the project, one should ensure that these
5+
tests are updated accordingly and are successful before opening a pull request.
6+
7+
All unit and integration tests can be executed with the following command:
8+
9+
```
10+
npm test
11+
```
12+
13+
## Unit Tests
14+
15+
Unit tests do not require a neptune db cluster or graph and can be executed with
16+
the following command:
17+
18+
```
19+
npm run test:unit
20+
```
21+
22+
## Integration Tests
23+
24+
Integration tests execute against a live neptune db cluster or graph and require
25+
the following prerequisites to run:
26+
27+
1. test dependencies installed by executing `npm install` from the `test`
28+
directory
29+
2. neptune db cluster or graph which is accessible from the machine running the
30+
tests and
31+
is [loaded with the airports sample dataset](#loading-airports-sample-data-into-neptune)
32+
3, AWS credentials configured appropriately on the machine running the tests
33+
to allow query access to the neptune db or cluster
34+
4. AWS IAM configured to allow creation of AWS resources necessary to deploy an
35+
App Sync API
36+
5. environment variables `AIR_ROUTES_DB_HOST` and `AIR_ROUTES_DB_PORT` set to
37+
identify the neptune db cluster or graph, for example:
38+
39+
```
40+
# neptune db cluster
41+
export AIR_ROUTES_DB_HOST=air-routes.cluster-123.us-west-2.neptune.amazonaws.com
42+
export AIR_ROUTES_DB_PORT=8182
43+
```
44+
45+
```
46+
# neptune analytics graph
47+
export AIR_ROUTES_DB_HOST=g-abc123.us-west-2.neptune-graph.amazonaws.com
48+
export AIR_ROUTES_DB_PORT=8182
49+
```
50+
51+
To execute the integration tests use the following command:
52+
53+
```
54+
npm run test:integration
55+
```
56+
57+
## Loading Airports Sample Data Into Neptune
58+
59+
The easiest way to load the airports sample data into Neptune is using
60+
the [%seed line magic](https://docs.aws.amazon.com/neptune/latest/userguide/notebooks-magics.html#notebooks-line-magics-seed)
61+
in a Neptune notebook. To set up a Neptune notebook
62+
see [Using Amazon Neptune with graph notebooks](https://docs.aws.amazon.com/neptune/latest/userguide/graph-notebooks.html)
63+
and [Using notebooks with Neptune Analytics](https://docs.aws.amazon.com/neptune-analytics/latest/userguide/notebooks.html).
64+
65+
66+
> [!TIP]
67+
> The integration tests expect neptune db clusters to be loaded with the
68+
> airports `gremlin` sample dataset and neptune analytics graphs to be loaded
69+
> with
70+
> the airports `opencypher` sample dataset (the gremlin airports dataset is not
71+
> available for neptune analytics).
72+
73+
![Seed Airport Data with Gremlin](doc/images/SeedAirportsGremlin.png)
74+
75+
![Seed Airport Data with Cypher](doc/images/SeedAirportsCypher.png)

doc/images/SeedAirportsCypher.png

20.4 KB
Loading

doc/images/SeedAirportsGremlin.png

23.1 KB
Loading
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "getAirport _id",
33
"description": "Get neptune _id",
4-
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n _id\n }\n }",
4+
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n code\n }\n }",
55
"result":{
6-
"_id": "22"
6+
"code": "SEA"
77
}
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "Type graph query 1",
33
"description": "Type with graph query returning a scalar",
4-
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n outboundRoutesCount\n }\n }\n",
4+
"graphql": "query MyQuery {\n getAirport(code: \"YYZ\") {\n outboundRoutesCount\n }\n }\n",
55
"result": {
6-
"outboundRoutesCount": 122
6+
"outboundRoutesCount": 195
77
}
88
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "graphQuery type",
3-
"description": "Query using a graphQuery returing a type",
4-
"graphql": "query MyQuery {\n getAirportConnection(fromCode: \"SEA\", country: \"US\", toCode: \"BLQ\") {\n city\n code\n }\n }\n",
3+
"description": "Query using a graphQuery returning a type",
4+
"graphql": "query MyQuery {\n getAirportConnection(fromCode: \"YKF\", country: \"US\", toCode: \"ORD\") {\n city\n code\n }\n }\n",
55
"result":{
6-
"code": "PHL",
7-
"city": "Philadelphia"
6+
"code": "YYC",
7+
"city": "Calgary"
88
}
99
}

test/TestCases/Case01/queries/Query0008.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "graphQuery Gremlin type",
33
"description": "Query using Gremlin returning a type",
4+
"neptuneType": "neptune-db",
45
"graphql": "query MyQuery {\n getAirportWithGremlin(code: \"SEA\") {\n _id\n city\n runways\n }\n }\n",
56
"result": {
67
"_id": "22",

test/TestCases/Case01/queries/Query0009.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "graphQuery Gremlin type array",
33
"description": "Query using Gremlin returning a type array",
4+
"neptuneType": "neptune-db",
45
"graphql": "query MyQuery {\n getContinentsWithGremlin {\n code\n }\n }\n",
56
"result": [
67
{

0 commit comments

Comments
 (0)