python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / tests / nginx-etag.nix
blob6f45eacf8b41a389d56c0668af24ebf2345204de
1 import ./make-test-python.nix {
2   name = "nginx-etag";
4   nodes = {
5     server = { pkgs, lib, ... }: {
6       networking.firewall.enable = false;
7       services.nginx.enable = true;
8       services.nginx.virtualHosts.server = {
9         root = pkgs.runCommandLocal "testdir" {} ''
10           mkdir "$out"
11           cat > "$out/test.js" <<EOF
12           document.getElementById('foobar').setAttribute('foo', 'bar');
13           EOF
14           cat > "$out/index.html" <<EOF
15           <!DOCTYPE html>
16           <div id="foobar">test</div>
17           <script src="test.js"></script>
18           EOF
19         '';
20       };
22       specialisation.pass-checks.configuration = {
23         services.nginx.virtualHosts.server = {
24           root = lib.mkForce (pkgs.runCommandLocal "testdir2" {} ''
25             mkdir "$out"
26             cat > "$out/test.js" <<EOF
27             document.getElementById('foobar').setAttribute('foo', 'yay');
28             EOF
29             cat > "$out/index.html" <<EOF
30             <!DOCTYPE html>
31             <div id="foobar">test</div>
32             <script src="test.js"></script>
33             EOF
34           '');
35         };
36       };
37     };
39     client = { pkgs, lib, ... }: {
40       environment.systemPackages = let
41         testRunner = pkgs.writers.writePython3Bin "test-runner" {
42           libraries = [ pkgs.python3Packages.selenium ];
43         } ''
44           import os
45           import time
47           from selenium.webdriver import Firefox
48           from selenium.webdriver.firefox.options import Options
50           options = 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'):
60               time.sleep(0.5)
62           driver.get('http://server/')
63           driver.find_element('xpath', '//div[@foo="yay"]')
64           open('/tmp/passed', 'w')
65         '';
66       in [ pkgs.firefox-unwrapped pkgs.geckodriver testRunner ];
67     };
68   };
70   testScript = { nodes, ... }: let
71     inherit (nodes.server.config.system.build) toplevel;
72     newSystem = "${toplevel}/specialisation/pass-checks";
73   in ''
74     start_all()
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")
81     server.succeed(
82         "${newSystem}/bin/switch-to-configuration test >&2"
83     )
84     client.succeed("touch /tmp/proceed")
86     client.wait_for_file("/tmp/passed")
87   '';