Skip to content

Commit 604f4fc

Browse files
authored
switch default arion project to use sample_mflix db instead of chinook (#35)
This means that when you run `arion up -d` you get the sample_mflix database. This database is better for document-oriented testing because it includes object and array values within documents. Relationships and native procedures are not configured yet. I started setting things up so we can use both databases via two connector instances. We'll have to set up a supergraph with namespaces if we want to finish that. The ndc-test and e2e test arion projects still use chinook.
1 parent 4274be1 commit 604f4fc

33 files changed

Lines changed: 2615 additions & 58 deletions

arion-compose/fixtures-mongodb.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# MongoDB fixtures in the form of docker volume mounting strings
22
{
3+
all-fixtures = "${toString ./..}/fixtures/mongodb:/docker-entrypoint-initdb.d:ro";
34
chinook = "${toString ./..}/fixtures/mongodb/chinook:/docker-entrypoint-initdb.d:ro";
45
}

arion-compose/project-connector.nix

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66

77
{ pkgs, ... }:
88
let
9-
connector-port = "7130";
9+
connector = "7130";
1010
engine-port = "7100";
1111
mongodb-port = "27017";
1212
in
1313
{
1414
project.name = "mongodb-connector";
1515

1616
services = {
17-
connector = import ./service-mongodb-connector.nix {
17+
connector = import ./service-connector.nix {
1818
inherit pkgs;
19-
port = connector-port;
20-
hostPort = connector-port;
19+
configuration-dir = ../fixtures/connector/sample_mflix;
20+
database-uri = "mongodb://mongodb/sample_mflix";
21+
port = connector;
22+
hostPort = connector;
2123
otlp-endpoint = "http://jaeger:4317";
2224
service.depends_on = {
2325
jaeger.condition = "service_healthy";
26+
mongodb.condition = "service_healthy";
2427
};
2528
};
2629

@@ -30,15 +33,17 @@ in
3033
hostPort = mongodb-port;
3134
volumes = [
3235
"mongodb:/data/db"
33-
(import ./fixtures-mongodb.nix).chinook
36+
(import ./fixtures-mongodb.nix).all-fixtures
3437
];
3538
};
3639

3740
engine = import ./service-engine.nix {
3841
inherit pkgs;
3942
port = engine-port;
4043
hostPort = engine-port;
41-
connector-url = "http://connector:${connector-port}";
44+
connectors = [
45+
{ name = "sample_mflix"; url = "http://connector:${connector}"; subgraph = ../fixtures/ddn/subgraphs/sample_mflix; }
46+
];
4247
otlp-endpoint = "http://jaeger:4317";
4348
service.depends_on = {
4449
auth-hook.condition = "service_started";

arion-compose/project-e2e-testing.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ in
1818
};
1919
};
2020

21-
connector = import ./service-mongodb-connector.nix {
21+
connector = import ./service-connector.nix {
2222
inherit pkgs;
23+
configuration-dir = ../fixtures/connector/chinook;
24+
database-uri = "mongodb://mongodb/chinook";
2325
port = connector-port;
2426
service.depends_on.mongodb.condition = "service_healthy";
2527
};
@@ -35,7 +37,7 @@ in
3537
engine = import ./service-engine.nix {
3638
inherit pkgs;
3739
port = engine-port;
38-
connector-url = "http://connector:${connector-port}";
40+
connectors = [{ name = "chinook"; url = "http://connector:${connector-port}"; subgraph = ../fixtures/ddn/subgraphs/chinook; }];
3941
service.depends_on = {
4042
auth-hook.condition = "service_started";
4143
};

arion-compose/project-ndc-test.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ in
77
project.name = "mongodb-ndc-test";
88

99
services = {
10-
test = import ./service-mongodb-connector.nix {
10+
test = import ./service-connector.nix {
1111
inherit pkgs;
1212
command = "test";
13+
configuration-dir = ../fixtures/connector/chinook;
1314
database-uri = "mongodb://mongodb:${mongodb-port}/chinook";
1415
service.depends_on.mongodb.condition = "service_healthy";
1516
};
1617

1718
mongodb = import ./service-mongodb.nix {
1819
inherit pkgs;
1920
port = mongodb-port;
21+
volumes = [
22+
(import ./fixtures-mongodb.nix).chinook
23+
];
2024
};
2125
};
2226
}

arion-compose/service-mongodb-connector.nix renamed to arion-compose/service-connector.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
, profile ? "dev" # Rust crate profile, usually either "dev" or "release"
1313
, hostPort ? null
1414
, command ? "serve"
15-
, configuration-dir ? ../fixtures/connector/chinook
16-
, database-uri ? "mongodb://mongodb/chinook"
15+
, configuration-dir ? ../fixtures/connector/sample_mflix
16+
, database-uri ? "mongodb://mongodb/sample_mflix"
1717
, service ? { } # additional options to customize this service configuration
1818
, otlp-endpoint ? null
1919
}:

arion-compose/service-engine.nix

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{ pkgs
22
, port ? "7100"
33
, hostPort ? null
4-
, connector-url ? "http://connector:7130"
5-
, ddn-subgraph-dir ? ../fixtures/ddn/subgraphs/chinook
4+
, connectors ? [{ name = "sample_mflix"; url = "http://connector:7130"; subgraph = ../fixtures/ddn/subgraphs/sample_mflix; }]
65
, auth-webhook ? { url = "http://auth-hook:3050/validate-request"; }
76
, otlp-endpoint ? "http://jaeger:4317"
87
, service ? { } # additional options to customize this service configuration
@@ -12,8 +11,8 @@ let
1211
# Compile JSON metadata from HML fixture
1312
metadata = pkgs.stdenv.mkDerivation {
1413
name = "hasura-metadata.json";
15-
src = ddn-subgraph-dir;
16-
nativeBuildInputs = with pkgs; [ jq yq-go ];
14+
src = (builtins.head connectors).subgraph;
15+
nativeBuildInputs = with pkgs; [ findutils jq yq-go ];
1716

1817
# The yq command converts the input sequence of yaml docs to a sequence of
1918
# newline-separated json docs.
@@ -22,13 +21,14 @@ let
2221
# switch), and modifies the json to update the data connector url.
2322
buildPhase = ''
2423
combined=$(mktemp -t subgraph-XXXXXX.hml)
25-
for obj in **/*.hml; do
24+
for obj in $(find . -name '*hml'); do
2625
echo "---" >> "$combined"
2726
cat "$obj" >> "$combined"
2827
done
2928
cat "$combined" \
3029
| yq -o=json \
31-
| jq -s 'map(if .kind == "DataConnectorLink" then .definition.url = { singleUrl: { value: "${connector-url}" } } else . end) | map(select(type != "null"))' \
30+
${connector-url-substituters} \
31+
| jq -s 'map(select(type != "null"))' \
3232
> metadata.json
3333
'';
3434

@@ -37,6 +37,14 @@ let
3737
'';
3838
};
3939

40+
# Pipe commands to replace data connector urls in fixture configuration with
41+
# urls of dockerized connector instances
42+
connector-url-substituters = builtins.toString (builtins.map
43+
({ name, url, ... }:
44+
'' | jq 'if .kind == "DataConnectorLink" and .definition.name == "${name}" then .definition.url = { singleUrl: { value: "${url}" } } else . end' ''
45+
)
46+
connectors);
47+
4048
auth-config = pkgs.writeText "auth_config.json" (builtins.toJSON {
4149
version = "v1";
4250
definition = {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "comments",
3+
"collections": {
4+
"comments": {
5+
"type": "comments"
6+
}
7+
},
8+
"objectTypes": {
9+
"comments": {
10+
"fields": {
11+
"_id": {
12+
"type": {
13+
"scalar": "objectId"
14+
}
15+
},
16+
"date": {
17+
"type": {
18+
"scalar": "date"
19+
}
20+
},
21+
"email": {
22+
"type": {
23+
"scalar": "string"
24+
}
25+
},
26+
"movie_id": {
27+
"type": {
28+
"scalar": "objectId"
29+
}
30+
},
31+
"name": {
32+
"type": {
33+
"scalar": "string"
34+
}
35+
},
36+
"text": {
37+
"type": {
38+
"scalar": "string"
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)