diff --git a/nix/vm-tests/k8s-services.nix b/nix/vm-tests/k8s-services.nix index 0d6bbbf1c..b2db2629d 100644 --- a/nix/vm-tests/k8s-services.nix +++ b/nix/vm-tests/k8s-services.nix @@ -373,6 +373,9 @@ pkgs.testers.runNixOSTest { Type = "oneshot"; RemainAfterExit = true; User = legacyUser; + # k3s waits for this unit, so a record that never shows must fail it + # and not hold the boot. + TimeoutStartSec = 120; UMask = "0007"; ExecStartPre = "+${pkgs.writeShellScript "victorialogs-legacy-dir" '' mkdir -p ${vlDir} @@ -388,7 +391,8 @@ pkgs.testers.runNixOSTest { curl -sf --data-binary \ "{\"_msg\":\"written before the switch\",\"app\":\"legacy\",\"_time\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" \ 'http://127.0.0.1:${toString legacyPort}/insert/jsonline?_stream_fields=app' - until curl -s --data-urlencode 'query=legacy' http://127.0.0.1:${toString legacyPort}/select/logsql/query \ + # A bare word matches the message field, so the query names a word of it. + until curl -s --data-urlencode 'query=switch' http://127.0.0.1:${toString legacyPort}/select/logsql/query \ | grep -q 'written before the switch'; do sleep 1; done kill -TERM "$pid" wait "$pid" || true @@ -854,15 +858,15 @@ pkgs.testers.runNixOSTest { AGENT_TOKEN = f"swarm-agent.{AGENT}.{AGENT_SECRETS[AGENT]}" with subtest("an agent's bearer reads the record written before the switch through the gateway, and the other bearers are granted or refused as the store says"): - wait_for_record(AGENT_TOKEN, "legacy", "written before the switch") + wait_for_record(AGENT_TOKEN, "switch", "written before the switch") # Each refusal has the answer above as its control: the same request with # a bearer the store grants. - assert vl_query(f"swarm-agent.{OTHER_AGENT}.{AGENT_SECRETS[OTHER_AGENT]}", "legacy")[0] == 403 - assert vl_query(f"swarm-agent.{AGENT}.{'0' * 32}", "legacy")[0] == 401 + assert vl_query(f"swarm-agent.{OTHER_AGENT}.{AGENT_SECRETS[OTHER_AGENT]}", "switch")[0] == 403 + assert vl_query(f"swarm-agent.{AGENT}.{'0' * 32}", "switch")[0] == 401 # Grafana's bearer goes to the second responder of the same pod. - status, body = vl_query(GRAFANA_BEARER, "legacy") + status, body = vl_query(GRAFANA_BEARER, "switch") assert status == 200 and "written before the switch" in body, (status, body) - assert vl_query("0" * 64, "legacy")[0] == 401 + assert vl_query("0" * 64, "switch")[0] == 401 with subtest("a record posted to the ingest route and the store's own metrics come through the gateway, and a restarted pod still holds both records"): import base64 @@ -892,7 +896,7 @@ pkgs.testers.runNixOSTest { assert status == 200 and "vl_" in body, (status, body[:200]) kube(machine, f"delete pod {vl_pod} --wait=true", timeout=120) vl_pod = wait_pod_ready(VL) - wait_for_record(AGENT_TOKEN, "legacy", "written before the switch") + wait_for_record(AGENT_TOKEN, "switch", "written before the switch") wait_for_record(AGENT_TOKEN, "gateway", "written through the gateway") with subtest("only the node reaches the log store's pods, and the responders' pod reaches the store's pod listener and no other port of the host"):