Merge pull request #75701 from kampka/port-tests-2
Port NixOS tests to python
This commit is contained in:
commit
9faa37cfdf
10 changed files with 81 additions and 67 deletions
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ lib, ... } : {
|
||||
import ./make-test-python.nix ({ lib, ... } : {
|
||||
name = "paperless";
|
||||
meta = with lib.maintainers; {
|
||||
maintainers = [ earvstedt ];
|
||||
|
@ -13,17 +13,24 @@ import ./make-test.nix ({ lib, ... } : {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
$machine->waitForUnit("paperless-consumer.service");
|
||||
# Create test doc
|
||||
$machine->succeed('convert -size 400x40 xc:white -font "DejaVu-Sans" -pointsize 20 -fill black \
|
||||
-annotate +5+20 "hello world 16-10-2005" /var/lib/paperless/consume/doc.png');
|
||||
machine.wait_for_unit("paperless-consumer.service")
|
||||
|
||||
$machine->waitForUnit("paperless-server.service");
|
||||
# Wait until server accepts connections
|
||||
$machine->waitUntilSucceeds("curl -s localhost:28981");
|
||||
# Wait until document is consumed
|
||||
$machine->waitUntilSucceeds('(($(curl -s localhost:28981/api/documents/ | jq .count) == 1))');
|
||||
$machine->succeed("curl -s localhost:28981/api/documents/ | jq '.results | .[0] | .created'")
|
||||
=~ /2005-10-16/ or die;
|
||||
# Create test doc
|
||||
machine.succeed(
|
||||
"convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black -annotate +5+20 'hello world 16-10-2005' /var/lib/paperless/consume/doc.png"
|
||||
)
|
||||
|
||||
with subtest("Service gets ready"):
|
||||
machine.wait_for_unit("paperless-server.service")
|
||||
# Wait until server accepts connections
|
||||
machine.wait_until_succeeds("curl -s localhost:28981")
|
||||
|
||||
with subtest("Test document is consumed"):
|
||||
machine.wait_until_succeeds(
|
||||
"(($(curl -s localhost:28981/api/documents/ | jq .count) == 1))"
|
||||
)
|
||||
assert "2005-10-16" in machine.succeed(
|
||||
"curl -s localhost:28981/api/documents/ | jq '.results | .[0] | .created'"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ... }: {
|
||||
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "powerdns";
|
||||
|
||||
nodes.server = { ... }: {
|
||||
|
@ -6,7 +6,7 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
$server->waitForUnit("pdns-recursor");
|
||||
$server->waitForOpenPort("53");
|
||||
server.wait_for_unit("pdns-recursor")
|
||||
server.wait_for_open_port("53")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This test runs peerflix and checks if peerflix starts
|
||||
|
||||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "peerflix";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ offline ];
|
||||
|
@ -15,9 +15,9 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$peerflix->waitForUnit("peerflix.service");
|
||||
$peerflix->waitUntilSucceeds("curl localhost:9000");
|
||||
peerflix.wait_for_unit("peerflix.service")
|
||||
peerflix.wait_until_succeeds("curl localhost:9000")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ... } :
|
||||
import ./make-test-python.nix ({ pkgs, ... } :
|
||||
let
|
||||
role = "test";
|
||||
password = "secret";
|
||||
|
@ -29,11 +29,13 @@ in
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
$one->waitForUnit("default.target");
|
||||
$one->requireActiveUnit("pgmanage.service");
|
||||
start_all()
|
||||
one.wait_for_unit("default.target")
|
||||
one.require_unit_state("pgmanage.service", "active")
|
||||
|
||||
# Test if we can log in.
|
||||
$one->waitUntilSucceeds("curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail");
|
||||
one.wait_until_succeeds(
|
||||
"curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
let testString = "can-use-subgroups"; in
|
||||
|
||||
import ./make-test.nix ({ ...}: {
|
||||
import ./make-test-python.nix ({ ...}: {
|
||||
name = "php-httpd-pcre-jit-test";
|
||||
machine = { lib, pkgs, ... }: {
|
||||
time.timeZone = "UTC";
|
||||
|
@ -31,9 +31,10 @@ import ./make-test.nix ({ ...}: {
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
$machine->waitForUnit('httpd.service');
|
||||
machine.wait_for_unit("httpd.service")
|
||||
# Ensure php evaluation by matching on the var_dump syntax
|
||||
$machine->succeed('curl -vvv -s http://127.0.0.1:80/index.php \
|
||||
| grep "string(${toString (builtins.stringLength testString)}) \"${testString}\""');
|
||||
assert 'string(${toString (builtins.stringLength testString)}) "${testString}"' in machine.succeed(
|
||||
"curl -vvv -s http://127.0.0.1:80/index.php"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "postgis";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ lsix ];
|
||||
|
@ -20,10 +20,10 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
$master->waitForUnit("postgresql");
|
||||
$master->sleep(10); # Hopefully this is long enough!!
|
||||
$master->succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis;'");
|
||||
$master->succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis_topology;'");
|
||||
start_all()
|
||||
master.wait_for_unit("postgresql")
|
||||
master.sleep(10) # Hopefully this is long enough!!
|
||||
master.succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis;'")
|
||||
master.succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis_topology;'")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#
|
||||
# All interfaces are in OSPF Area 0.
|
||||
|
||||
import ./make-test.nix ({ pkgs, ... }:
|
||||
import ./make-test-python.nix ({ pkgs, ... }:
|
||||
let
|
||||
|
||||
ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
|
||||
|
@ -74,23 +74,23 @@ import ./make-test.nix ({ pkgs, ... }:
|
|||
testScript =
|
||||
{ ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for the networking to start on all machines
|
||||
$_->waitForUnit("network.target") foreach values %vms;
|
||||
for machine in client, router1, router2, server:
|
||||
machine.wait_for_unit("network.target")
|
||||
|
||||
# Wait for OSPF to form adjacencies
|
||||
for my $gw ($router1, $router2) {
|
||||
$gw->waitForUnit("ospfd");
|
||||
$gw->waitUntilSucceeds("vtysh -c 'show ip ospf neighbor' | grep Full");
|
||||
$gw->waitUntilSucceeds("vtysh -c 'show ip route' | grep '^O>'");
|
||||
}
|
||||
with subtest("Wait for OSPF to form adjacencies"):
|
||||
for gw in router1, router2:
|
||||
gw.wait_for_unit("ospfd")
|
||||
gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
|
||||
gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
|
||||
|
||||
# Test ICMP.
|
||||
$client->succeed("ping -c 3 server >&2");
|
||||
with subtest("Test ICMP"):
|
||||
client.wait_until_succeeds("ping -c 3 server >&2")
|
||||
|
||||
# Test whether HTTP works.
|
||||
$server->waitForUnit("httpd");
|
||||
$client->succeed("curl --fail http://server/ >&2");
|
||||
with subtest("Test whether HTTP works"):
|
||||
server.wait_for_unit("httpd")
|
||||
client.succeed("curl --fail http://server/ >&2")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ lib, ... }:
|
||||
import ./make-test-python.nix ({ lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
|
@ -11,8 +11,8 @@ with lib;
|
|||
{ services.sonarr.enable = true; };
|
||||
|
||||
testScript = ''
|
||||
$machine->waitForUnit('sonarr.service');
|
||||
$machine->waitForOpenPort('8989');
|
||||
$machine->succeed("curl --fail http://localhost:8989/");
|
||||
machine.wait_for_unit("sonarr.service")
|
||||
machine.wait_for_open_port("8989")
|
||||
machine.succeed("curl --fail http://localhost:8989/")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Test configuration switching.
|
||||
|
||||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "switch-test";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ gleber ];
|
||||
|
@ -28,7 +28,11 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
exec env -i "$@" | tee /dev/stderr
|
||||
'';
|
||||
in ''
|
||||
$machine->succeed("${stderrRunner} ${originalSystem}/bin/switch-to-configuration test");
|
||||
$machine->succeed("${stderrRunner} ${otherSystem}/bin/switch-to-configuration test");
|
||||
machine.succeed(
|
||||
"${stderrRunner} ${originalSystem}/bin/switch-to-configuration test"
|
||||
)
|
||||
machine.succeed(
|
||||
"${stderrRunner} ${otherSystem}/bin/switch-to-configuration test"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Regression test for systemd-timesync having moved the state directory without
|
||||
# upstream providing a migration path. https://github.com/systemd/systemd/issues/12131
|
||||
|
||||
import ./make-test.nix (let
|
||||
import ./make-test-python.nix (let
|
||||
common = { lib, ... }: {
|
||||
# override the `false` value from the qemu-vm base profile
|
||||
services.timesyncd.enable = lib.mkForce true;
|
||||
|
@ -25,28 +25,28 @@ in {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
$current->succeed('systemctl status systemd-timesyncd.service');
|
||||
start_all()
|
||||
current.succeed("systemctl status systemd-timesyncd.service")
|
||||
# on a new install with a recent systemd there should not be any
|
||||
# leftovers from the dynamic user mess
|
||||
$current->succeed('test -e /var/lib/systemd/timesync');
|
||||
$current->succeed('test ! -L /var/lib/systemd/timesync');
|
||||
current.succeed("test -e /var/lib/systemd/timesync")
|
||||
current.succeed("test ! -L /var/lib/systemd/timesync")
|
||||
|
||||
# timesyncd should be running on the upgrading system since we fixed the
|
||||
# file bits in the activation script
|
||||
$pre1909->succeed('systemctl status systemd-timesyncd.service');
|
||||
pre1909.succeed("systemctl status systemd-timesyncd.service")
|
||||
|
||||
# the path should be gone after the migration
|
||||
$pre1909->succeed('test ! -e /var/lib/private/systemd/timesync');
|
||||
pre1909.succeed("test ! -e /var/lib/private/systemd/timesync")
|
||||
|
||||
# and the new path should no longer be a symlink
|
||||
$pre1909->succeed('test -e /var/lib/systemd/timesync');
|
||||
$pre1909->succeed('test ! -L /var/lib/systemd/timesync');
|
||||
pre1909.succeed("test -e /var/lib/systemd/timesync")
|
||||
pre1909.succeed("test ! -L /var/lib/systemd/timesync")
|
||||
|
||||
# after a restart things should still work and not fail in the activation
|
||||
# scripts and cause the boot to fail..
|
||||
$pre1909->shutdown;
|
||||
$pre1909->start;
|
||||
$pre1909->succeed('systemctl status systemd-timesyncd.service');
|
||||
pre1909.shutdown()
|
||||
pre1909.start()
|
||||
pre1909.succeed("systemctl status systemd-timesyncd.service")
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue