Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 92c91c0923d7
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 839be38ccaf6
Choose a head ref
  • 4 commits
  • 3 files changed
  • 2 contributors

Commits on Jan 26, 2020

  1. nixosTests: Drop invalid utf characters in command output

    Jacek Galowicz committed Jan 26, 2020
    Copy the full SHA
    f63ef28 View commit details
  2. nixosTests.limesurvey: Port to python

    Jacek Galowicz committed Jan 26, 2020
    Copy the full SHA
    4df1df9 View commit details
  3. nixosTests.proxy: Port to python

    Jacek Galowicz committed Jan 26, 2020
    Copy the full SHA
    ee2acd6 View commit details

Commits on Jan 27, 2020

  1. Merge pull request #78555 from tfc/limesurvey-utf8

    nixosTests.limesurvey: port to python and drop badly utf encoded characters
    worldofpeace authored Jan 27, 2020
    Copy the full SHA
    839be38 View commit details
Showing with 86 additions and 88 deletions.
  1. +1 −1 nixos/lib/test-driver/test-driver.py
  2. +17 −12 nixos/tests/limesurvey.nix
  3. +68 −75 nixos/tests/proxy.nix
2 changes: 1 addition & 1 deletion nixos/lib/test-driver/test-driver.py
Original file line number Diff line number Diff line change
@@ -395,7 +395,7 @@ def execute(self, command: str) -> Tuple[int, str]:
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]
29 changes: 17 additions & 12 deletions nixos/tests/limesurvey.nix
Original file line number Diff line number Diff line change
@@ -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";

# limesurvey won't work without a dot in the hostname
networking.hosts."127.0.0.1" = [ "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/"
)
'';
})
143 changes: 68 additions & 75 deletions nixos/tests/proxy.nix
Original file line number Diff line number Diff line change
@@ -1,97 +1,90 @@
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";
networking.firewall.allowedTCPPorts = [ 80 ];
backend = { pkgs, ... }: {
services.httpd = {
enable = true;
adminAddr = "foo@example.org";
virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
};

in

{
networking.firewall.allowedTCPPorts = [ 80 ];
};
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 = ''
ExtendedStatus on
nodes = {
proxy = { nodes, ... }: {
services.httpd = {
enable = true;
adminAddr = "bar@example.org";
extraModules = [ "proxy_balancer" "lbmethod_byrequests" ];
extraConfig = ''
ExtendedStatus on
'';
virtualHosts.localhost = {
extraConfig = ''
<Location /server-status>
Require all granted
SetHandler server-status
</Location>
<Proxy balancer://cluster>
Require all granted
BalancerMember http://${nodes.backend1.config.networking.hostName} retry=0
BalancerMember http://${nodes.backend2.config.networking.hostName} retry=0
</Proxy>
ProxyStatus full
ProxyPass /server-status !
ProxyPass / balancer://cluster/
ProxyPassReverse / balancer://cluster/
# For testing; don't want to wait forever for dead backend servers.
ProxyTimeout 5
'';
services.httpd.virtualHosts.localhost = {
extraConfig = ''
<Location /server-status>
Require all granted
SetHandler server-status
</Location>
<Proxy balancer://cluster>
Require all granted
BalancerMember http://${nodes.backend1.config.networking.hostName} retry=0
BalancerMember http://${nodes.backend2.config.networking.hostName} retry=0
</Proxy>
ProxyStatus full
ProxyPass /server-status !
ProxyPass / balancer://cluster/
ProxyPassReverse / balancer://cluster/
# For testing; don't want to wait forever for dead backend servers.
ProxyTimeout 5
'';
};

networking.firewall.allowedTCPPorts = [ 80 ];
};

backend1 = backend;
backend2 = backend;

client = { ... }: { };
};
networking.firewall.allowedTCPPorts = [ 80 ];
};

testScript =
''
startAll;
backend1 = backend;
backend2 = backend;

client = { ... }: { };
};

$proxy->waitForUnit("httpd");
$backend1->waitForUnit("httpd");
$backend2->waitForUnit("httpd");
$client->waitForUnit("network.target");
testScript = ''
start_all()
# With the back-ends up, the proxy should work.
$client->succeed("curl --fail http://proxy/");
proxy.wait_for_unit("httpd")
backend1.wait_for_unit("httpd")
backend2.wait_for_unit("httpd")
client.wait_for_unit("network.target")
$client->succeed("curl --fail http://proxy/server-status");
# With the back-ends up, the proxy should work.
client.succeed("curl --fail http://proxy/")
# Block the first back-end.
$backend1->block;
client.succeed("curl --fail http://proxy/server-status")
# The proxy should still work.
$client->succeed("curl --fail http://proxy/");
# Block the first back-end.
backend1.block()
$client->succeed("curl --fail http://proxy/");
# The proxy should still work.
client.succeed("curl --fail http://proxy/")
client.succeed("curl --fail http://proxy/")
# Block the second back-end.
$backend2->block;
# Block the second back-end.
backend2.block()
# Now the proxy should fail as well.
$client->fail("curl --fail http://proxy/");
# Now the proxy should fail as well.
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/");
'';
# But if the second back-end comes back, the proxy should start
# working again.
backend2.unblock()
client.succeed("curl --fail http://proxy/")
'';
})