Merge pull request #72835 from tfc/nixos-integration-test-ports
Nixos integration test ports
This commit is contained in:
commit
3780b9e69c
@ -4,7 +4,9 @@ from contextlib import contextmanager
|
|||||||
from xml.sax.saxutils import XMLGenerator
|
from xml.sax.saxutils import XMLGenerator
|
||||||
import _thread
|
import _thread
|
||||||
import atexit
|
import atexit
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import ptpython.repl
|
||||||
import pty
|
import pty
|
||||||
import queue
|
import queue
|
||||||
import re
|
import re
|
||||||
@ -15,7 +17,6 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import ptpython.repl
|
|
||||||
|
|
||||||
CHAR_TO_KEY = {
|
CHAR_TO_KEY = {
|
||||||
"A": "shift-a",
|
"A": "shift-a",
|
||||||
@ -344,6 +345,18 @@ class Machine:
|
|||||||
)
|
)
|
||||||
return self.execute("systemctl {}".format(q))
|
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):
|
def execute(self, command):
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
@ -642,6 +655,27 @@ class Machine:
|
|||||||
if status == 0:
|
if status == 0:
|
||||||
return
|
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):
|
def sleep(self, secs):
|
||||||
time.sleep(secs)
|
time.sleep(secs)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ./make-test.nix ({ pkgs, ... }: {
|
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||||
name = "firefox";
|
name = "firefox";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ eelco shlevy ];
|
maintainers = [ eelco shlevy ];
|
||||||
@ -11,19 +11,27 @@ import ./make-test.nix ({ pkgs, ... }: {
|
|||||||
environment.systemPackages = [ pkgs.firefox pkgs.xdotool ];
|
environment.systemPackages = [ pkgs.firefox pkgs.xdotool ];
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript = ''
|
||||||
''
|
machine.wait_for_x()
|
||||||
$machine->waitForX;
|
|
||||||
$machine->execute("xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' &");
|
with subtest("wait until Firefox has finished loading the Valgrind docs page"):
|
||||||
$machine->waitForWindow(qr/Valgrind/);
|
machine.execute(
|
||||||
$machine->sleep(40); # wait until Firefox has finished loading the page
|
"xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' &"
|
||||||
$machine->execute("xdotool key space"); # do I want to make Firefox the
|
)
|
||||||
# default browser? I just want to close the dialog
|
machine.wait_for_window("Valgrind")
|
||||||
$machine->sleep(2); # wait until Firefox hides the default browser window
|
machine.sleep(40)
|
||||||
$machine->execute("xdotool key F12");
|
|
||||||
$machine->sleep(10); # wait until Firefox draws the developer tool panel
|
with subtest("Close default browser prompt"):
|
||||||
$machine->succeed("xwininfo -root -tree | grep Valgrind");
|
machine.execute("xdotool key space")
|
||||||
$machine->screenshot("screen");
|
|
||||||
|
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")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ./make-test.nix ({ pkgs, ... } : let
|
import ./make-test-python.nix ({ pkgs, ... } : let
|
||||||
|
|
||||||
|
|
||||||
runWithOpenSSL = file: cmd: pkgs.runCommand file {
|
runWithOpenSSL = file: cmd: pkgs.runCommand file {
|
||||||
@ -55,13 +55,17 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
startAll;
|
start_all()
|
||||||
$serverpostgres->waitForUnit("matrix-synapse.service");
|
serverpostgres.wait_for_unit("matrix-synapse.service")
|
||||||
$serverpostgres->waitUntilSucceeds("curl -L --cacert ${ca_pem} https://localhost:8448/");
|
serverpostgres.wait_until_succeeds(
|
||||||
$serverpostgres->requireActiveUnit("postgresql.service");
|
"curl -L --cacert ${ca_pem} https://localhost:8448/"
|
||||||
$serversqlite->waitForUnit("matrix-synapse.service");
|
)
|
||||||
$serversqlite->waitUntilSucceeds("curl -L --cacert ${ca_pem} https://localhost:8448/");
|
serverpostgres.require_unit_state("postgresql.service")
|
||||||
$serversqlite->mustSucceed("[ -e /var/lib/matrix-synapse/homeserver.db ]");
|
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 ]")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user