Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ export default {
'transform': {},
'verbose': true,
'testSequencer': './test/jestTestSequencer.js',
'testPathIgnorePatterns': [
'/node_modules/',
// tests below are intended to be executed manually
'.*\\.manual\\.test\\.js$'
],
'globals': {
// neptune db that has pre-loaded air routes sample data host and port
// ex. db-neptune-foo-bar.cluster-abc.us-west-2.neptune.amazonaws.com
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ permissions and limitations under the License.
* Allow credentials to be refreshed at Apollo runtime by passing the credential
provider to the
interceptor ([#134](https://github.com/aws/amazon-neptune-for-graphql/pull/134))
* Added manually executed query integration test suites for App Sync and
Apollo ([#138](https://github.com/aws/amazon-neptune-for-graphql/pull/138))

### Bug Fixes

Expand Down
74 changes: 73 additions & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ the following command:
npm run test:unit
```

## Integration Tests
## Automated Integration Tests

Integration tests execute against a live neptune db cluster or graph and require
the following prerequisites to run:
Expand Down Expand Up @@ -54,6 +54,78 @@ To execute the integration tests use the following command:
npm run test:integration
```

## Manual Integration Tests

In addition to the automated integration tests, there are manual integration
tests that can be run against live AWS AppSync APIs and Apollo Server instances
that were deployed via the Amazon Neptune Utility for GraphQL. These tests are
useful for validating deployed GraphQL APIs that are interfacing Neptune db or
analytics graphs loaded with the airports sample data.

### AppSync Manual Tests

These tests execute queries against a deployed AWS AppSync API:

#### Standard AppSync Queries

```
npm run test:manual -- test/appSyncAirRoutesQueries.manual.test.js
```

#### Custom AppSync Queries

```
npm run test:manual -- test/appSyncCustomAirRoutesQueries.manual.test.js
```

#### All AppSync Queries

```
npm run test:manual -- test/appSync*.manual.test.js
```

**Prerequisites for AppSync tests:**

- Set environment variables:
```
export APP_SYNC_API_ID=your-appsync-api-id
export APP_SYNC_API_KEY=your-api-key
export APP_SYNC_REGION=your-aws-region
```

### Apollo Server Manual Tests

These tests execute queries against a local Apollo Server instance:

#### Standard Apollo Queries

```
npm run test:manual -- test/apolloAirRoutesQueries.manual.test.js
```

#### Custom Apollo Queries

```
npm run test:manual -- test/apolloCustomAirRoutesQueries.manual.test.js
```

#### All Apollo Queries

```
npm run test:manual -- test/apollo*.manual.test.js
```

### Test Query Suites

Both test suites use JSON files containing GraphQL queries and expected results:

- **`air-routes-queries.json`**: Standard queries including filters, sorting,
pagination, variables, and fragments
- **`custom-air-routes-queries.json`**: Custom queries using `@graphQuery`
directives, Gremlin queries, and custom field resolvers. These queries assume
that the utility was executed with option
`--input-schema-changes-file ./test/air-routes-changes.json`

## Loading Airports Sample Data Into Neptune

The easiest way to load the airports sample data into Neptune is using
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --detectOpenHandles --config .jest.js --testPathPattern=src/test",
"test:integration": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --detectOpenHandles --config .jest.js --testPathPattern=test/TestCases",
"test:sdk": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --detectOpenHandles --config .jest.js --testPathPattern=test/TestCases/Case07",
"test:resolver": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --detectOpenHandles --config .jest.js --testPathPattern=test/TestCases/Case01"
"test:resolver": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --runInBand --detectOpenHandles --config .jest.js --testPathPattern=test/TestCases/Case01",
"test:manual": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
},
"jest": {
"collectCoverage": true,
Expand Down
2 changes: 1 addition & 1 deletion test/TestCases/Case01/queries/Query0002.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "getAirport _id",
"description": "Get neptune _id",
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n code\n }\n }",
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"SEA\"}}) {\n code\n }\n }",
"result":{
"code": "SEA"
}
Expand Down
2 changes: 1 addition & 1 deletion test/TestCases/Case01/queries/Query0003.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "3",
"name": "getAirport nested type",
"description": "Nested types single and array, references in and out",
"graphql": "query MyQuery {\n getAirport(code: \"YKM\") {\n city\n continentContainsIn {\n desc\n }\n countryContainsIn {\n desc\n }\n airportRoutesOut {\n code\n }\n }\n }",
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"YKM\"}}) {\n city\n continentContainsIn {\n desc\n }\n countryContainsIn {\n desc\n }\n airportRoutesOut {\n code\n }\n }\n }",
"result":{
"airportRoutesOut": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/TestCases/Case01/queries/Query0004.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Edge properties 2",
"description": "Get edge properties in nested array",
"graphql": "query MyQuery {\n getAirport(code: \"SEA\") {\n airportRoutesOut {\n code\n route {\n dist\n }\n }\n }\n }\n",
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"SEA\"}}) {\n airportRoutesOut {\n code\n route {\n dist\n }\n }\n }\n }\n",
"result": {
"airportRoutesOut": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/TestCases/Case01/queries/Query0005.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Type graph query 1",
"description": "Type with graph query returning a scalar",
"graphql": "query MyQuery {\n getAirport(code: \"YYZ\") {\n outboundRoutesCount\n }\n }\n",
"graphql": "query MyQuery {\n getAirport(filter: {code: {eq: \"YYZ\"}}) {\n outboundRoutesCount\n }\n }\n",
"result": {
"outboundRoutesCount": 195
}
Expand Down
38 changes: 38 additions & 0 deletions test/air-routes-changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"type": "Airport",
"field": "outboundRoutesCount",
"action": "add",
"value": "outboundRoutesCount: Int @graphQuery(statement: \"MATCH (this)-[r:route]->(a) RETURN count(r)\")"
},
{
"type": "Query",
"field": "getAirportWithGremlin",
"action": "add",
"value": "getAirportWithGremlin(code:String): Airport @graphQuery(statement: \"g.V().has('airport', 'code', '$code').elementMap()\")"
},
{
"type": "Query",
"field": "getContinentsWithGremlin",
"action": "add",
"value": "getContinentsWithGremlin: [Continent] @cypher(statement: \"g.V().hasLabel('continent').order().elementMap().fold()\")"
},
{
"type": "Query",
"field": "getAirportByCode",
"action": "add",
"value": "getAirportByCode(code:String): Airport @graphQuery(statement: \"MATCH (this: airport {code: '$code'})\")"
},
{
"type": "Query",
"field": "getCountriesCountGremlin",
"action": "add",
"value": "getCountriesCountGremlin: Int @graphQuery(statement: \"g.V().hasLabel('country').count()\")"
},
{
"type": "Query",
"field": "getAirportConnection",
"action": "add",
"value": "getAirportConnection(fromCode: String!, toCode: String!): Airport @cypher(statement: \"MATCH (:airport{code: '$fromCode'})-[:route]->(this:airport)-[:route]->(:airport{code:'$toCode'})\")"
}
]
Loading