这是indexloc提供的服务,不要输入任何密码
Skip to content

switch default arion project to use sample_mflix db instead of chinook #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 12, 2024
Merged
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
1 change: 1 addition & 0 deletions arion-compose/fixtures-mongodb.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# MongoDB fixtures in the form of docker volume mounting strings
{
all-fixtures = "${toString ./..}/fixtures/mongodb:/docker-entrypoint-initdb.d:ro";
chinook = "${toString ./..}/fixtures/mongodb/chinook:/docker-entrypoint-initdb.d:ro";
}
17 changes: 11 additions & 6 deletions arion-compose/project-connector.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@

{ pkgs, ... }:
let
connector-port = "7130";
connector = "7130";
engine-port = "7100";
mongodb-port = "27017";
in
{
project.name = "mongodb-connector";

services = {
connector = import ./service-mongodb-connector.nix {
connector = import ./service-connector.nix {
inherit pkgs;
port = connector-port;
hostPort = connector-port;
configuration-dir = ../fixtures/connector/sample_mflix;
database-uri = "mongodb://mongodb/sample_mflix";
port = connector;
hostPort = connector;
otlp-endpoint = "http://jaeger:4317";
service.depends_on = {
jaeger.condition = "service_healthy";
mongodb.condition = "service_healthy";
};
};

Expand All @@ -30,15 +33,17 @@ in
hostPort = mongodb-port;
volumes = [
"mongodb:/data/db"
(import ./fixtures-mongodb.nix).chinook
(import ./fixtures-mongodb.nix).all-fixtures
];
};

engine = import ./service-engine.nix {
inherit pkgs;
port = engine-port;
hostPort = engine-port;
connector-url = "http://connector:${connector-port}";
connectors = [
{ name = "sample_mflix"; url = "http://connector:${connector}"; subgraph = ../fixtures/ddn/subgraphs/sample_mflix; }
];
otlp-endpoint = "http://jaeger:4317";
service.depends_on = {
auth-hook.condition = "service_started";
Expand Down
6 changes: 4 additions & 2 deletions arion-compose/project-e2e-testing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ in
};
};

connector = import ./service-mongodb-connector.nix {
connector = import ./service-connector.nix {
inherit pkgs;
configuration-dir = ../fixtures/connector/chinook;
database-uri = "mongodb://mongodb/chinook";
port = connector-port;
service.depends_on.mongodb.condition = "service_healthy";
};
Expand All @@ -35,7 +37,7 @@ in
engine = import ./service-engine.nix {
inherit pkgs;
port = engine-port;
connector-url = "http://connector:${connector-port}";
connectors = [{ name = "chinook"; url = "http://connector:${connector-port}"; subgraph = ../fixtures/ddn/subgraphs/chinook; }];
service.depends_on = {
auth-hook.condition = "service_started";
};
Expand Down
6 changes: 5 additions & 1 deletion arion-compose/project-ndc-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ in
project.name = "mongodb-ndc-test";

services = {
test = import ./service-mongodb-connector.nix {
test = import ./service-connector.nix {
inherit pkgs;
command = "test";
configuration-dir = ../fixtures/connector/chinook;
database-uri = "mongodb://mongodb:${mongodb-port}/chinook";
service.depends_on.mongodb.condition = "service_healthy";
};

mongodb = import ./service-mongodb.nix {
inherit pkgs;
port = mongodb-port;
volumes = [
(import ./fixtures-mongodb.nix).chinook
];
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
, profile ? "dev" # Rust crate profile, usually either "dev" or "release"
, hostPort ? null
, command ? "serve"
, configuration-dir ? ../fixtures/connector/chinook
, database-uri ? "mongodb://mongodb/chinook"
, configuration-dir ? ../fixtures/connector/sample_mflix
, database-uri ? "mongodb://mongodb/sample_mflix"
, service ? { } # additional options to customize this service configuration
, otlp-endpoint ? null
}:
Expand Down
20 changes: 14 additions & 6 deletions arion-compose/service-engine.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ pkgs
, port ? "7100"
, hostPort ? null
, connector-url ? "http://connector:7130"
, ddn-subgraph-dir ? ../fixtures/ddn/subgraphs/chinook
, connectors ? [{ name = "sample_mflix"; url = "http://connector:7130"; subgraph = ../fixtures/ddn/subgraphs/sample_mflix; }]
, auth-webhook ? { url = "http://auth-hook:3050/validate-request"; }
, otlp-endpoint ? "http://jaeger:4317"
, service ? { } # additional options to customize this service configuration
Expand All @@ -12,8 +11,8 @@ let
# Compile JSON metadata from HML fixture
metadata = pkgs.stdenv.mkDerivation {
name = "hasura-metadata.json";
src = ddn-subgraph-dir;
nativeBuildInputs = with pkgs; [ jq yq-go ];
src = (builtins.head connectors).subgraph;
nativeBuildInputs = with pkgs; [ findutils jq yq-go ];

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

Expand All @@ -37,6 +37,14 @@ let
'';
};

# Pipe commands to replace data connector urls in fixture configuration with
# urls of dockerized connector instances
connector-url-substituters = builtins.toString (builtins.map
({ name, url, ... }:
'' | jq 'if .kind == "DataConnectorLink" and .definition.name == "${name}" then .definition.url = { singleUrl: { value: "${url}" } } else . end' ''
)
connectors);

auth-config = pkgs.writeText "auth_config.json" (builtins.toJSON {
version = "v1";
definition = {
Expand Down
44 changes: 44 additions & 0 deletions fixtures/connector/sample_mflix/schema/comments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "comments",
"collections": {
"comments": {
"type": "comments"
}
},
"objectTypes": {
"comments": {
"fields": {
"_id": {
"type": {
"scalar": "objectId"
}
},
"date": {
"type": {
"scalar": "date"
}
},
"email": {
"type": {
"scalar": "string"
}
},
"movie_id": {
"type": {
"scalar": "objectId"
}
},
"name": {
"type": {
"scalar": "string"
}
},
"text": {
"type": {
"scalar": "string"
}
}
}
}
}
}
Loading