nixosTests.nginx*: review fixes
Co-Authored-By: Florian Klink <flokli@flokli.de>
This commit is contained in:
parent
1c2781d39c
commit
abbce768dc
|
@ -72,35 +72,32 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||||
url = "http://localhost/index.html"
|
url = "http://localhost/index.html"
|
||||||
|
|
||||||
|
|
||||||
def checkEtag():
|
def check_etag():
|
||||||
etag = webserver.succeed(
|
etag = webserver.succeed(f'curl -v {url} 2>&1 | sed -n -e "s/^< etag: *//ip"')
|
||||||
f'curl -v {url} 2>&1 | sed -n -e "s/^< [Ee][Tt][Aa][Gg]: *//p"'
|
http_code = webserver.succeed(
|
||||||
)
|
|
||||||
httpCode = webserver.succeed(
|
|
||||||
f"curl -w '%{http_code}' -X HEAD -H 'If-None-Match: {etag}' {url}"
|
f"curl -w '%{http_code}' -X HEAD -H 'If-None-Match: {etag}' {url}"
|
||||||
)
|
)
|
||||||
assert httpCode == "304"
|
assert http_code == "304"
|
||||||
|
|
||||||
return etag
|
return etag
|
||||||
|
|
||||||
|
|
||||||
webserver.wait_for_unit("nginx")
|
webserver.wait_for_unit("nginx")
|
||||||
webserver.wait_for_open_port("80")
|
webserver.wait_for_open_port(80)
|
||||||
|
|
||||||
with subtest("check ETag if serving Nix store paths"):
|
with subtest("check ETag if serving Nix store paths"):
|
||||||
oldEtag = checkEtag
|
old_etag = check_etag()
|
||||||
webserver.succeed(
|
webserver.succeed(
|
||||||
"${etagSystem}/bin/switch-to-configuration test >&2"
|
"${etagSystem}/bin/switch-to-configuration test >&2"
|
||||||
)
|
)
|
||||||
webserver.sleep(1) # race condition
|
new_etag = check_etag()
|
||||||
newEtag = checkEtag
|
assert old_etag != new_etag
|
||||||
assert oldEtag != newEtag
|
|
||||||
|
|
||||||
with subtest("config is reloaded on nixos-rebuild switch"):
|
with subtest("config is reloaded on nixos-rebuild switch"):
|
||||||
webserver.succeed(
|
webserver.succeed(
|
||||||
"${justReloadSystem}/bin/switch-to-configuration test >&2"
|
"${justReloadSystem}/bin/switch-to-configuration test >&2"
|
||||||
)
|
)
|
||||||
webserver.wait_for_open_port("8080")
|
webserver.wait_for_open_port(8080)
|
||||||
webserver.fail("journalctl -u nginx | grep -q -i stopped")
|
webserver.fail("journalctl -u nginx | grep -q -i stopped")
|
||||||
webserver.succeed("journalctl -u nginx | grep -q -i reloaded")
|
webserver.succeed("journalctl -u nginx | grep -q -i reloaded")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue