Merge pull request #72887 from 1000101/master

Port tests to Python
This commit is contained in:
Marek Mahut 2019-11-07 19:57:50 +01:00 committed by GitHub
commit 1a65fc1041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 113 additions and 111 deletions

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, lib, ... }: {
import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "moodle";
meta.maintainers = [ lib.maintainers.aanderse ];
@ -15,8 +15,8 @@ import ./make-test.nix ({ pkgs, lib, ... }: {
};
testScript = ''
startAll;
$machine->waitForUnit('phpfpm-moodle.service');
$machine->succeed('curl http://localhost/') =~ /You are not logged in/ or die;
start_all()
machine.wait_for_unit("phpfpm-moodle.service")
machine.wait_until_succeeds("curl http://localhost/ | grep 'You are not logged in'")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... }:
import ./make-test-python.nix ({ pkgs, ... }:
{
name = "morty";
@ -22,11 +22,9 @@ import ./make-test.nix ({ pkgs, ... }:
testScript =
{ ... }:
''
$mortyProxyWithKey->waitForUnit("default.target");
$mortyProxyWithKey->waitForOpenPort(3001);
$mortyProxyWithKey->succeed("curl -L 127.0.0.1:3001 | grep MortyProxy");
mortyProxyWithKey.wait_for_unit("default.target")
mortyProxyWithKey.wait_for_open_port(3001)
mortyProxyWithKey.succeed("curl -L 127.0.0.1:3001 | grep MortyProxy")
'';
})

View File

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

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...} : {
import ./make-test-python.nix ({ pkgs, ...} : {
name = "redis";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ flokli ];
@ -15,12 +15,10 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
startAll;
$machine->waitForUnit("redis");
$machine->waitForOpenPort("6379");
$machine->succeed("redis-cli ping | grep PONG");
$machine->succeed("redis-cli -s /run/redis/redis.sock ping | grep PONG");
start_all()
machine.wait_for_unit("redis")
machine.wait_for_open_port("6379")
machine.succeed("redis-cli ping | grep PONG")
machine.succeed("redis-cli -s /run/redis/redis.sock ping | grep PONG")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...} : {
import ./make-test-python.nix ({ pkgs, ...} : {
name = "roundcube";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ globin ];
@ -21,10 +21,10 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
$roundcube->start;
$roundcube->waitForUnit("postgresql.service");
$roundcube->waitForUnit("phpfpm-roundcube.service");
$roundcube->waitForUnit("nginx.service");
$roundcube->succeed("curl -sSfL http://roundcube/ | grep 'Keep me logged in'");
roundcube.start
roundcube.wait_for_unit("postgresql.service")
roundcube.wait_for_unit("phpfpm-roundcube.service")
roundcube.wait_for_unit("nginx.service")
roundcube.succeed("curl -sSfL http://roundcube/ | grep 'Keep me logged in'")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix {
import ./make-test-python.nix {
name = "opensmtpd";
nodes = {
@ -53,14 +53,14 @@ import ./make-test.nix {
};
testScript = ''
startAll;
start_all()
$server->waitForUnit("network-online.target");
$server->waitForUnit("opensmtpd");
$server->waitForUnit("dovecot2");
$server->waitForUnit("nginx");
$server->waitForUnit("rss2email");
server.wait_for_unit("network-online.target")
server.wait_for_unit("opensmtpd")
server.wait_for_unit("dovecot2")
server.wait_for_unit("nginx")
server.wait_for_unit("rss2email")
$server->waitUntilSucceeds('check-mail-landed >&2');
server.wait_until_succeeds("check-mail-landed >&2")
'';
}

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...} :
import ./make-test-python.nix ({ pkgs, ...} :
{
name = "signal-desktop";
@ -24,14 +24,14 @@ import ./make-test.nix ({ pkgs, ...} :
testScript = { nodes, ... }: let
user = nodes.machine.config.users.users.alice;
in ''
startAll;
$machine->waitForX;
start_all()
machine.wait_for_x()
# start signal desktop
$machine->execute("su - alice -c signal-desktop &");
machine.execute("su - alice -c signal-desktop &")
# wait for the "Link your phone to Signal Desktop" message
$machine->waitForText(qr/Link your phone to Signal Desktop/);
$machine->screenshot("signal_desktop");
machine.wait_for_text("Link your phone to Signal Desktop")
machine.screenshot("signal_desktop")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ ... }:
import ./make-test-python.nix ({ ... }:
{
name = "snapper";
@ -20,24 +20,16 @@ import ./make-test.nix ({ ... }:
};
testScript = ''
$machine->succeed("btrfs subvolume create /home/.snapshots");
$machine->succeed("snapper -c home list");
$machine->succeed("snapper -c home create --description empty");
$machine->succeed("echo test > /home/file");
$machine->succeed("snapper -c home create --description file");
$machine->succeed("snapper -c home status 1..2");
$machine->succeed("snapper -c home undochange 1..2");
$machine->fail("ls /home/file");
$machine->succeed("snapper -c home delete 2");
$machine->succeed("systemctl --wait start snapper-timeline.service");
$machine->succeed("systemctl --wait start snapper-cleanup.service");
machine.succeed("btrfs subvolume create /home/.snapshots")
machine.succeed("snapper -c home list")
machine.succeed("snapper -c home create --description empty")
machine.succeed("echo test > /home/file")
machine.succeed("snapper -c home create --description file")
machine.succeed("snapper -c home status 1..2")
machine.succeed("snapper -c home undochange 1..2")
machine.fail("ls /home/file")
machine.succeed("snapper -c home delete 2")
machine.succeed("systemctl --wait start snapper-timeline.service")
machine.succeed("systemctl --wait start snapper-cleanup.service")
'';
})

View File

@ -16,7 +16,7 @@
# See the NixOS manual for how to run this test:
# https://nixos.org/nixos/manual/index.html#sec-running-nixos-tests-interactively
import ./make-test.nix ({ pkgs, ...} :
import ./make-test-python.nix ({ pkgs, ...} :
let
allowESP = "iptables --insert INPUT --protocol ESP --jump ACCEPT";
@ -142,7 +142,7 @@ in {
};
testScript = ''
startAll();
$carol->waitUntilSucceeds("ping -c 1 alice");
start_all()
carol.wait_until_succeeds("ping -c 1 alice")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...} : {
import ./make-test-python.nix ({ pkgs, ...} : {
name = "telegraf";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ mic92 ];
@ -22,9 +22,9 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
startAll;
start_all()
$machine->waitForUnit("telegraf.service");
$machine->waitUntilSucceeds("grep -q example /tmp/metrics.out");
machine.wait_for_unit("telegraf.service")
machine.wait_until_succeeds("grep -q example /tmp/metrics.out")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... }: {
import ./make-test-python.nix ({ pkgs, ... }: {
name = "trickster";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ "1000101" ];
@ -15,15 +15,23 @@ import ./make-test.nix ({ pkgs, ... }: {
};
testScript = ''
startAll;
$prometheus->waitForUnit("prometheus.service");
$prometheus->waitForOpenPort(9090);
$prometheus->waitUntilSucceeds("curl -L http://localhost:9090/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'");
$trickster->waitForUnit("trickster.service");
$trickster->waitForOpenPort(8082);
$trickster->waitForOpenPort(9090);
$trickster->waitUntilSucceeds("curl -L http://localhost:8082/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'");
$trickster->waitUntilSucceeds("curl -L http://prometheus:9090/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'");
$trickster->waitUntilSucceeds("curl -L http://localhost:9090/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'");
start_all()
prometheus.wait_for_unit("prometheus.service")
prometheus.wait_for_open_port(9090)
prometheus.wait_until_succeeds(
"curl -L http://localhost:9090/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'"
)
trickster.wait_for_unit("trickster.service")
trickster.wait_for_open_port(8082)
trickster.wait_for_open_port(9090)
trickster.wait_until_succeeds(
"curl -L http://localhost:8082/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'"
)
trickster.wait_until_succeeds(
"curl -L http://prometheus:9090/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'"
)
trickster.wait_until_succeeds(
"curl -L http://localhost:9090/metrics | grep 'promhttp_metric_handler_requests_total{code=\"500\"} 0'"
)
'';
})

View File

@ -5,7 +5,7 @@
# this succeeds an external client will try to connect to the port
# mapping.
import ./make-test.nix ({ pkgs, ... }:
import ./make-test-python.nix ({ pkgs, ... }:
let
internalRouterAddress = "192.168.3.1";
@ -75,20 +75,20 @@ in
testScript =
{ nodes, ... }:
''
startAll;
start_all()
# Wait for network and miniupnpd.
$router->waitForUnit("network-online.target");
# $router->waitForUnit("nat");
$router->waitForUnit("firewall.service");
$router->waitForUnit("miniupnpd");
router.wait_for_unit("network-online.target")
# $router.wait_for_unit("nat")
router.wait_for_unit("firewall.service")
router.wait_for_unit("miniupnpd")
$client1->waitForUnit("network-online.target");
client1.wait_for_unit("network-online.target")
$client1->succeed("upnpc -a ${internalClient1Address} 9000 9000 TCP");
client1.succeed("upnpc -a ${internalClient1Address} 9000 9000 TCP")
$client1->waitForUnit("httpd");
$client2->waitUntilSucceeds("curl http://${externalRouterAddress}:9000/");
client1.wait_for_unit("httpd")
client2.wait_until_succeeds("curl http://${externalRouterAddress}:9000/")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, lib, ... }:
import ./make-test-python.nix ({ pkgs, lib, ... }:
with lib;
@ -15,10 +15,10 @@ with lib;
};
testScript = ''
$machine->start;
$machine->waitForX;
$machine->mustFail("pgrep xlock");
$machine->sleep(120);
$machine->mustSucceed("pgrep xlock");
machine.start()
machine.wait_for_x()
machine.fail("pgrep xlock")
machine.sleep(120)
machine.succeed("pgrep xlock")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, lib, ... }:
import ./make-test-python.nix ({ pkgs, lib, ... }:
with lib;
@ -20,14 +20,14 @@ with lib;
};
testScript = ''
$machine->start;
$machine->waitForX;
machine.start()
machine.wait_for_x()
# confirm proper startup
$machine->waitForUnit("yabar.service", "bob");
$machine->sleep(10);
$machine->waitForUnit("yabar.service", "bob");
machine.wait_for_unit("yabar.service", "bob")
machine.sleep(10)
machine.wait_for_unit("yabar.service", "bob")
$machine->screenshot("top_bar");
machine.screenshot("top_bar")
'';
})

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ...} : {
import ./make-test-python.nix ({ pkgs, ...} : {
name = "zookeeper";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ nequissimus ];
@ -15,14 +15,20 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
startAll;
start_all()
$server->waitForUnit("zookeeper");
$server->waitForUnit("network.target");
$server->waitForOpenPort(2181);
server.wait_for_unit("zookeeper")
server.wait_for_unit("network.target")
server.wait_for_open_port(2181)
$server->waitUntilSucceeds("${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar");
$server->waitUntilSucceeds("${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello");
$server->waitUntilSucceeds("${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello");
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar"
)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello"
)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello"
)
'';
})