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: a46c78142e37
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3780b9e69caa
Choose a head ref
  • 5 commits
  • 3 files changed
  • 2 contributors

Commits on Nov 5, 2019

  1. Copy the full SHA
    9c54658 View commit details
  2. Copy the full SHA
    fdb72f6 View commit details
  3. Copy the full SHA
    45b339b View commit details
  4. Copy the full SHA
    d6b7a99 View commit details

Commits on Nov 7, 2019

  1. Merge pull request #72835 from tfc/nixos-integration-test-ports

    Nixos integration test ports
    worldofpeace authored Nov 7, 2019
    Copy the full SHA
    3780b9e View commit details
Showing with 69 additions and 23 deletions.
  1. +35 −1 nixos/lib/test-driver/test-driver.py
  2. +22 −14 nixos/tests/firefox.nix
  3. +12 −8 nixos/tests/matrix-synapse.nix
36 changes: 35 additions & 1 deletion nixos/lib/test-driver/test-driver.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@
from xml.sax.saxutils import XMLGenerator
import _thread
import atexit
import json
import os
import ptpython.repl
import pty
import queue
import re
@@ -15,7 +17,6 @@
import tempfile
import time
import unicodedata
import ptpython.repl

CHAR_TO_KEY = {
"A": "shift-a",
@@ -344,6 +345,18 @@ def systemctl(self, q, user=None):
)
return self.execute("systemctl {}".format(q))

def require_unit_state(self, unit, require_state="active"):
with self.nested(
"checking if unit ‘{}’ has reached state '{}'".format(unit, require_state)
):
info = self.get_unit_info(unit)
state = info["ActiveState"]
if state != require_state:
raise Exception(
"Expected unit ‘{}’ to to be in state ".format(unit)
+ "'active' but it is in state ‘{}’".format(state)
)

def execute(self, command):
self.connect()

@@ -642,6 +655,27 @@ def wait_for_x(self):
if status == 0:
return

def get_window_names(self):
return self.succeed(
r"xwininfo -root -tree | sed 's/.*0x[0-9a-f]* \"\([^\"]*\)\".*/\1/; t; d'"
).splitlines()

def wait_for_window(self, regexp):
pattern = re.compile(regexp)

def window_is_visible(last_try):
names = self.get_window_names()
if last_try:
self.log(
"Last chance to match {} on the window list,".format(regexp)
+ " which currently contains: "
+ ", ".join(names)
)
return any(pattern.search(name) for name in names)

with self.nested("Waiting for a window to appear"):
retry(window_is_visible)

def sleep(self, secs):
time.sleep(secs)

36 changes: 22 additions & 14 deletions nixos/tests/firefox.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... }: {
import ./make-test-python.nix ({ pkgs, ... }: {
name = "firefox";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ eelco shlevy ];
@@ -11,19 +11,27 @@ import ./make-test.nix ({ pkgs, ... }: {
environment.systemPackages = [ pkgs.firefox pkgs.xdotool ];
};

testScript =
''
$machine->waitForX;
$machine->execute("xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' &");
$machine->waitForWindow(qr/Valgrind/);
$machine->sleep(40); # wait until Firefox has finished loading the page
$machine->execute("xdotool key space"); # do I want to make Firefox the
# default browser? I just want to close the dialog
$machine->sleep(2); # wait until Firefox hides the default browser window
$machine->execute("xdotool key F12");
$machine->sleep(10); # wait until Firefox draws the developer tool panel
$machine->succeed("xwininfo -root -tree | grep Valgrind");
$machine->screenshot("screen");
testScript = ''
machine.wait_for_x()
with subtest("wait until Firefox has finished loading the Valgrind docs page"):
machine.execute(
"xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' &"
)
machine.wait_for_window("Valgrind")
machine.sleep(40)
with subtest("Close default browser prompt"):
machine.execute("xdotool key space")
with subtest("Hide default browser window"):
machine.sleep(2)
machine.execute("xdotool key F12")
with subtest("wait until Firefox draws the developer tool panel"):
machine.sleep(10)
machine.succeed("xwininfo -root -tree | grep Valgrind")
machine.screenshot("screen")
'';

})
20 changes: 12 additions & 8 deletions nixos/tests/matrix-synapse.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ./make-test.nix ({ pkgs, ... } : let
import ./make-test-python.nix ({ pkgs, ... } : let


runWithOpenSSL = file: cmd: pkgs.runCommand file {
@@ -55,13 +55,17 @@ in {
};

testScript = ''
startAll;
$serverpostgres->waitForUnit("matrix-synapse.service");
$serverpostgres->waitUntilSucceeds("curl -L --cacert ${ca_pem} https://localhost:8448/");
$serverpostgres->requireActiveUnit("postgresql.service");
$serversqlite->waitForUnit("matrix-synapse.service");
$serversqlite->waitUntilSucceeds("curl -L --cacert ${ca_pem} https://localhost:8448/");
$serversqlite->mustSucceed("[ -e /var/lib/matrix-synapse/homeserver.db ]");
start_all()
serverpostgres.wait_for_unit("matrix-synapse.service")
serverpostgres.wait_until_succeeds(
"curl -L --cacert ${ca_pem} https://localhost:8448/"
)
serverpostgres.require_unit_state("postgresql.service")
serversqlite.wait_for_unit("matrix-synapse.service")
serversqlite.wait_until_succeeds(
"curl -L --cacert ${ca_pem} https://localhost:8448/"
)
serversqlite.succeed("[ -e /var/lib/matrix-synapse/homeserver.db ]")
'';

})