nixos/cjdns: port test to python

This commit is contained in:
Marijan 2019-11-06 20:05:17 +01:00 committed by Marijan Petricevic
parent 30d1dfef4b
commit 3695e600cc

View file

@ -17,7 +17,7 @@ let
in in
import ./make-test.nix ({ pkgs, ...} : { import ./make-test-python.nix ({ pkgs, ...} : {
name = "cjdns"; name = "cjdns";
meta = with pkgs.stdenv.lib.maintainers; { meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ ehmry ]; maintainers = [ ehmry ];
@ -83,36 +83,39 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript = testScript =
'' ''
startAll; import re
$alice->waitForUnit("cjdns.service"); start_all()
$bob->waitForUnit("cjdns.service");
$carol->waitForUnit("cjdns.service");
sub cjdnsIp { alice.wait_for_unit("cjdns.service")
my ($machine) = @_; bob.wait_for_unit("cjdns.service")
my $ip = (split /[ \/]+/, $machine->succeed("ip -o -6 addr show dev tun0"))[3]; carol.wait_for_unit("cjdns.service")
$machine->log("has ip $ip");
return $ip;
}
my $aliceIp6 = cjdnsIp $alice;
my $bobIp6 = cjdnsIp $bob; def cjdns_ip(machine):
my $carolIp6 = cjdnsIp $carol; res = machine.succeed("ip -o -6 addr show dev tun0")
ip = re.split("\s+|/", res)[3]
machine.log("has ip {}".format(ip))
return ip
alice_ip6 = cjdns_ip(alice)
bob_ip6 = cjdns_ip(bob)
carol_ip6 = cjdns_ip(carol)
# ping a few times each to let the routing table establish itself # ping a few times each to let the routing table establish itself
$alice->succeed("ping -c 4 $carolIp6"); alice.succeed("ping -c 4 {}".format(carol_ip6))
$bob->succeed("ping -c 4 $carolIp6"); bob.succeed("ping -c 4 {}".format(carol_ip6))
$carol->succeed("ping -c 4 $aliceIp6"); carol.succeed("ping -c 4 {}".format(alice_ip6))
$carol->succeed("ping -c 4 $bobIp6"); carol.succeed("ping -c 4 {}".format(bob_ip6))
$alice->succeed("ping -c 4 $bobIp6"); alice.succeed("ping -c 4 {}".format(bob_ip6))
$bob->succeed("ping -c 4 $aliceIp6"); bob.succeed("ping -c 4 {}".format(alice_ip6))
$alice->waitForUnit("httpd.service"); alice.wait_for_unit("httpd.service")
$bob->succeed("curl --fail -g http://[$aliceIp6]"); bob.succeed("curl --fail -g http://[{}]".format(alice_ip6))
''; '';
}) })