Merge pull request #75695 from kampka/port-tests

Port NixOS tests to python
This commit is contained in:
Dmitry Kalinkin 2019-12-17 21:45:59 -05:00 committed by GitHub
commit fc47ec691f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 36 deletions

View file

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...}: {
import ./make-test-python.nix ({ pkgs, ...}: {
name = "haproxy";
nodes = {
machine = { ... }: {
@ -33,11 +33,13 @@ import ./make-test.nix ({ pkgs, ...}: {
};
};
testScript = ''
startAll;
$machine->waitForUnit('multi-user.target');
$machine->waitForUnit('haproxy.service');
$machine->waitForUnit('httpd.service');
$machine->succeed('curl -k http://localhost:80/index.txt | grep "We are all good!"');
$machine->succeed('curl -k http://localhost:80/metrics | grep haproxy_process_pool_allocated_bytes');
start_all()
machine.wait_for_unit("multi-user.target")
machine.wait_for_unit("haproxy.service")
machine.wait_for_unit("httpd.service")
assert "We are all good!" in machine.succeed("curl -k http://localhost:80/index.txt")
assert "haproxy_process_pool_allocated_bytes" in machine.succeed(
"curl -k http://localhost:80/metrics"
)
'';
})

View file

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...} : {
import ./make-test-python.nix ({ pkgs, ...} : {
name = "initrd-network";
meta.maintainers = [ pkgs.stdenv.lib.maintainers.eelco ];
@ -15,8 +15,8 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
startAll;
$machine->waitForUnit("multi-user.target");
$machine->succeed("ip link >&2");
start_all()
machine.wait_for_unit("multi-user.target")
machine.succeed("ip link >&2")
'';
})

View file

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... }:
import ./make-test-python.nix ({ pkgs, ... }:
{
name = "leaps";
@ -22,9 +22,11 @@ import ./make-test.nix ({ pkgs, ... }:
testScript =
''
startAll;
$server->waitForOpenPort(6666);
$client->waitForUnit("network.target");
$client->succeed("${pkgs.curl}/bin/curl http://server:6666/leaps/ | grep -i 'leaps'");
start_all()
server.wait_for_open_port(6666)
client.wait_for_unit("network.target")
assert "leaps" in client.succeed(
"${pkgs.curl}/bin/curl http://server:6666/leaps/"
)
'';
})

View file

@ -1,4 +1,4 @@
import ./make-test.nix ({ lib, ... }:
import ./make-test-python.nix ({ lib, ... }:
with lib;
@ -11,8 +11,10 @@ with lib;
{ services.lidarr.enable = true; };
testScript = ''
$machine->waitForUnit('lidarr.service');
$machine->waitForOpenPort('8686');
$machine->succeed("curl --fail http://localhost:8686/");
start_all()
machine.wait_for_unit("lidarr.service")
machine.wait_for_open_port("8686")
machine.succeed("curl --fail http://localhost:8686/")
'';
})

View file

@ -1,4 +1,4 @@
import ./make-test.nix ({ lib, ... }:
import ./make-test-python.nix ({ lib, ... }:
{
name = "mailcatcher";
@ -16,11 +16,15 @@ import ./make-test.nix ({ lib, ... }:
};
testScript = ''
startAll;
start_all()
$machine->waitForUnit('mailcatcher.service');
$machine->waitForOpenPort('1025');
$machine->succeed('echo "this is the body of the email" | mail -s "subject" root@example.org');
$machine->succeed('curl http://localhost:1080/messages/1.source') =~ /this is the body of the email/ or die;
machine.wait_for_unit("mailcatcher.service")
machine.wait_for_open_port("1025")
machine.succeed(
'echo "this is the body of the email" | mail -s "subject" root@example.org'
)
assert "this is the body of the email" in machine.succeed(
"curl http://localhost:1080/messages/1.source"
)
'';
})

View file

@ -13,7 +13,7 @@ let
in
import ../make-test.nix ({ pkgs, ...} : {
import ../make-test-python.nix ({ pkgs, ...} : {
name = "wireguard-with-namespaces";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ asymmetric ];
@ -65,16 +65,14 @@ import ../make-test.nix ({ pkgs, ...} : {
};
testScript = ''
startAll();
start_all()
$peer0->waitForUnit("wireguard-wg0.service");
$peer1->waitForUnit("wireguard-wg0.service");
$peer2->waitForUnit("wireguard-wg0.service");
$peer3->waitForUnit("wireguard-wg0.service");
for machine in peer0, peer1, peer2, peer3:
machine.wait_for_unit("wireguard-wg0.service")
$peer0->succeed("ip -n ${socketNamespace} link show wg0");
$peer1->succeed("ip -n ${interfaceNamespace} link show wg0");
$peer2->succeed("ip -n ${interfaceNamespace} link show wg0");
$peer3->succeed("ip link show wg0");
peer0.succeed("ip -n ${socketNamespace} link show wg0")
peer1.succeed("ip -n ${interfaceNamespace} link show wg0")
peer2.succeed("ip -n ${interfaceNamespace} link show wg0")
peer3.succeed("ip link show wg0")
'';
})