* Optionally pass the computed `nodes' to the test script as a

function argument, so that the test script can refer to computed
  values such as the assigned IP addresses of the virtual machines.

svn path=/nixos/trunk/; revision=21939
This commit is contained in:
Eelco Dolstra 2010-05-21 14:31:05 +00:00
parent fa183e5472
commit dd81311714
4 changed files with 20 additions and 13 deletions

View file

@ -45,6 +45,7 @@ rec {
EOF
chmod +x $out/bin/run-vms
''; # */
passthru = { nodes = nodes_; };
};

View file

@ -95,17 +95,19 @@ rec {
if t ? machine then { machine = t.machine; }
else { };
vms = buildVirtualNetwork { inherit nodes; };
test = runTests vms t.testScript;
test = runTests vms
# Call the test script with the computed nodes.
(if builtins.isFunction t.testScript then t.testScript { inherit (vms) nodes; } else t.testScript);
report = makeReport test;
};
runInMachine = {
drv
, machine
, preBuild ? ""
, postBuild ? ""
, ...
}:
runInMachine =
{ drv
, machine
, preBuild ? ""
, postBuild ? ""
, ...
}:
let
vms =
buildVirtualNetwork { nodes = { client = machine; } ; };

View file

@ -13,10 +13,10 @@ let
# Some random file to serve.
file = pkgs.nixUnstable.src;
miniupnpdConf = pkgs.writeText "miniupnpd.conf"
miniupnpdConf = nodes: pkgs.writeText "miniupnpd.conf"
''
ext_ifname=eth1
listening_ip=192.168.2.3/24
listening_ip=${nodes.router.config.networking.ifaces.eth2.ipAddress}/24
allow 1024-65535 192.168.2.0/24 1024-65535
'';
@ -56,6 +56,7 @@ in
};
testScript =
{ nodes, ... }:
''
startAll;
@ -63,11 +64,12 @@ in
$router->mustSucceed(
"iptables -t nat -F",
"iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -d 192.168.2.0/24 -j ACCEPT",
"iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j SNAT --to-source 192.168.1.3", # !!! ugly
"iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j SNAT "
. "--to-source ${nodes.router.config.networking.ifaces.eth1.ipAddress}",
"iptables -t nat -N MINIUPNPD",
"iptables -t nat -A PREROUTING -i eth1 -j MINIUPNPD",
"echo 1 > /proc/sys/net/ipv4/ip_forward",
"miniupnpd -f ${miniupnpdConf}"
"miniupnpd -f ${miniupnpdConf nodes}"
);
# Create the torrent.

View file

@ -31,6 +31,7 @@
};
testScript =
{ nodes, ... }:
''
startAll;
@ -45,7 +46,8 @@
$router->mustSucceed(
"iptables -t nat -F",
"iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 192.168.1.0/24 -j ACCEPT",
"iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 192.168.2.2", # !!! ugly
"iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT "
. "--to-source ${nodes.router.config.networking.ifaces.eth1.ipAddress}",
"echo 1 > /proc/sys/net/ipv4/ip_forward"
);