Skip to content

Commit 6f0bdd9

Browse files
committed
tests: Wait for network *online* targets
More prevalent than I thought in 15073e8 See also https://github.com/NixOS/nix/actions/runs/12872412321/job/35887830320?pr=12310 which is a failed github-flakes test without "Network is Online"
1 parent fcc501b commit 6f0bdd9

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

tests/nixos/git-submodules.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
remote.wait_for_unit("sshd")
4747
remote.wait_for_unit("multi-user.target")
4848
remote.wait_for_unit("network-online.target")
49+
client.wait_for_unit("network-online.target")
4950
client.succeed(f"ssh -o StrictHostKeyChecking=no {remote.name} 'echo hello world'")
5051
5152
remote.succeed("""

tests/nixos/github-flakes.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ in
161161
github.succeed("cat /var/log/httpd/*.log >&2")
162162
163163
github.wait_for_unit("httpd.service")
164+
github.wait_for_unit("network-online.target")
164165
166+
client.wait_for_unit("network-online.target")
165167
client.succeed("curl -v https://github.com/ >&2")
166168
out = client.succeed("nix registry list")
167169
print(out)

tests/nixos/nix-docker.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ in {
3737

3838
testScript = { nodes }: ''
3939
cache.wait_for_unit("harmonia.service")
40+
cache.wait_for_unit("network-online.target")
4041
4142
machine.succeed("mkdir -p /etc/containers")
4243
machine.succeed("""echo '{"default":[{"type":"insecureAcceptAnything"}]}' > /etc/containers/policy.json""")

tests/nixos/nss-preload.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ in
102102
};
103103

104104
testScript = { nodes, ... }: ''
105+
http_dns.wait_for_unit("network-online.target")
105106
http_dns.wait_for_unit("nginx")
106107
http_dns.wait_for_open_port(80)
107108
http_dns.wait_for_unit("unbound")
108109
http_dns.wait_for_open_port(53)
109110
110111
client.start()
111112
client.wait_for_unit('multi-user.target')
113+
client.wait_for_unit('network-online.target')
112114
113115
with subtest("can fetch data from a remote server outside sandbox"):
114116
client.succeed("nix --version >&2")

tests/nixos/s3-binary-cache-store.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ in {
5252
5353
# Create a binary cache.
5454
server.wait_for_unit("minio")
55+
server.wait_for_unit("network-online.target")
5556
5657
server.succeed("mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4")
5758
server.succeed("mc mb minio/my-cache")
5859
5960
server.succeed("${env} nix copy --to '${storeUrl}' ${pkgA}")
6061
62+
client.wait_for_unit("network-online.target")
63+
6164
# Test fetchurl on s3:// URLs while we're at it.
6265
client.succeed("${env} nix eval --impure --expr 'builtins.fetchurl { name = \"foo\"; url = \"s3://my-cache/nix-cache-info?endpoint=http://server:9000&region=eu-west-1\"; }'")
6366

tests/nixos/sourcehut-flakes.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ in
122122
start_all()
123123
124124
sourcehut.wait_for_unit("httpd.service")
125+
sourcehut.wait_for_unit("network-online.target")
126+
client.wait_for_unit("network-online.target")
125127
126128
client.succeed("curl -v https://git.sr.ht/ >&2")
127129
client.succeed("nix registry list | grep nixpkgs")

0 commit comments

Comments
 (0)