3
0
Fork 0
forked from mirrors/nixpkgs

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"; name = "haproxy";
nodes = { nodes = {
machine = { ... }: { machine = { ... }: {
@ -33,11 +33,13 @@ import ./make-test.nix ({ pkgs, ...}: {
}; };
}; };
testScript = '' testScript = ''
startAll; start_all()
$machine->waitForUnit('multi-user.target'); machine.wait_for_unit("multi-user.target")
$machine->waitForUnit('haproxy.service'); machine.wait_for_unit("haproxy.service")
$machine->waitForUnit('httpd.service'); machine.wait_for_unit("httpd.service")
$machine->succeed('curl -k http://localhost:80/index.txt | grep "We are all good!"'); assert "We are all good!" in machine.succeed("curl -k http://localhost:80/index.txt")
$machine->succeed('curl -k http://localhost:80/metrics | grep haproxy_process_pool_allocated_bytes'); 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"; name = "initrd-network";
meta.maintainers = [ pkgs.stdenv.lib.maintainers.eelco ]; meta.maintainers = [ pkgs.stdenv.lib.maintainers.eelco ];
@ -15,8 +15,8 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript = testScript =
'' ''
startAll; start_all()
$machine->waitForUnit("multi-user.target"); machine.wait_for_unit("multi-user.target")
$machine->succeed("ip link >&2"); machine.succeed("ip link >&2")
''; '';
}) })

View file

@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... }: import ./make-test-python.nix ({ pkgs, ... }:
{ {
name = "leaps"; name = "leaps";
@ -22,9 +22,11 @@ import ./make-test.nix ({ pkgs, ... }:
testScript = testScript =
'' ''
startAll; start_all()
$server->waitForOpenPort(6666); server.wait_for_open_port(6666)
$client->waitForUnit("network.target"); client.wait_for_unit("network.target")
$client->succeed("${pkgs.curl}/bin/curl http://server:6666/leaps/ | grep -i 'leaps'"); 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; with lib;
@ -11,8 +11,10 @@ with lib;
{ services.lidarr.enable = true; }; { services.lidarr.enable = true; };
testScript = '' testScript = ''
$machine->waitForUnit('lidarr.service'); start_all()
$machine->waitForOpenPort('8686');
$machine->succeed("curl --fail http://localhost:8686/"); 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"; name = "mailcatcher";
@ -16,11 +16,15 @@ import ./make-test.nix ({ lib, ... }:
}; };
testScript = '' testScript = ''
startAll; start_all()
$machine->waitForUnit('mailcatcher.service'); machine.wait_for_unit("mailcatcher.service")
$machine->waitForOpenPort('1025'); machine.wait_for_open_port("1025")
$machine->succeed('echo "this is the body of the email" | mail -s "subject" root@example.org'); machine.succeed(
$machine->succeed('curl http://localhost:1080/messages/1.source') =~ /this is the body of the email/ or die; '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 in
import ../make-test.nix ({ pkgs, ...} : { import ../make-test-python.nix ({ pkgs, ...} : {
name = "wireguard-with-namespaces"; name = "wireguard-with-namespaces";
meta = with pkgs.stdenv.lib.maintainers; { meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ asymmetric ]; maintainers = [ asymmetric ];
@ -65,16 +65,14 @@ import ../make-test.nix ({ pkgs, ...} : {
}; };
testScript = '' testScript = ''
startAll(); start_all()
$peer0->waitForUnit("wireguard-wg0.service"); for machine in peer0, peer1, peer2, peer3:
$peer1->waitForUnit("wireguard-wg0.service"); machine.wait_for_unit("wireguard-wg0.service")
$peer2->waitForUnit("wireguard-wg0.service");
$peer3->waitForUnit("wireguard-wg0.service");
$peer0->succeed("ip -n ${socketNamespace} link show wg0"); peer0.succeed("ip -n ${socketNamespace} link show wg0")
$peer1->succeed("ip -n ${interfaceNamespace} link show wg0"); peer1.succeed("ip -n ${interfaceNamespace} link show wg0")
$peer2->succeed("ip -n ${interfaceNamespace} link show wg0"); peer2.succeed("ip -n ${interfaceNamespace} link show wg0")
$peer3->succeed("ip link show wg0"); peer3.succeed("ip link show wg0")
''; '';
}) })