Skip to content

Commit

Permalink
update integration fixtures to work with latest cli (#88)
Browse files Browse the repository at this point in the history
I reorganized and updated the ddn and connector configuration fixtures used in integration tests to match the structure used by the ddn cli. This lets us use commands like `ddn connector introspect` to update connector configuration, and `ddn connector-link update` to update subgraphs.

The fixtures are tied to the arion services, so those commands will work after running services with `arion up -d`.

I added `fixtures/hasura/README.md` with the exact commands to run for updates.
  • Loading branch information
hallettj authored Jul 11, 2024
1 parent 84c9a6d commit 9662c96
Show file tree
Hide file tree
Showing 96 changed files with 786 additions and 266 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.hml linguist-language=yaml
4 changes: 2 additions & 2 deletions arion-compose/e2e-testing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ in

connector = import ./services/connector.nix {
inherit pkgs;
configuration-dir = ../fixtures/connector/chinook;
configuration-dir = ../fixtures/hasura/chinook/connector/chinook;
database-uri = "mongodb://mongodb/chinook";
port = connector-port;
service.depends_on.mongodb.condition = "service_healthy";
Expand All @@ -38,7 +38,7 @@ in
inherit pkgs;
port = engine-port;
connectors.chinook = "http://connector:${connector-port}";
ddn-dirs = [ ../fixtures/ddn/chinook ];
ddn-dirs = [ ../fixtures/hasura/chinook/metadata ];
service.depends_on = {
auth-hook.condition = "service_started";
};
Expand Down
10 changes: 5 additions & 5 deletions arion-compose/integration-test-services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in
{
connector = import ./services/connector.nix {
inherit pkgs otlp-endpoint;
configuration-dir = ../fixtures/connector/sample_mflix;
configuration-dir = ../fixtures/hasura/sample_mflix/connector/sample_mflix;
database-uri = "mongodb://mongodb/sample_mflix";
port = connector-port;
hostPort = hostPort connector-port;
Expand All @@ -32,7 +32,7 @@ in

connector-chinook = import ./services/connector.nix {
inherit pkgs otlp-endpoint;
configuration-dir = ../fixtures/connector/chinook;
configuration-dir = ../fixtures/hasura/chinook/connector/chinook;
database-uri = "mongodb://mongodb/chinook";
port = connector-chinook-port;
hostPort = hostPort connector-chinook-port;
Expand Down Expand Up @@ -62,9 +62,9 @@ in
sample_mflix = "http://connector:${connector-port}";
};
ddn-dirs = [
../fixtures/ddn/chinook
../fixtures/ddn/sample_mflix
../fixtures/ddn/remote-relationships_chinook-sample_mflix
../fixtures/hasura/chinook/metadata
../fixtures/hasura/sample_mflix/metadata
../fixtures/hasura/common/metadata
];
service.depends_on = {
auth-hook.condition = "service_started";
Expand Down
2 changes: 1 addition & 1 deletion arion-compose/ndc-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in
# command = ["test" "--snapshots-dir" "/snapshots" "--seed" "1337_1337_1337_1337_1337_1337_13"];
# Replay and test the recorded snapshots
# command = ["replay" "--snapshots-dir" "/snapshots"];
configuration-dir = ../fixtures/connector/chinook;
configuration-dir = ../fixtures/hasura/chinook/connector/chinook;
database-uri = "mongodb://mongodb:${mongodb-port}/chinook";
service.depends_on.mongodb.condition = "service_healthy";
# Run the container as the current user so when it writes to the snapshots directory it doesn't write as root
Expand Down
2 changes: 1 addition & 1 deletion arion-compose/services/connector.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
, profile ? "dev" # Rust crate profile, usually either "dev" or "release"
, hostPort ? null
, command ? ["serve"]
, configuration-dir ? ../../fixtures/connector/sample_mflix
, configuration-dir ? ../../fixtures/hasura/sample_mflix/connector/sample_mflix
, database-uri ? "mongodb://mongodb/sample_mflix"
, service ? { } # additional options to customize this service configuration
, otlp-endpoint ? null
Expand Down
3 changes: 2 additions & 1 deletion arion-compose/services/engine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# a `DataConnectorLink.definition.name` value in one of the given `ddn-dirs`
# to correctly match up configuration to connector instances.
, connectors ? { sample_mflix = "http://connector:7130"; }
, ddn-dirs ? [ ../../fixtures/ddn/subgraphs/sample_mflix ]
, ddn-dirs ? [ ../../fixtures/hasura/sample_mflix/metadata ]
, auth-webhook ? { url = "http://auth-hook:3050/validate-request"; }
, otlp-endpoint ? "http://jaeger:4317"
, service ? { } # additional options to customize this service configuration
Expand Down Expand Up @@ -65,6 +65,7 @@ let
auth-config = pkgs.writeText "auth_config.json" (builtins.toJSON {
version = "v1";
definition = {
allowRoleEmulationBy = "admin";
mode.webhook = {
url = auth-webhook.url;
method = "Post";
Expand Down
17 changes: 17 additions & 0 deletions fixtures/hasura/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"customizations": {
"vscode": {
"extensions": [
"HasuraHQ.hasura"
],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"terminal.integrated.shellArgs.linux": [
"-l"
]
}
}
},
"name": "Hasura DDN Codespace",
"postCreateCommand": "curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v2/get.sh | bash"
}
2 changes: 2 additions & 0 deletions fixtures/hasura/.hasura/context.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
context:
supergraph: ../supergraph.yaml
5 changes: 5 additions & 0 deletions fixtures/hasura/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"HasuraHQ.hasura"
]
}
13 changes: 13 additions & 0 deletions fixtures/hasura/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"configurations": [
{
"cwd": "${workspaceFolder}",
"name": "DDN Dev",
"preLaunchTask": "dev",
"program": "${workspaceFolder}",
"request": "launch",
"type": "node"
}
],
"version": "0.2.0"
}
26 changes: 26 additions & 0 deletions fixtures/hasura/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"tasks": [
{
"args": [
"watch",
"--dir",
"."
],
"command": "ddn",
"label": "watch",
"options": {
"cwd": "${workspaceFolder}"
},
"presentation": {
"clear": true,
"close": false,
"focus": true,
"panel": "new",
"reveal": "always"
},
"problemMatcher": [],
"type": "shell"
}
],
"version": "2.0.0"
}
35 changes: 35 additions & 0 deletions fixtures/hasura/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# MongoDB Connector Hasura fixtures

This directory contains example DDN and connector configuration which is used to
run integration tests in this repo, and supports local development.

Instead of having docker compose configurations in this directory, supporting
services are run using arion configurations defined at the top level of the
repo. Before running ddn commands bring up services with:

```sh
arion up -d
```

## Cheat Sheet

We have two subgraphs, and two connector configurations. So a lot of these
commands are repeated for each subgraph + connector combination.

Run introspection to update connector configuration:

```sh
$ ddn connector introspect --connector sample_mflix/connector/sample_mflix/connector.yaml

$ ddn connector introspect --connector chinook/connector/chinook/connector.yaml
```

Update Hasura metadata based on connector configuration
(after restarting connectors with `arion up -d` if there were changes from
introspection):

```sh
$ ddn connector-link update sample_mflix --subgraph sample_mflix/subgraph.yaml --env-file sample_mflix/.env.sample_mflix --add-all-resources

$ ddn connector-link update chinook --subgraph chinook/subgraph.yaml --env-file chinook/.env.chinook --add-all-resources
```
1 change: 1 addition & 0 deletions fixtures/hasura/chinook/.env.chinook
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHINOOK_CONNECTOR_URL='http://localhost:7131'
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/hasura/chinook/connector/chinook/.ddnignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
1 change: 1 addition & 0 deletions fixtures/hasura/chinook/connector/chinook/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGODB_DATABASE_URI="mongodb://localhost/chinook"
7 changes: 7 additions & 0 deletions fixtures/hasura/chinook/connector/chinook/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"introspectionOptions": {
"sampleSize": 100,
"noValidatorSchema": false,
"allSchemaNullable": false
}
}
8 changes: 8 additions & 0 deletions fixtures/hasura/chinook/connector/chinook/connector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: Connector
version: v1
definition:
name: chinook
subgraph: chinook
source: hasura/mongodb:v0.1.0
context: .
envFile: .env
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,43 @@ definition:
dataConnectorScalarType: Int
representation: Int
graphql:
comparisonExpressionTypeName: IntComparisonExp
comparisonExpressionTypeName: Chinook_IntComparisonExp

---
kind: ScalarType
version: v1
definition:
name: Chinook_Double
graphql:
typeName: Chinook_Double

---
kind: DataConnectorScalarRepresentation
version: v1
definition:
dataConnectorName: chinook
dataConnectorScalarType: Double
representation: Double
graphql:
comparisonExpressionTypeName: Chinook_DoubleComparisonExp

---
kind: ScalarType
version: v1
definition:
name: Decimal
graphql:
typeName: Chinook_Decimal

---
kind: DataConnectorScalarRepresentation
version: v1
definition:
dataConnectorName: chinook
dataConnectorScalarType: Decimal
representation: Decimal
graphql:
comparisonExpressionTypeName: Chinook_DecimalComparisonExp

---
kind: DataConnectorScalarRepresentation
Expand All @@ -34,7 +70,7 @@ definition:
dataConnectorScalarType: String
representation: String
graphql:
comparisonExpressionTypeName: StringComparisonExp
comparisonExpressionTypeName: Chinook_StringComparisonExp

---
kind: ScalarType
Expand All @@ -54,12 +90,3 @@ definition:
graphql:
comparisonExpressionTypeName: Chinook_ExtendedJsonComparisonExp

---
kind: DataConnectorScalarRepresentation
version: v1
definition:
dataConnectorName: chinook
dataConnectorScalarType: Float
representation: Float
graphql:
comparisonExpressionTypeName: FloatComparisonExp
Loading

0 comments on commit 9662c96

Please sign in to comment.