mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 05:00:16 +00:00
Merge pull request #72935 from marijanp/port-tests-python
Port tests to Python
This commit is contained in:
commit
dd439bc01f
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ... }: {
|
||||
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "caddy";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ xfix ];
|
||||
|
@ -50,33 +50,38 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||
etagSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-1";
|
||||
justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-2";
|
||||
in ''
|
||||
my $url = 'http://localhost/example.html';
|
||||
$webserver->waitForUnit("caddy");
|
||||
$webserver->waitForOpenPort("80");
|
||||
url = "http://localhost/example.html"
|
||||
webserver.wait_for_unit("caddy")
|
||||
webserver.wait_for_open_port("80")
|
||||
|
||||
sub checkEtag {
|
||||
my $etag = $webserver->succeed(
|
||||
'curl -v '.$url.' 2>&1 | sed -n -e "s/^< [Ee][Tt][Aa][Gg]: *//p"'
|
||||
);
|
||||
$etag =~ s/\r?\n$//;
|
||||
my $httpCode = $webserver->succeed(
|
||||
'curl -w "%{http_code}" -X HEAD -H \'If-None-Match: '.$etag.'\' '.$url
|
||||
);
|
||||
die "HTTP code is not 304" unless $httpCode == 304;
|
||||
return $etag;
|
||||
}
|
||||
|
||||
subtest "check ETag if serving Nix store paths", sub {
|
||||
my $oldEtag = checkEtag;
|
||||
$webserver->succeed("${etagSystem}/bin/switch-to-configuration test >&2");
|
||||
$webserver->sleep(1); # race condition
|
||||
my $newEtag = checkEtag;
|
||||
die "Old ETag $oldEtag is the same as $newEtag" if $oldEtag eq $newEtag;
|
||||
};
|
||||
def check_etag(url):
|
||||
etag = webserver.succeed(
|
||||
"curl -v '{}' 2>&1 | sed -n -e \"s/^< [Ee][Tt][Aa][Gg]: *//p\"".format(url)
|
||||
)
|
||||
etag = etag.replace("\r\n", " ")
|
||||
http_code = webserver.succeed(
|
||||
"curl -w \"%{{http_code}}\" -X HEAD -H 'If-None-Match: {}' {}".format(etag, url)
|
||||
)
|
||||
assert int(http_code) == 304, "HTTP code is not 304"
|
||||
return etag
|
||||
|
||||
subtest "config is reloaded on nixos-rebuild switch", sub {
|
||||
$webserver->succeed("${justReloadSystem}/bin/switch-to-configuration test >&2");
|
||||
$webserver->waitForOpenPort("8080");
|
||||
};
|
||||
|
||||
with subtest("check ETag if serving Nix store paths"):
|
||||
old_etag = check_etag(url)
|
||||
webserver.succeed(
|
||||
"${etagSystem}/bin/switch-to-configuration test >&2"
|
||||
)
|
||||
webserver.sleep(1)
|
||||
new_etag = check_etag(url)
|
||||
assert old_etag != new_etag, "Old ETag {} is the same as {}".format(
|
||||
old_etag, new_etag
|
||||
)
|
||||
|
||||
with subtest("config is reloaded on nixos-rebuild switch"):
|
||||
webserver.succeed(
|
||||
"${justReloadSystem}/bin/switch-to-configuration test >&2"
|
||||
)
|
||||
webserver.wait_for_open_port("8080")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ... } : {
|
||||
import ./make-test-python.nix ({ pkgs, ... } : {
|
||||
name = "cadvisor";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ offline ];
|
||||
|
@ -16,20 +16,19 @@ import ./make-test.nix ({ pkgs, ... } : {
|
|||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
''
|
||||
startAll;
|
||||
$machine->waitForUnit("cadvisor.service");
|
||||
$machine->succeed("curl http://localhost:8080/containers/");
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.wait_for_unit("cadvisor.service")
|
||||
machine.succeed("curl http://localhost:8080/containers/")
|
||||
|
||||
$influxdb->waitForUnit("influxdb.service");
|
||||
influxdb.wait_for_unit("influxdb.service")
|
||||
|
||||
# create influxdb database
|
||||
$influxdb->succeed(q~
|
||||
curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE root"
|
||||
~);
|
||||
influxdb.succeed(
|
||||
'curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE root"'
|
||||
)
|
||||
|
||||
$influxdb->waitForUnit("cadvisor.service");
|
||||
$influxdb->succeed("curl http://localhost:8080/containers/");
|
||||
influxdb.wait_for_unit("cadvisor.service")
|
||||
influxdb.succeed("curl http://localhost:8080/containers/")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
pkgs ? import ../.. { inherit system config; }
|
||||
}:
|
||||
|
||||
with import ../lib/testing.nix { inherit system pkgs; };
|
||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||
let
|
||||
mkSpec = { host, service ? null, action }: {
|
||||
inherit action;
|
||||
|
@ -123,17 +123,17 @@ in
|
|||
)));
|
||||
};
|
||||
testScript = ''
|
||||
$machine->waitForUnit('cfssl.service');
|
||||
$machine->waitUntilSucceeds('ls /tmp/decl.example.org-ca.pem');
|
||||
$machine->waitUntilSucceeds('ls /tmp/decl.example.org-key.pem');
|
||||
$machine->waitUntilSucceeds('ls /tmp/decl.example.org-cert.pem');
|
||||
$machine->waitUntilSucceeds('ls /tmp/imp.example.org-ca.pem');
|
||||
$machine->waitUntilSucceeds('ls /tmp/imp.example.org-key.pem');
|
||||
$machine->waitUntilSucceeds('ls /tmp/imp.example.org-cert.pem');
|
||||
$machine->waitForUnit('nginx.service');
|
||||
$machine->succeed('[ "1" -lt "$(journalctl -u nginx | grep "Starting Nginx" | wc -l)" ]');
|
||||
$machine->succeed('curl --cacert /tmp/imp.example.org-ca.pem https://imp.example.org');
|
||||
$machine->succeed('curl --cacert /tmp/decl.example.org-ca.pem https://decl.example.org');
|
||||
machine.wait_for_unit("cfssl.service")
|
||||
machine.wait_until_succeeds("ls /tmp/decl.example.org-ca.pem")
|
||||
machine.wait_until_succeeds("ls /tmp/decl.example.org-key.pem")
|
||||
machine.wait_until_succeeds("ls /tmp/decl.example.org-cert.pem")
|
||||
machine.wait_until_succeeds("ls /tmp/imp.example.org-ca.pem")
|
||||
machine.wait_until_succeeds("ls /tmp/imp.example.org-key.pem")
|
||||
machine.wait_until_succeeds("ls /tmp/imp.example.org-cert.pem")
|
||||
machine.wait_for_unit("nginx.service")
|
||||
assert 1 < int(machine.succeed('journalctl -u nginx | grep "Starting Nginx" | wc -l'))
|
||||
machine.succeed("curl --cacert /tmp/imp.example.org-ca.pem https://imp.example.org")
|
||||
machine.succeed("curl --cacert /tmp/decl.example.org-ca.pem https://decl.example.org")
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -143,8 +143,8 @@ in
|
|||
test = mkSpec { host = "command.example.org"; action = "touch /tmp/command.executed"; };
|
||||
};
|
||||
testScript = ''
|
||||
$machine->waitForUnit('cfssl.service');
|
||||
$machine->waitUntilSucceeds('stat /tmp/command.executed');
|
||||
machine.wait_for_unit("cfssl.service")
|
||||
machine.wait_until_succeeds("stat /tmp/command.executed")
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "cfssl";
|
||||
|
||||
machine = { config, lib, pkgs, ... }:
|
||||
|
@ -60,8 +60,8 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
});
|
||||
in
|
||||
''
|
||||
$machine->waitForUnit('cfssl.service');
|
||||
$machine->waitUntilSucceeds('${cfsslrequest}');
|
||||
$machine->succeed('ls /tmp/certificate-key.pem');
|
||||
machine.wait_for_unit("cfssl.service")
|
||||
machine.wait_until_succeeds("${cfsslrequest}")
|
||||
machine.succeed("ls /tmp/certificate-key.pem")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -17,7 +17,7 @@ let
|
|||
|
||||
in
|
||||
|
||||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "cjdns";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ ehmry ];
|
||||
|
@ -83,36 +83,39 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
|
||||
testScript =
|
||||
''
|
||||
startAll;
|
||||
import re
|
||||
|
||||
$alice->waitForUnit("cjdns.service");
|
||||
$bob->waitForUnit("cjdns.service");
|
||||
$carol->waitForUnit("cjdns.service");
|
||||
start_all()
|
||||
|
||||
sub cjdnsIp {
|
||||
my ($machine) = @_;
|
||||
my $ip = (split /[ \/]+/, $machine->succeed("ip -o -6 addr show dev tun0"))[3];
|
||||
$machine->log("has ip $ip");
|
||||
return $ip;
|
||||
}
|
||||
alice.wait_for_unit("cjdns.service")
|
||||
bob.wait_for_unit("cjdns.service")
|
||||
carol.wait_for_unit("cjdns.service")
|
||||
|
||||
my $aliceIp6 = cjdnsIp $alice;
|
||||
my $bobIp6 = cjdnsIp $bob;
|
||||
my $carolIp6 = cjdnsIp $carol;
|
||||
|
||||
def cjdns_ip(machine):
|
||||
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
|
||||
|
||||
$alice->succeed("ping -c 4 $carolIp6");
|
||||
$bob->succeed("ping -c 4 $carolIp6");
|
||||
alice.succeed("ping -c 4 {}".format(carol_ip6))
|
||||
bob.succeed("ping -c 4 {}".format(carol_ip6))
|
||||
|
||||
$carol->succeed("ping -c 4 $aliceIp6");
|
||||
$carol->succeed("ping -c 4 $bobIp6");
|
||||
carol.succeed("ping -c 4 {}".format(alice_ip6))
|
||||
carol.succeed("ping -c 4 {}".format(bob_ip6))
|
||||
|
||||
$alice->succeed("ping -c 4 $bobIp6");
|
||||
$bob->succeed("ping -c 4 $aliceIp6");
|
||||
alice.succeed("ping -c 4 {}".format(bob_ip6))
|
||||
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))
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
pkgs ? import ../.. { inherit system config; }
|
||||
}:
|
||||
|
||||
with import ../lib/testing.nix { inherit system pkgs; };
|
||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||
with pkgs.lib;
|
||||
|
||||
let
|
||||
|
@ -30,6 +30,7 @@ let
|
|||
'';
|
||||
};
|
||||
in makeTest {
|
||||
name = "cloud-init";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ lewo ];
|
||||
};
|
||||
|
@ -40,10 +41,12 @@ in makeTest {
|
|||
services.cloud-init.enable = true;
|
||||
};
|
||||
testScript = ''
|
||||
$machine->start;
|
||||
$machine->waitForUnit("cloud-init.service");
|
||||
$machine->succeed("cat /tmp/cloudinit-write-file | grep -q 'cloudinit'");
|
||||
machine.start()
|
||||
machine.wait_for_unit("cloud-init.service")
|
||||
machine.succeed("cat /tmp/cloudinit-write-file | grep -q 'cloudinit'")
|
||||
|
||||
$machine->waitUntilSucceeds("cat /root/.ssh/authorized_keys | grep -q 'should be a key!'");
|
||||
machine.wait_until_succeeds(
|
||||
"cat /root/.ssh/authorized_keys | grep -q 'should be a key!'"
|
||||
)
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, lib, ...}:
|
||||
import ./make-test-python.nix ({ pkgs, lib, ...}:
|
||||
|
||||
with lib;
|
||||
|
||||
|
@ -35,22 +35,42 @@ with lib;
|
|||
fi
|
||||
'';
|
||||
in ''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$couchdb1->waitForUnit("couchdb.service");
|
||||
$couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}");
|
||||
$couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}");
|
||||
$couchdb1->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}");
|
||||
$couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "3"}");
|
||||
$couchdb1->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}");
|
||||
$couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}");
|
||||
couchdb1.wait_for_unit("couchdb.service")
|
||||
couchdb1.wait_until_succeeds(
|
||||
"${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
|
||||
)
|
||||
couchdb1.wait_until_succeeds(
|
||||
"${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
|
||||
)
|
||||
couchdb1.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
|
||||
couchdb1.succeed(
|
||||
"${curlJqCheck "GET" "_all_dbs" ". | length" "3"}"
|
||||
)
|
||||
couchdb1.succeed(
|
||||
"${curlJqCheck "DELETE" "foo" ".ok" "true"}"
|
||||
)
|
||||
couchdb1.succeed(
|
||||
"${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
|
||||
)
|
||||
|
||||
$couchdb2->waitForUnit("couchdb.service");
|
||||
$couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}");
|
||||
$couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}");
|
||||
$couchdb2->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}");
|
||||
$couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "1"}");
|
||||
$couchdb2->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}");
|
||||
$couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}");
|
||||
couchdb2.wait_for_unit("couchdb.service")
|
||||
couchdb2.wait_until_succeeds(
|
||||
"${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
|
||||
)
|
||||
couchdb2.wait_until_succeeds(
|
||||
"${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
|
||||
)
|
||||
couchdb2.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
|
||||
couchdb2.succeed(
|
||||
"${curlJqCheck "GET" "_all_dbs" ". | length" "1"}"
|
||||
)
|
||||
couchdb2.succeed(
|
||||
"${curlJqCheck "DELETE" "foo" ".ok" "true"}"
|
||||
)
|
||||
couchdb2.succeed(
|
||||
"${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, ... }: {
|
||||
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "dnscrypt-proxy";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ joachifm ];
|
||||
|
@ -23,11 +23,13 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
$client->waitForUnit("dnsmasq");
|
||||
client.wait_for_unit("dnsmasq")
|
||||
|
||||
# The daemon is socket activated; sending a single ping should activate it.
|
||||
$client->fail("systemctl is-active dnscrypt-proxy");
|
||||
$client->execute("${pkgs.iputils}/bin/ping -c1 example.com");
|
||||
$client->waitUntilSucceeds("systemctl is-active dnscrypt-proxy");
|
||||
client.fail("systemctl is-active dnscrypt-proxy")
|
||||
client.execute(
|
||||
"${pkgs.iputils}/bin/ping -c1 example.com"
|
||||
)
|
||||
client.wait_until_succeeds("systemctl is-active dnscrypt-proxy")
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This test runs docker and checks if simple container starts
|
||||
|
||||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "docker";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ nequissimus offline ];
|
||||
|
@ -31,17 +31,19 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$docker->waitForUnit("sockets.target");
|
||||
$docker->succeed("tar cv --files-from /dev/null | docker import - scratchimg");
|
||||
$docker->succeed("docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10");
|
||||
$docker->succeed("docker ps | grep sleeping");
|
||||
$docker->succeed("sudo -u hasprivs docker ps");
|
||||
$docker->fail("sudo -u noprivs docker ps");
|
||||
$docker->succeed("docker stop sleeping");
|
||||
docker.wait_for_unit("sockets.target")
|
||||
docker.succeed("tar cv --files-from /dev/null | docker import - scratchimg")
|
||||
docker.succeed(
|
||||
"docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
|
||||
)
|
||||
docker.succeed("docker ps | grep sleeping")
|
||||
docker.succeed("sudo -u hasprivs docker ps")
|
||||
docker.fail("sudo -u noprivs docker ps")
|
||||
docker.succeed("docker stop sleeping")
|
||||
|
||||
# Must match version twice to ensure client and server versions are correct
|
||||
$docker->succeed('[ $(docker version | grep ${pkgs.docker-edge.version} | wc -l) = "2" ]');
|
||||
docker.succeed('[ $(docker version | grep ${pkgs.docker-edge.version} | wc -l) = "2" ]')
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This test runs docker and checks if simple container starts
|
||||
|
||||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "docker";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ nequissimus offline ];
|
||||
|
@ -31,17 +31,19 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$docker->waitForUnit("sockets.target");
|
||||
$docker->succeed("tar cv --files-from /dev/null | docker import - scratchimg");
|
||||
$docker->succeed("docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10");
|
||||
$docker->succeed("docker ps | grep sleeping");
|
||||
$docker->succeed("sudo -u hasprivs docker ps");
|
||||
$docker->fail("sudo -u noprivs docker ps");
|
||||
$docker->succeed("docker stop sleeping");
|
||||
docker.wait_for_unit("sockets.target")
|
||||
docker.succeed("tar cv --files-from /dev/null | docker import - scratchimg")
|
||||
docker.succeed(
|
||||
"docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
|
||||
)
|
||||
docker.succeed("docker ps | grep sleeping")
|
||||
docker.succeed("sudo -u hasprivs docker ps")
|
||||
docker.fail("sudo -u noprivs docker ps")
|
||||
docker.succeed("docker stop sleeping")
|
||||
|
||||
# Must match version twice to ensure client and server versions are correct
|
||||
$docker->succeed('[ $(docker version | grep ${pkgs.docker.version} | wc -l) = "2" ]');
|
||||
docker.succeed('[ $(docker version | grep ${pkgs.docker.version} | wc -l) = "2" ]')
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./make-test.nix ({ pkgs, lib, ...} : {
|
||||
import ./make-test-python.nix ({ pkgs, lib, ...} : {
|
||||
name = "documize";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ ma27 ];
|
||||
|
@ -29,30 +29,34 @@ import ./make-test.nix ({ pkgs, lib, ...} : {
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$machine->waitForUnit("documize-server.service");
|
||||
$machine->waitForOpenPort(3000);
|
||||
machine.wait_for_unit("documize-server.service")
|
||||
machine.wait_for_open_port(3000)
|
||||
|
||||
my $dbhash = $machine->succeed("curl -f localhost:3000 "
|
||||
. " | grep 'property=\"dbhash' "
|
||||
. " | grep -Po 'content=\"\\K[^\"]*'"
|
||||
);
|
||||
dbhash = machine.succeed(
|
||||
"curl -f localhost:3000 | grep 'property=\"dbhash' | grep -Po 'content=\"\\K[^\"]*'"
|
||||
)
|
||||
|
||||
chomp($dbhash);
|
||||
dbhash = dbhash.strip()
|
||||
|
||||
$machine->succeed("curl -X POST "
|
||||
. "--data 'dbname=documize' "
|
||||
. "--data 'dbhash=$dbhash' "
|
||||
. "--data 'title=NixOS' "
|
||||
. "--data 'message=Docs' "
|
||||
. "--data 'firstname=John' "
|
||||
. "--data 'lastname=Doe' "
|
||||
. "--data 'email=john.doe\@nixos.org' "
|
||||
. "--data 'password=verysafe' "
|
||||
. "-f localhost:3000/api/setup"
|
||||
);
|
||||
machine.succeed(
|
||||
(
|
||||
"curl -X POST"
|
||||
" --data 'dbname=documize'"
|
||||
" --data 'dbhash={}'"
|
||||
" --data 'title=NixOS'"
|
||||
" --data 'message=Docs'"
|
||||
" --data 'firstname=John'"
|
||||
" --data 'lastname=Doe'"
|
||||
" --data 'email=john.doe@nixos.org'"
|
||||
" --data 'password=verysafe'"
|
||||
" -f localhost:3000/api/setup"
|
||||
).format(dbhash)
|
||||
)
|
||||
|
||||
$machine->succeed('test "$(curl -f localhost:3000/api/public/meta | jq ".title" | xargs echo)" = "NixOS"');
|
||||
machine.succeed(
|
||||
'test "$(curl -f localhost:3000/api/public/meta | jq ".title" | xargs echo)" = "NixOS"'
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue