This repository has been archived by the owner on Apr 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
all-in-one.nix
80 lines (65 loc) · 2.89 KB
/
all-in-one.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{ pkgs
, contrailPkgs
# If not set, contrail32 or contrailMaster test scripts are used.
, testScript ? null
}:
with import (pkgs.path + /nixos/lib/testing.nix) { system = builtins.currentSystem; };
with pkgs.lib;
let
machine = { config, ...}: {
imports = [ ../modules/all-in-one.nix ];
config = {
# include pkgs to have access to tools overlay
_module.args = { inherit pkgs contrailPkgs; };
virtualisation = { memorySize = 4096; cores = 2; };
environment.systemPackages = with pkgs; [
# Used by the test suite
jq
contrailApiCliWithExtra
contrailPkgs.configUtils
];
contrail.allInOne = {
enable = true;
vhostInterface = "eth1";
vhostGateway = "10.0.2.2";
};
};
};
contrailTestScript = ''
$machine->waitForUnit("cassandra.service");
$machine->waitForUnit("rabbitmq.service");
$machine->waitForUnit("zookeeper.service");
$machine->waitForUnit("redis.service");
'' + optionalString contrailPkgs.isContrail32 ''
$machine->waitForUnit("contrail-discovery.service");
'' + ''
$machine->waitForUnit("contrail-api.service");
$machine->waitForUnit("contrail-svc-monitor.service");
$machine->waitForUnit("contrail-schema-transformer.service");
$machine->waitForUnit("contrail-analytics-api.service");
$machine->waitForUnit("contrail-collector.service");
$machine->waitForUnit("contrail-control.service");
'' + optionalString contrailPkgs.isContrail32 ''
# check services state
my @services = qw(ApiServer IfmapServer Collector OpServer xmpp-server);
foreach my $service (@services)
{
$machine->waitUntilSucceeds(sprintf("curl -s localhost:5998/services.json | jq -e '.services[] | select(.service_type == \"%s\" and .oper_state == \"up\")'", $service));
}
'' + ''
$machine->succeed("lsmod | grep -q vrouter");
$machine->waitForUnit("contrail-vrouter-agent.service");
$machine->waitUntilSucceeds("curl http://localhost:8083/Snh_ShowBgpNeighborSummaryReq | grep machine | grep -q Established");
$machine->waitUntilSucceeds("curl -s localhost:8081/analytics/uves/vrouter/*?cfilt=NodeStatus:process_status | jq '.value | map(select(.value.NodeStatus.process_status[0].state == \"Functional\")) | length' | grep -q 1");
$machine->succeed("contrail-api-cli --ns contrail_api_cli.provision add-vn --project-fqname default-domain:default-project --subnet 20.1.1.0/24 vn1");
$machine->succeed("netns-daemon-start -n default-domain:default-project:vn1 vm1");
$machine->succeed("netns-daemon-start -n default-domain:default-project:vn1 vm2");
$machine->succeed("ip netns exec ns-vm1 ip a | grep -q 20.1.1.252");
$machine->succeed("ip netns exec ns-vm1 ping -c1 20.1.1.251");
'';
in
makeTest {
name = "all-in-one";
nodes = { inherit machine; };
testScript = if testScript != null then testScript else contrailTestScript;
}