nixos/tests: add osrm-backend test
This commit is contained in:
parent
bae9fd59a9
commit
694c351cc3
|
@ -158,6 +158,7 @@ in
|
|||
opensmtpd = handleTest ./opensmtpd.nix {};
|
||||
openssh = handleTest ./openssh.nix {};
|
||||
osquery = handleTest ./osquery.nix {};
|
||||
osrm-backend = handleTest ./osrm-backend.nix {};
|
||||
ostree = handleTest ./ostree.nix {};
|
||||
pam-oath-login = handleTest ./pam-oath-login.nix {};
|
||||
peerflix = handleTest ./peerflix.nix {};
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
import ./make-test.nix ({ pkgs, lib, ... }:
|
||||
let
|
||||
port = 5000;
|
||||
in {
|
||||
name = "osrm-backend";
|
||||
meta.maintainers = [ lib.maintainers.erictapen ];
|
||||
|
||||
machine = { config, pkgs, ... }:{
|
||||
|
||||
services.osrm = {
|
||||
enable = true;
|
||||
inherit port;
|
||||
dataFile = let
|
||||
filename = "monaco";
|
||||
osrm-data = pkgs.stdenv.mkDerivation {
|
||||
name = "osrm-data";
|
||||
|
||||
buildInputs = [ pkgs.osrm-backend ];
|
||||
|
||||
# This is a pbf file of monaco, downloaded at 2019-01-04 from
|
||||
# http://download.geofabrik.de/europe/monaco-latest.osm.pbf
|
||||
# as apparently no provider of OSM files guarantees immutability,
|
||||
# this is hosted as a gist on GitHub.
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://gist.github.com/erictapen/01e39f73a6c856eac53ba809a94cdb83";
|
||||
rev = "9b1ff0f24deb40e5cf7df51f843dbe860637b8ce";
|
||||
sha256 = "1scqhmrfnpwsy5i2a9jpggqnvfgj4hv9p4qyvc79321pzkbv59nx";
|
||||
};
|
||||
|
||||
buildCommand = ''
|
||||
cp $src/${filename}.osm.pbf .
|
||||
${pkgs.osrm-backend}/bin/osrm-extract -p ${pkgs.osrm-backend}/share/osrm/profiles/car.lua ${filename}.osm.pbf
|
||||
${pkgs.osrm-backend}/bin/osrm-partition ${filename}.osrm
|
||||
${pkgs.osrm-backend}/bin/osrm-customize ${filename}.osrm
|
||||
mkdir -p $out
|
||||
cp ${filename}* $out/
|
||||
'';
|
||||
};
|
||||
in "${osrm-data}/${filename}.osrm";
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
};
|
||||
|
||||
testScript = let
|
||||
query = "http://localhost:${toString port}/route/v1/driving/7.41720,43.73304;7.42463,43.73886?steps=true";
|
||||
in ''
|
||||
$machine->waitForUnit("osrm.service");
|
||||
$machine->waitForOpenPort(${toString port});
|
||||
$machine->succeed("curl --silent '${query}' | jq .waypoints[0].name | grep -F 'Boulevard Rainier III'");
|
||||
$machine->succeed("curl --silent '${query}' | jq .waypoints[1].name | grep -F 'Avenue de la Costa'");
|
||||
'';
|
||||
})
|
Loading…
Reference in New Issue