Skip to content

Commit

Permalink
ndc-test nix improvements and Chinook data fixes (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-chambers authored Apr 17, 2024
1 parent 2931b2c commit 93e0b09
Show file tree
Hide file tree
Showing 30 changed files with 155,495 additions and 46 deletions.
15 changes: 13 additions & 2 deletions arion-compose/project-ndc-test.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, config, ... }:

let
mongodb-port = "27017";
Expand All @@ -9,10 +9,21 @@ in
services = {
test = import ./service-connector.nix {
inherit pkgs;
command = "test";
command = ["test"];
# Record snapshots into the snapshots dir
# 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;
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
service.user = builtins.toString config.host.uid;
extra-volumes = [
# Mount the snapshots directory in the repo source tree into the container
# so that ndc-test can read/write in it
"./snapshots:/snapshots:rw"
];
};

mongodb = import ./service-mongodb.nix {
Expand Down
8 changes: 4 additions & 4 deletions arion-compose/service-connector.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
, port ? "7130"
, profile ? "dev" # Rust crate profile, usually either "dev" or "release"
, hostPort ? null
, command ? "serve"
, command ? ["serve"]
, configuration-dir ? ../fixtures/connector/sample_mflix
, database-uri ? "mongodb://mongodb/sample_mflix"
, service ? { } # additional options to customize this service configuration
, otlp-endpoint ? null
, extra-volumes ? [],
}:

let
Expand All @@ -26,8 +27,7 @@ let
command = [
# mongodb-connector is added to pkgs via an overlay in flake.nix
"${connector-pkg}/bin/mongodb-connector"
command
];
] ++ command;
ports = pkgs.lib.optionals (hostPort != null) [
"${hostPort}:${port}" # host:container
];
Expand All @@ -41,7 +41,7 @@ let
};
volumes = [
"${configuration-dir}:/configuration:ro"
];
] ++ extra-volumes;
healthcheck = {
test = [ "CMD" "${pkgs.pkgsCross.linux.curl}/bin/curl" "-f" "http://localhost:${port}/health" ];
start_period = "5s";
Expand Down
2 changes: 1 addition & 1 deletion fixtures/connector/chinook/schema/Employee.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"ReportsTo": {
"type": {
"nullable": {
"scalar": "string"
"scalar": "int"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions fixtures/connector/chinook/schema/Invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"Total": {
"type": {
"scalar": "double"
"scalar": "decimal"
}
},
"_id": {
Expand All @@ -72,4 +72,4 @@
"description": "Object type for collection Invoice"
}
}
}
}
4 changes: 2 additions & 2 deletions fixtures/connector/chinook/schema/InvoiceLine.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"UnitPrice": {
"type": {
"scalar": "double"
"scalar": "decimal"
}
},
"_id": {
Expand All @@ -42,4 +42,4 @@
"description": "Object type for collection InvoiceLine"
}
}
}
}
4 changes: 2 additions & 2 deletions fixtures/connector/chinook/schema/Track.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"UnitPrice": {
"type": {
"scalar": "double"
"scalar": "decimal"
}
},
"_id": {
Expand All @@ -70,4 +70,4 @@
"description": "Object type for collection Track"
}
}
}
}
Loading

0 comments on commit 93e0b09

Please sign in to comment.