-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnixos-test.nix
34 lines (28 loc) · 1.23 KB
/
nixos-test.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ lib, pkgs, ... }: {
name = "peering-manager";
meta = with lib.maintainers; {
maintainers = [ yuka ];
};
nodes.machine = { ... }: {
services.peering-manager = {
enable = true;
secretKeyFile = pkgs.writeText "secret" ''
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
'';
};
environment.systemPackages = with pkgs; [ wanda wandaTestEnv bgpq4 ];
};
testScript = { nodes }: let
peeringmanagerUrl = "http://localhost:${toString nodes.machine.config.services.peering-manager.port}";
in ''
machine.start()
machine.wait_for_unit("peering-manager.target")
machine.wait_until_succeeds("journalctl --since -1m --unit peering-manager --grep Listening")
machine.succeed("peering-manager-manage createsuperuser --no-input --username admin --email [email protected]")
api_token=machine.succeed(
"peering-manager-manage shell -c \"from users.models import Token; from users.models import User; u=User.objects.get(email='[email protected]'); t = Token.objects.create(user=u); print(t.key)\""
).strip()
machine.succeed("PEERINGMANAGER_API_TOKEN=%s PEERINGMANAGER_URL=${peeringmanagerUrl} pytest ${pkgs.wanda.src}" % (api_token))
machine.shutdown()
'';
}