git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #125683 from talyz/test-driver-pipefail

nixos/test-driver: Run commands with pipefail set

commitc177b49d39337415f6d0c67637fffdfab01dd3cb authorRobert Hensing <roberth@users.noreply.github.com> dateSun 6 Jun 2021, 10:42 (5 years ago) parent78d9a753d9c3e5
17 files changed+107−86
nixos/doc/manual/development/writing-nixos-tests.xml+23−2 nixos/lib/test-driver/test-driver.py+1−1 nixos/tests/calibre-web.nix+2−2 nixos/tests/docker-tools.nix+3−3 nixos/tests/doh-proxy-rust.nix+1−1 nixos/tests/elk.nix+1−1 nixos/tests/gitlab.nix+1−1 nixos/tests/gocd-agent.nix+1−1 nixos/tests/grafana.nix+4−4 nixos/tests/miniflux.nix+6−6 nixos/tests/nginx-variants.nix+1−1 nixos/tests/nginx.nix+2−2 nixos/tests/pomerium.nix+3−3 nixos/tests/prometheus-exporters.nix+50−50 nixos/tests/shiori.nix+1−1 nixos/tests/wiki-js.nix+3−3 nixos/tests/xandikos.nix+4−4
nixos/doc/manual/development/writing-nixos-tests.xml+23−2
@@ -274,8 +274,29 @@ start_all()
274274 </term>
275275 <listitem>
276276 <para>
277− Execute a shell command, raising an exception if the exit status is not
278− zero, otherwise returning the standard output.
277+ Execute a shell command, raising an exception if the exit status
278+ is not zero, otherwise returning the standard output. Commands
279+ are run with <literal>set -euo pipefail</literal> set:
280+ <itemizedlist>
281+ <listitem>
282+ <para>
283+ If several commands are separated by <literal>;</literal>
284+ and one fails, the command as a whole will fail.
285+ </para>
286+ </listitem>
287+ <listitem>
288+ <para>
289+ For pipelines, the last non-zero exit status will be
290+ returned (if there is one, zero will be returned
291+ otherwise).
292+ </para>
293+ </listitem>
294+ <listitem>
295+ <para>
296+ Dereferencing unset variables fail the command.
297+ </para>
298+ </listitem>
299+ </itemizedlist>
279300 </para>
280301 </listitem>
281302 </varlistentry>
nixos/lib/test-driver/test-driver.py+1−1
@@ -441,7 +441,7 @@ class Machine:
441441 def execute(self, command: str) -> Tuple[int, str]:
442442 self.connect()
443443
444− out_command = "( {} ); echo '|!=EOF' $?\n".format(command)
444+ out_command = "( set -euo pipefail; {} ); echo '|!=EOF' $?\n".format(command)
445445 self.shell.send(out_command.encode())
446446
447447 output = ""
nixos/tests/calibre-web.nix+2−2
@@ -36,7 +36,7 @@ import ./make-test-python.nix (
3636 default.wait_for_unit("calibre-web.service")
3737 default.wait_for_open_port(${toString defaultPort})
3838 default.succeed(
39− "curl --fail 'http://localhost:${toString defaultPort}/basicconfig' | grep -q 'Basic Configuration'"
39+ "curl --fail 'http://localhost:${toString defaultPort}/basicconfig' | grep 'Basic Configuration'"
4040 )
4141
4242 customized.succeed(
@@ -46,7 +46,7 @@ import ./make-test-python.nix (
4646 customized.wait_for_unit("calibre-web.service")
4747 customized.wait_for_open_port(${toString port})
4848 customized.succeed(
49− "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep -q test-book"
49+ "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep test-book"
5050 )
5151 '';
5252 }
nixos/tests/docker-tools.nix+3−3
@@ -23,15 +23,15 @@ import ./make-test-python.nix ({ pkgs, ... }: {
2323 with subtest("includeStorePath"):
2424 with subtest("assumption"):
2525 docker.succeed("${examples.helloOnRoot} | docker load")
26− docker.succeed("set -euo pipefail; docker run --rm hello | grep -i hello")
26+ docker.succeed("docker run --rm hello | grep -i hello")
2727 docker.succeed("docker image rm hello:latest")
2828 with subtest("includeStorePath = false; breaks example"):
2929 docker.succeed("${examples.helloOnRootNoStore} | docker load")
30− docker.fail("set -euo pipefail; docker run --rm hello | grep -i hello")
30+ docker.fail("docker run --rm hello | grep -i hello")
3131 docker.succeed("docker image rm hello:latest")
3232 with subtest("includeStorePath = false; works with mounted store"):
3333 docker.succeed("${examples.helloOnRootNoStore} | docker load")
34− docker.succeed("set -euo pipefail; docker run --rm --volume ${builtins.storeDir}:${builtins.storeDir}:ro hello | grep -i hello")
34+ docker.succeed("docker run --rm --volume ${builtins.storeDir}:${builtins.storeDir}:ro hello | grep -i hello")
3535 docker.succeed("docker image rm hello:latest")
3636
3737 with subtest("Ensure Docker images use a stable date by default"):
nixos/tests/doh-proxy-rust.nix+1−1
@@ -38,6 +38,6 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
3838 machine.wait_for_unit("doh-proxy-rust.service")
3939 machine.wait_for_open_port(53)
4040 machine.wait_for_open_port(3000)
41− machine.succeed(f"curl --fail '{url}?dns={query}' | grep -qF {bin_ip}")
41+ machine.succeed(f"curl --fail '{url}?dns={query}' | grep -F {bin_ip}")
4242 '';
4343})
nixos/tests/elk.nix+1−1
@@ -178,7 +178,7 @@ let
178178 one.systemctl("stop logstash")
179179 one.systemctl("start elasticsearch-curator")
180180 one.wait_until_succeeds(
181− '! curl --silent --show-error "${esUrl}/_cat/indices" | grep logstash | grep -q ^'
181+ '! curl --silent --show-error "${esUrl}/_cat/indices" | grep logstash | grep ^'
182182 )
183183 '';
184184 }) {};
nixos/tests/gitlab.nix+1−1
@@ -102,7 +102,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : with lib; {
102102 # `doSetup` is is true.
103103 test = doSetup: ''
104104 gitlab.succeed(
105− "curl -isSf http://gitlab | grep -i location | grep -q http://gitlab/users/sign_in"
105+ "curl -isSf http://gitlab | grep -i location | grep http://gitlab/users/sign_in"
106106 )
107107 gitlab.succeed(
108108 "${pkgs.sudo}/bin/sudo -u gitlab -H gitlab-rake gitlab:check 1>&2"
nixos/tests/gocd-agent.nix+1−1
@@ -42,7 +42,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
4242 "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].uuid"
4343 )
4444 agent.succeed(
45− "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep -q Idle"
45+ "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep Idle"
4646 )
4747 '';
4848})
nixos/tests/grafana.nix+4−4
@@ -74,7 +74,7 @@ in {
7474 declarativePlugins.wait_for_unit("grafana.service")
7575 declarativePlugins.wait_for_open_port(3000)
7676 declarativePlugins.succeed(
77− "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/plugins | grep -q grafana-clock-panel"
77+ "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/plugins | grep grafana-clock-panel"
7878 )
7979 declarativePlugins.shutdown()
8080
@@ -82,7 +82,7 @@ in {
8282 sqlite.wait_for_unit("grafana.service")
8383 sqlite.wait_for_open_port(3000)
8484 sqlite.succeed(
85− "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"
85+ "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep testadmin\@localhost"
8686 )
8787 sqlite.shutdown()
8888
@@ -92,7 +92,7 @@ in {
9292 postgresql.wait_for_open_port(3000)
9393 postgresql.wait_for_open_port(5432)
9494 postgresql.succeed(
95− "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"
95+ "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep testadmin\@localhost"
9696 )
9797 postgresql.shutdown()
9898
@@ -102,7 +102,7 @@ in {
102102 mysql.wait_for_open_port(3000)
103103 mysql.wait_for_open_port(3306)
104104 mysql.succeed(
105− "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"
105+ "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep testadmin\@localhost"
106106 )
107107 mysql.shutdown()
108108 '';
nixos/tests/miniflux.nix+6−6
@@ -48,23 +48,23 @@ with lib;
4848
4949 default.wait_for_unit("miniflux.service")
5050 default.wait_for_open_port(${toString defaultPort})
51− default.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep -q OK")
51+ default.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep OK")
5252 default.succeed(
53− "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep -q '\"is_admin\":true'"
53+ "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep '\"is_admin\":true'"
5454 )
5555
5656 withoutSudo.wait_for_unit("miniflux.service")
5757 withoutSudo.wait_for_open_port(${toString defaultPort})
58− withoutSudo.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep -q OK")
58+ withoutSudo.succeed("curl --fail 'http://localhost:${toString defaultPort}/healthcheck' | grep OK")
5959 withoutSudo.succeed(
60− "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep -q '\"is_admin\":true'"
60+ "curl 'http://localhost:${toString defaultPort}/v1/me' -u '${defaultUsername}:${defaultPassword}' -H Content-Type:application/json | grep '\"is_admin\":true'"
6161 )
6262
6363 customized.wait_for_unit("miniflux.service")
6464 customized.wait_for_open_port(${toString port})
65− customized.succeed("curl --fail 'http://localhost:${toString port}/healthcheck' | grep -q OK")
65+ customized.succeed("curl --fail 'http://localhost:${toString port}/healthcheck' | grep OK")
6666 customized.succeed(
67− "curl 'http://localhost:${toString port}/v1/me' -u '${username}:${password}' -H Content-Type:application/json | grep -q '\"is_admin\":true'"
67+ "curl 'http://localhost:${toString port}/v1/me' -u '${username}:${password}' -H Content-Type:application/json | grep '\"is_admin\":true'"
6868 )
6969 '';
7070})
nixos/tests/nginx-variants.nix+1−1
@@ -29,5 +29,5 @@ builtins.listToAttrs (
2929 };
3030 }
3131 )
32− [ "nginxStable" "nginxUnstable" "nginxShibboleth" "openresty" "tengine" ]
32+ [ "nginxStable" "nginxMainline" "nginxShibboleth" "openresty" "tengine" ]
3333)
nixos/tests/nginx.nix+2−2
@@ -56,11 +56,11 @@ import ./make-test-python.nix ({ pkgs, ... }: {
5656 };
5757
5858 specialisation.reloadRestartSystem.configuration = {
59− services.nginx.package = pkgs.nginxUnstable;
59+ services.nginx.package = pkgs.nginxMainline;
6060 };
6161
6262 specialisation.reloadWithErrorsSystem.configuration = {
63− services.nginx.package = pkgs.nginxUnstable;
63+ services.nginx.package = pkgs.nginxMainline;
6464 services.nginx.virtualHosts."!@$$(#*%".locations."~@#*$*!)".proxyPass = ";;;";
6565 };
6666 };
nixos/tests/pomerium.nix+3−3
@@ -88,15 +88,15 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
8888
8989 with subtest("no authentication required"):
9090 pomerium.succeed(
91− "curl --resolve my.website:80:127.0.0.1 http://my.website | grep -q 'hello world'"
91+ "curl --resolve my.website:80:127.0.0.1 http://my.website | grep 'hello world'"
9292 )
9393
9494 with subtest("login required"):
9595 pomerium.succeed(
96− "curl -I --resolve login.required:80:127.0.0.1 http://login.required | grep -q pom-auth"
96+ "curl -I --resolve login.required:80:127.0.0.1 http://login.required | grep pom-auth"
9797 )
9898 pomerium.succeed(
99− "curl -L --resolve login.required:80:127.0.0.1 http://login.required | grep -q 'hello I am login page'"
99+ "curl -L --resolve login.required:80:127.0.0.1 http://login.required | grep 'hello I am login page'"
100100 )
101101 '';
102102})
nixos/tests/prometheus-exporters.nix+50−50
@@ -71,7 +71,7 @@ let
7171 wait_for_open_port(3551)
7272 wait_for_unit("prometheus-apcupsd-exporter.service")
7373 wait_for_open_port(9162)
74− succeed("curl -sSf http://localhost:9162/metrics | grep -q 'apcupsd_info'")
74+ succeed("curl -sSf http://localhost:9162/metrics | grep 'apcupsd_info'")
7575 '';
7676 };
7777
@@ -85,7 +85,7 @@ let
8585 wait_for_unit("prometheus-artifactory-exporter.service")
8686 wait_for_open_port(9531)
8787 succeed(
88− "curl -sSf http://localhost:9531/metrics | grep -q 'artifactory_up'"
88+ "curl -sSf http://localhost:9531/metrics | grep 'artifactory_up'"
8989 )
9090 '';
9191 };
@@ -106,7 +106,7 @@ let
106106 wait_for_unit("prometheus-bind-exporter.service")
107107 wait_for_open_port(9119)
108108 succeed(
109− "curl -sSf http://localhost:9119/metrics | grep -q 'bind_query_recursions_total 0'"
109+ "curl -sSf http://localhost:9119/metrics | grep 'bind_query_recursions_total 0'"
110110 )
111111 '';
112112 };
@@ -135,7 +135,7 @@ let
135135 wait_for_unit("prometheus-bird-exporter.service")
136136 wait_for_open_port(9324)
137137 wait_until_succeeds(
138− "curl -sSf http://localhost:9324/metrics | grep -q 'MyObviousTestString'"
138+ "curl -sSf http://localhost:9324/metrics | grep 'MyObviousTestString'"
139139 )
140140 '';
141141 };
@@ -154,7 +154,7 @@ let
154154 wait_for_unit("prometheus-bitcoin-exporter.service")
155155 wait_for_unit("bitcoind-default.service")
156156 wait_for_open_port(9332)
157− succeed("curl -sSf http://localhost:9332/metrics | grep -q '^bitcoin_blocks '")
157+ succeed("curl -sSf http://localhost:9332/metrics | grep '^bitcoin_blocks '")
158158 '';
159159 };
160160
@@ -172,7 +172,7 @@ let
172172 wait_for_unit("prometheus-blackbox-exporter.service")
173173 wait_for_open_port(9115)
174174 succeed(
175− "curl -sSf 'http://localhost:9115/probe?target=localhost&module=icmp_v6' | grep -q 'probe_success 1'"
175+ "curl -sSf 'http://localhost:9115/probe?target=localhost&module=icmp_v6' | grep 'probe_success 1'"
176176 )
177177 '';
178178 };
@@ -204,7 +204,7 @@ let
204204 "curl -sSfH 'Content-Type: application/json' -X POST --data @/tmp/data.json localhost:9103/collectd"
205205 )
206206 succeed(
207− "curl -sSf localhost:9103/metrics | grep -q 'collectd_testplugin_gauge{instance=\"testhost\"} 23'"
207+ "curl -sSf localhost:9103/metrics | grep 'collectd_testplugin_gauge{instance=\"testhost\"} 23'"
208208 )
209209 '';
210210 };
@@ -220,7 +220,7 @@ let
220220 exporterTest = ''
221221 wait_for_unit("prometheus-dnsmasq-exporter.service")
222222 wait_for_open_port(9153)
223− succeed("curl -sSf http://localhost:9153/metrics | grep -q 'dnsmasq_leases 0'")
223+ succeed("curl -sSf http://localhost:9153/metrics | grep 'dnsmasq_leases 0'")
224224 '';
225225 };
226226
@@ -235,7 +235,7 @@ let
235235 wait_for_unit("prometheus-domain-exporter.service")
236236 wait_for_open_port(9222)
237237 succeed(
238− "curl -sSf 'http://localhost:9222/probe?target=nixos.org' | grep -q 'domain_probe_success 0'"
238+ "curl -sSf 'http://localhost:9222/probe?target=nixos.org' | grep 'domain_probe_success 0'"
239239 )
240240 '';
241241 };
@@ -254,7 +254,7 @@ let
254254 wait_for_unit("prometheus-dovecot-exporter.service")
255255 wait_for_open_port(9166)
256256 succeed(
257− "curl -sSf http://localhost:9166/metrics | grep -q 'dovecot_up{scope=\"global\"} 1'"
257+ "curl -sSf http://localhost:9166/metrics | grep 'dovecot_up{scope=\"global\"} 1'"
258258 )
259259 '';
260260 };
@@ -268,7 +268,7 @@ let
268268 wait_for_unit("prometheus-fritzbox-exporter.service")
269269 wait_for_open_port(9133)
270270 succeed(
271− "curl -sSf http://localhost:9133/metrics | grep -q 'fritzbox_exporter_collect_errors 0'"
271+ "curl -sSf http://localhost:9133/metrics | grep 'fritzbox_exporter_collect_errors 0'"
272272 )
273273 '';
274274 };
@@ -290,9 +290,9 @@ let
290290 wait_for_unit("prometheus-jitsi-exporter.service")
291291 wait_for_open_port(9700)
292292 wait_until_succeeds(
293− 'journalctl -eu prometheus-jitsi-exporter.service -o cat | grep -q "key=participants"'
293+ 'journalctl -eu prometheus-jitsi-exporter.service -o cat | grep "key=participants"'
294294 )
295− succeed("curl -sSf 'localhost:9700/metrics' | grep -q 'jitsi_participants 0'")
295+ succeed("curl -sSf 'localhost:9700/metrics' | grep 'jitsi_participants 0'")
296296 '';
297297 };
298298
@@ -321,7 +321,7 @@ let
321321 wait_for_unit("prometheus-json-exporter.service")
322322 wait_for_open_port(7979)
323323 succeed(
324− "curl -sSf 'localhost:7979/probe?target=http://localhost' | grep -q 'json_test_metric 1'"
324+ "curl -sSf 'localhost:7979/probe?target=http://localhost' | grep 'json_test_metric 1'"
325325 )
326326 '';
327327 };
@@ -426,7 +426,7 @@ let
426426 wait_for_unit("knot.service")
427427 wait_for_unit("prometheus-knot-exporter.service")
428428 wait_for_open_port(9433)
429− succeed("curl -sSf 'localhost:9433' | grep -q 'knot_server_zone_count 1.0'")
429+ succeed("curl -sSf 'localhost:9433' | grep 'knot_server_zone_count 1.0'")
430430 '';
431431 };
432432
@@ -441,10 +441,10 @@ let
441441 wait_for_unit("prometheus-keylight-exporter.service")
442442 wait_for_open_port(9288)
443443 succeed(
444− "curl -sS --write-out '%{http_code}' -o /dev/null http://localhost:9288/metrics | grep -q '400'"
444+ "curl -sS --write-out '%{http_code}' -o /dev/null http://localhost:9288/metrics | grep '400'"
445445 )
446446 succeed(
447− "curl -sS --write-out '%{http_code}' -o /dev/null http://localhost:9288/metrics?target=nosuchdevice | grep -q '500'"
447+ "curl -sS --write-out '%{http_code}' -o /dev/null http://localhost:9288/metrics?target=nosuchdevice | grep '500'"
448448 )
449449 '';
450450 };
@@ -489,7 +489,7 @@ let
489489 wait_for_open_port(10009)
490490 wait_for_unit("prometheus-lnd-exporter.service")
491491 wait_for_open_port(9092)
492− succeed("curl -sSf localhost:9092/metrics | grep -q '^promhttp_metric_handler'")
492+ succeed("curl -sSf localhost:9092/metrics | grep '^promhttp_metric_handler'")
493493 '';
494494 };
495495
@@ -531,7 +531,7 @@ let
531531 wait_for_unit("prometheus-mail-exporter.service")
532532 wait_for_open_port(9225)
533533 wait_until_succeeds(
534− "curl -sSf http://localhost:9225/metrics | grep -q 'mail_deliver_success{configname=\"testserver\"} 1'"
534+ "curl -sSf http://localhost:9225/metrics | grep 'mail_deliver_success{configname=\"testserver\"} 1'"
535535 )
536536 '';
537537 };
@@ -571,7 +571,7 @@ let
571571 wait_for_unit("prometheus-mikrotik-exporter.service")
572572 wait_for_open_port(9436)
573573 succeed(
574− "curl -sSf http://localhost:9436/metrics | grep -q 'mikrotik_scrape_collector_success{device=\"router\"} 0'"
574+ "curl -sSf http://localhost:9436/metrics | grep 'mikrotik_scrape_collector_success{device=\"router\"} 0'"
575575 )
576576 '';
577577 };
@@ -596,7 +596,7 @@ let
596596 wait_for_unit("prometheus-modemmanager-exporter.service")
597597 wait_for_open_port(9539)
598598 succeed(
599− "curl -sSf http://localhost:9539/metrics | grep -q 'modemmanager_info'"
599+ "curl -sSf http://localhost:9539/metrics | grep 'modemmanager_info'"
600600 )
601601 '';
602602 };
@@ -634,7 +634,7 @@ let
634634 wait_for_unit("nginx.service")
635635 wait_for_unit("prometheus-nextcloud-exporter.service")
636636 wait_for_open_port(9205)
637− succeed("curl -sSf http://localhost:9205/metrics | grep -q 'nextcloud_up 1'")
637+ succeed("curl -sSf http://localhost:9205/metrics | grep 'nextcloud_up 1'")
638638 '';
639639 };
640640
@@ -653,7 +653,7 @@ let
653653 wait_for_unit("nginx.service")
654654 wait_for_unit("prometheus-nginx-exporter.service")
655655 wait_for_open_port(9113)
656− succeed("curl -sSf http://localhost:9113/metrics | grep -q 'nginx_up 1'")
656+ succeed("curl -sSf http://localhost:9113/metrics | grep 'nginx_up 1'")
657657 '';
658658 };
659659
@@ -708,12 +708,12 @@ let
708708 succeed("curl http://localhost")
709709 execute("sleep 1")
710710 succeed(
711− "curl -sSf http://localhost:9117/metrics | grep 'filelogger_http_response_count_total' | grep -q 1"
711+ "curl -sSf http://localhost:9117/metrics | grep 'filelogger_http_response_count_total' | grep 1"
712712 )
713713 succeed("curl http://localhost:81")
714714 execute("sleep 1")
715715 succeed(
716− "curl -sSf http://localhost:9117/metrics | grep 'syslogger_http_response_count_total' | grep -q 1"
716+ "curl -sSf http://localhost:9117/metrics | grep 'syslogger_http_response_count_total' | grep 1"
717717 )
718718 '';
719719 };
@@ -726,7 +726,7 @@ let
726726 wait_for_unit("prometheus-node-exporter.service")
727727 wait_for_open_port(9100)
728728 succeed(
729− "curl -sSf http://localhost:9100/metrics | grep -q 'node_exporter_build_info{.\\+} 1'"
729+ "curl -sSf http://localhost:9100/metrics | grep 'node_exporter_build_info{.\\+} 1'"
730730 )
731731 '';
732732 };
@@ -786,7 +786,7 @@ let
786786 wait_for_open_port(389)
787787 wait_for_open_port(9330)
788788 wait_until_succeeds(
789− "curl -sSf http://localhost:9330/metrics | grep -q 'openldap_scrape{result=\"ok\"} 1'"
789+ "curl -sSf http://localhost:9330/metrics | grep 'openldap_scrape{result=\"ok\"} 1'"
790790 )
791791 '';
792792 };
@@ -812,7 +812,7 @@ let
812812 exporterTest = ''
813813 wait_for_unit("openvpn-test.service")
814814 wait_for_unit("prometheus-openvpn-exporter.service")
815− succeed("curl -sSf http://localhost:9176/metrics | grep -q 'openvpn_up{.*} 1'")
815+ succeed("curl -sSf http://localhost:9176/metrics | grep 'openvpn_up{.*} 1'")
816816 '';
817817 };
818818
@@ -828,9 +828,9 @@ let
828828 wait_for_file("/var/lib/postfix/queue/public/showq")
829829 wait_for_open_port(9154)
830830 succeed(
831− "curl -sSf http://localhost:9154/metrics | grep -q 'postfix_smtpd_connects_total 0'"
831+ "curl -sSf http://localhost:9154/metrics | grep 'postfix_smtpd_connects_total 0'"
832832 )
833− succeed("curl -sSf http://localhost:9154/metrics | grep -q 'postfix_up{.*} 1'")
833+ succeed("curl -sSf http://localhost:9154/metrics | grep 'postfix_up{.*} 1'")
834834 '';
835835 };
836836
@@ -847,20 +847,20 @@ let
847847 wait_for_open_port(9187)
848848 wait_for_unit("postgresql.service")
849849 succeed(
850− "curl -sSf http://localhost:9187/metrics | grep -q 'pg_exporter_last_scrape_error 0'"
850+ "curl -sSf http://localhost:9187/metrics | grep 'pg_exporter_last_scrape_error 0'"
851851 )
852− succeed("curl -sSf http://localhost:9187/metrics | grep -q 'pg_up 1'")
852+ succeed("curl -sSf http://localhost:9187/metrics | grep 'pg_up 1'")
853853 systemctl("stop postgresql.service")
854854 succeed(
855− "curl -sSf http://localhost:9187/metrics | grep -qv 'pg_exporter_last_scrape_error 0'"
855+ "curl -sSf http://localhost:9187/metrics | grep -v 'pg_exporter_last_scrape_error 0'"
856856 )
857− succeed("curl -sSf http://localhost:9187/metrics | grep -q 'pg_up 0'")
857+ succeed("curl -sSf http://localhost:9187/metrics | grep 'pg_up 0'")
858858 systemctl("start postgresql.service")
859859 wait_for_unit("postgresql.service")
860860 succeed(
861− "curl -sSf http://localhost:9187/metrics | grep -q 'pg_exporter_last_scrape_error 0'"
861+ "curl -sSf http://localhost:9187/metrics | grep 'pg_exporter_last_scrape_error 0'"
862862 )
863− succeed("curl -sSf http://localhost:9187/metrics | grep -q 'pg_up 1'")
863+ succeed("curl -sSf http://localhost:9187/metrics | grep 'pg_up 1'")
864864 '';
865865 };
866866
@@ -893,7 +893,7 @@ let
893893 wait_for_unit("prometheus-py-air-control-exporter.service")
894894 wait_for_open_port(9896)
895895 succeed(
896− "curl -sSf http://localhost:9896/metrics | grep -q 'py_air_control_sampling_error_total'"
896+ "curl -sSf http://localhost:9896/metrics | grep 'py_air_control_sampling_error_total'"
897897 )
898898 '';
899899 };
@@ -908,7 +908,7 @@ let
908908 wait_for_unit("prometheus-redis-exporter.service")
909909 wait_for_open_port(6379)
910910 wait_for_open_port(9121)
911− wait_until_succeeds("curl -sSf localhost:9121/metrics | grep -q 'redis_up 1'")
911+ wait_until_succeeds("curl -sSf localhost:9121/metrics | grep 'redis_up 1'")
912912 '';
913913 };
914914
@@ -926,7 +926,7 @@ let
926926 wait_for_open_port(11334)
927927 wait_for_open_port(7980)
928928 wait_until_succeeds(
929− "curl -sSf 'localhost:7980/probe?target=http://localhost:11334/stat' | grep -q 'rspamd_scanned{host=\"rspamd\"} 0'"
929+ "curl -sSf 'localhost:7980/probe?target=http://localhost:11334/stat' | grep 'rspamd_scanned{host=\"rspamd\"} 0'"
930930 )
931931 '';
932932 };
@@ -957,7 +957,7 @@ let
957957 wait_for_unit("prometheus-rtl_433-exporter.service")
958958 wait_for_open_port(9550)
959959 wait_until_succeeds(
960− "curl -sSf localhost:9550/metrics | grep -q '{}'".format(
960+ "curl -sSf localhost:9550/metrics | grep '{}'".format(
961961 'rtl_433_temperature_celsius{channel="3",id="55",location="",model="zopieux"} 18'
962962 )
963963 )
@@ -973,12 +973,12 @@ let
973973 wait_for_unit("prometheus-smokeping-exporter.service")
974974 wait_for_open_port(9374)
975975 wait_until_succeeds(
976− "curl -sSf localhost:9374/metrics | grep '{}' | grep -qv ' 0$'".format(
976+ "curl -sSf localhost:9374/metrics | grep '{}' | grep -v ' 0$'".format(
977977 'smokeping_requests_total{host="127.0.0.1",ip="127.0.0.1"} '
978978 )
979979 )
980980 wait_until_succeeds(
981− "curl -sSf localhost:9374/metrics | grep -q '{}'".format(
981+ "curl -sSf localhost:9374/metrics | grep '{}'".format(
982982 'smokeping_response_ttl{host="127.0.0.1",ip="127.0.0.1"}'
983983 )
984984 )
@@ -996,7 +996,7 @@ let
996996 exporterTest = ''
997997 wait_for_unit("prometheus-snmp-exporter.service")
998998 wait_for_open_port(9116)
999− succeed("curl -sSf localhost:9116/metrics | grep -q 'snmp_request_errors_total 0'")
999+ succeed("curl -sSf localhost:9116/metrics | grep 'snmp_request_errors_total 0'")
10001000 '';
10011001 };
10021002
@@ -1040,7 +1040,7 @@ let
10401040 exporterTest = ''
10411041 wait_for_unit("prometheus-sql-exporter.service")
10421042 wait_for_open_port(9237)
1043− succeed("curl http://localhost:9237/metrics | grep -c 'sql_points{' | grep -q 2")
1043+ succeed("curl http://localhost:9237/metrics | grep -c 'sql_points{' | grep 2")
10441044 '';
10451045 };
10461046
@@ -1063,7 +1063,7 @@ let
10631063 wait_for_open_port(80)
10641064 wait_for_unit("prometheus-surfboard-exporter.service")
10651065 wait_for_open_port(9239)
1066− succeed("curl -sSf localhost:9239/metrics | grep -q 'surfboard_up 1'")
1066+ succeed("curl -sSf localhost:9239/metrics | grep 'surfboard_up 1'")
10671067 '';
10681068 };
10691069
@@ -1076,7 +1076,7 @@ let
10761076 wait_for_unit("prometheus-systemd-exporter.service")
10771077 wait_for_open_port(9558)
10781078 succeed(
1079− "curl -sSf localhost:9558/metrics | grep -q '{}'".format(
1079+ "curl -sSf localhost:9558/metrics | grep '{}'".format(
10801080 'systemd_unit_state{name="basic.target",state="active",type="target"} 1'
10811081 )
10821082 )
@@ -1098,7 +1098,7 @@ let
10981098 wait_for_open_port(9051)
10991099 wait_for_unit("prometheus-tor-exporter.service")
11001100 wait_for_open_port(9130)
1101− succeed("curl -sSf localhost:9130/metrics | grep -q 'tor_version{.\\+} 1'")
1101+ succeed("curl -sSf localhost:9130/metrics | grep 'tor_version{.\\+} 1'")
11021102 '';
11031103 };
11041104
@@ -1110,7 +1110,7 @@ let
11101110 wait_for_unit("prometheus-unifi-poller-exporter.service")
11111111 wait_for_open_port(9130)
11121112 succeed(
1113− "curl -sSf localhost:9130/metrics | grep -q 'unifipoller_build_info{.\\+} 1'"
1113+ "curl -sSf localhost:9130/metrics | grep 'unifipoller_build_info{.\\+} 1'"
11141114 )
11151115 '';
11161116 };
@@ -1134,7 +1134,7 @@ let
11341134 wait_for_unit("unbound.service")
11351135 wait_for_unit("prometheus-unbound-exporter.service")
11361136 wait_for_open_port(9167)
1137− succeed("curl -sSf localhost:9167/metrics | grep -q 'unbound_up 1'")
1137+ succeed("curl -sSf localhost:9167/metrics | grep 'unbound_up 1'")
11381138 '';
11391139 };
11401140
@@ -1163,7 +1163,7 @@ let
11631163 wait_for_unit("prometheus-varnish-exporter.service")
11641164 wait_for_open_port(6081)
11651165 wait_for_open_port(9131)
1166− succeed("curl -sSf http://localhost:9131/metrics | grep -q 'varnish_up 1'")
1166+ succeed("curl -sSf http://localhost:9131/metrics | grep 'varnish_up 1'")
11671167 '';
11681168 };
11691169
nixos/tests/shiori.nix+1−1
@@ -28,7 +28,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...}:
2828 machine.wait_for_unit("shiori.service")
2929 machine.wait_for_open_port(8080)
3030 machine.succeed("curl --fail http://localhost:8080/")
31− machine.succeed("curl --fail --location http://localhost:8080/ | grep -qi shiori")
31+ machine.succeed("curl --fail --location http://localhost:8080/ | grep -i shiori")
3232
3333 with subtest("login"):
3434 auth_json = machine.succeed(
nixos/tests/wiki-js.nix+3−3
@@ -119,7 +119,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
119119
120120 with subtest("Setup"):
121121 result = machine.succeed(
122− "set -o pipefail; curl -sSf localhost:3000/finalize -X POST -d "
122+ "curl -sSf localhost:3000/finalize -X POST -d "
123123 + "@${payloads.finalize} -H 'Content-Type: application/json' "
124124 + "| jq .ok | xargs echo"
125125 )
@@ -132,7 +132,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
132132
133133 with subtest("Base functionality"):
134134 auth = machine.succeed(
135− "set -o pipefail; curl -sSf localhost:3000/graphql -X POST "
135+ "curl -sSf localhost:3000/graphql -X POST "
136136 + "-d @${payloads.login} -H 'Content-Type: application/json' "
137137 + "| jq '.[0].data.authentication.login.jwt' | xargs echo"
138138 ).strip()
@@ -140,7 +140,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
140140 assert auth
141141
142142 create = machine.succeed(
143− "set -o pipefail; curl -sSf localhost:3000/graphql -X POST "
143+ "curl -sSf localhost:3000/graphql -X POST "
144144 + "-d @${payloads.content} -H 'Content-Type: application/json' "
145145 + f"-H 'Authorization: Bearer {auth}' "
146146 + "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
nixos/tests/xandikos.nix+4−4
@@ -44,7 +44,7 @@ import ./make-test-python.nix (
4444 xandikos_default.wait_for_open_port(8080)
4545 xandikos_default.succeed("curl --fail http://localhost:8080/")
4646 xandikos_default.succeed(
47− "curl -s --fail --location http://localhost:8080/ | grep -qi Xandikos"
47+ "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
4848 )
4949 xandikos_client.wait_for_unit("network.target")
5050 xandikos_client.fail("curl --fail http://xandikos_default:8080/")
@@ -55,15 +55,15 @@ import ./make-test-python.nix (
5555 xandikos_proxy.wait_for_open_port(8080)
5656 xandikos_proxy.succeed("curl --fail http://localhost:8080/")
5757 xandikos_proxy.succeed(
58− "curl -s --fail --location http://localhost:8080/ | grep -qi Xandikos"
58+ "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
5959 )
6060 xandikos_client.wait_for_unit("network.target")
6161 xandikos_client.fail("curl --fail http://xandikos_proxy:8080/")
6262 xandikos_client.succeed(
63− "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -qi Xandikos"
63+ "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos"
6464 )
6565 xandikos_client.succeed(
66− "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -qi Xandikos"
66+ "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos"
6767 )
6868 '';
6969 }