Merge pull request #78555 from tfc/limesurvey-utf8

nixosTests.limesurvey: port to python and drop badly utf encoded characters
This commit is contained in:
worldofpeace 2020-01-26 19:09:31 -05:00 committed by GitHub
commit 839be38cca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 88 deletions

View File

@ -395,7 +395,7 @@ class Machine:
status_code_pattern = re.compile(r"(.*)\|\!EOF\s+(\d+)")
while True:
chunk = self.shell.recv(4096).decode()
chunk = self.shell.recv(4096).decode(errors="ignore")
match = status_code_pattern.match(chunk)
if match:
output += match[1]

View File

@ -1,21 +1,26 @@
import ./make-test.nix ({ pkgs, ... }: {
import ./make-test-python.nix ({ pkgs, ... }: {
name = "limesurvey";
meta.maintainers = [ pkgs.stdenv.lib.maintainers.aanderse ];
machine =
{ ... }:
{ services.limesurvey.enable = true;
services.limesurvey.virtualHost.hostName = "example.local";
services.limesurvey.virtualHost.adminAddr = "root@example.local";
machine = { ... }: {
services.limesurvey = {
enable = true;
virtualHost = {
hostName = "example.local";
adminAddr = "root@example.local";
};
};
# limesurvey won't work without a dot in the hostname
networking.hosts."127.0.0.1" = [ "example.local" ];
};
testScript = ''
startAll;
start_all()
$machine->waitForUnit('phpfpm-limesurvey.service');
$machine->succeed('curl http://example.local/') =~ /The following surveys are available/ or die;
machine.wait_for_unit("phpfpm-limesurvey.service")
assert "The following surveys are available" in machine.succeed(
"curl http://example.local/"
)
'';
})

View File

@ -1,35 +1,30 @@
import ./make-test.nix ({ pkgs, ...} :
import ./make-test-python.nix ({ pkgs, ...} :
let
backend =
{ pkgs, ... }:
{ services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
services.httpd.virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
backend = { pkgs, ... }: {
services.httpd = {
enable = true;
adminAddr = "foo@example.org";
virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
};
networking.firewall.allowedTCPPorts = [ 80 ];
};
in
{
in {
name = "proxy";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ eelco ];
};
nodes =
{ proxy =
{ nodes, ... }:
{ services.httpd.enable = true;
services.httpd.adminAddr = "bar@example.org";
services.httpd.extraModules = [ "proxy_balancer" "lbmethod_byrequests" ];
services.httpd.extraConfig = ''
nodes = {
proxy = { nodes, ... }: {
services.httpd = {
enable = true;
adminAddr = "bar@example.org";
extraModules = [ "proxy_balancer" "lbmethod_byrequests" ];
extraConfig = ''
ExtendedStatus on
'';
services.httpd.virtualHosts.localhost = {
virtualHosts.localhost = {
extraConfig = ''
<Location /server-status>
Require all granted
@ -51,7 +46,7 @@ in
ProxyTimeout 5
'';
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
};
@ -61,37 +56,35 @@ in
client = { ... }: { };
};
testScript =
''
startAll;
testScript = ''
start_all()
$proxy->waitForUnit("httpd");
$backend1->waitForUnit("httpd");
$backend2->waitForUnit("httpd");
$client->waitForUnit("network.target");
proxy.wait_for_unit("httpd")
backend1.wait_for_unit("httpd")
backend2.wait_for_unit("httpd")
client.wait_for_unit("network.target")
# With the back-ends up, the proxy should work.
$client->succeed("curl --fail http://proxy/");
client.succeed("curl --fail http://proxy/")
$client->succeed("curl --fail http://proxy/server-status");
client.succeed("curl --fail http://proxy/server-status")
# Block the first back-end.
$backend1->block;
backend1.block()
# The proxy should still work.
$client->succeed("curl --fail http://proxy/");
$client->succeed("curl --fail http://proxy/");
client.succeed("curl --fail http://proxy/")
client.succeed("curl --fail http://proxy/")
# Block the second back-end.
$backend2->block;
backend2.block()
# Now the proxy should fail as well.
$client->fail("curl --fail http://proxy/");
client.fail("curl --fail http://proxy/")
# But if the second back-end comes back, the proxy should start
# working again.
$backend2->unblock;
$client->succeed("curl --fail http://proxy/");
backend2.unblock()
client.succeed("curl --fail http://proxy/")
'';
})