1 import ./make-test-python.nix {
5 server = { pkgs, lib, ... }: {
6 networking.firewall.enable = false;
7 services.nginx.enable = true;
8 services.nginx.virtualHosts.server = {
9 root = pkgs.runCommandLocal "testdir" {} ''
11 cat > "$out/test.js" <<EOF
12 document.getElementById('foobar').setAttribute('foo', 'bar');
14 cat > "$out/index.html" <<EOF
16 <div id="foobar">test</div>
17 <script src="test.js"></script>
22 specialisation.pass-checks.configuration = {
23 services.nginx.virtualHosts.server = {
24 root = lib.mkForce (pkgs.runCommandLocal "testdir2" {} ''
26 cat > "$out/test.js" <<EOF
27 document.getElementById('foobar').setAttribute('foo', 'yay');
29 cat > "$out/index.html" <<EOF
31 <div id="foobar">test</div>
32 <script src="test.js"></script>
39 client = { pkgs, lib, ... }: {
40 environment.systemPackages = let
41 testRunner = pkgs.writers.writePython3Bin "test-runner" {
42 libraries = [ pkgs.python3Packages.selenium ];
47 from selenium.webdriver import Firefox
48 from selenium.webdriver.firefox.options import Options
51 options.add_argument('--headless')
52 driver = Firefox(options=options)
54 driver.implicitly_wait(20)
55 driver.get('http://server/')
56 driver.find_element('xpath', '//div[@foo="bar"]')
57 open('/tmp/passed_stage1', 'w')
59 while not os.path.exists('/tmp/proceed'):
62 driver.get('http://server/')
63 driver.find_element('xpath', '//div[@foo="yay"]')
64 open('/tmp/passed', 'w')
66 in [ pkgs.firefox-unwrapped pkgs.geckodriver testRunner ];
70 testScript = { nodes, ... }: let
71 inherit (nodes.server.config.system.build) toplevel;
72 newSystem = "${toplevel}/specialisation/pass-checks";
76 server.wait_for_unit("nginx.service")
77 client.wait_for_unit("multi-user.target")
78 client.execute("test-runner >&2 &")
79 client.wait_for_file("/tmp/passed_stage1")
82 "${newSystem}/bin/switch-to-configuration test >&2"
84 client.succeed("touch /tmp/proceed")
86 client.wait_for_file("/tmp/passed")