Skip to content

Commit 1e2b75f

Browse files
fix: integration test
1 parent 6feb484 commit 1e2b75f

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

nix/tests/default.nix

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,32 @@ let
3939
hydra = {
4040
port = toString 8080;
4141
mock = pkgs.writeText "hydra-mock" ''
42+
import json
4243
from http.server import BaseHTTPRequestHandler, HTTPServer
44+
45+
nixpkgs_url = "file://${dummy-nixpkgs}"
46+
with open("${dummy-nixpkgs}/REVISION") as f:
47+
revision = f.read().strip()
48+
49+
responses = {
50+
"jobset": {"inputs": {"nixpkgs": {"type": "git", "value": nixpkgs_url}}},
51+
"job": {"id": 1, "jobsetevals": [1]},
52+
"eval": {"id": 1, "jobsetevalinputs": {"nixpkgs": {"type": "git", "uri": nixpkgs_url, "revision": revision}}},
53+
}
54+
4355
class H(BaseHTTPRequestHandler):
4456
def do_GET(self):
57+
body = responses.get(self.path.split("/")[1])
58+
if body is None:
59+
self.send_response(404)
60+
self.end_headers()
61+
return
4562
self.send_response(200)
4663
self.send_header("Content-Type", "application/json")
4764
self.end_headers()
48-
self.wfile.write(b'${
49-
builtins.toJSON {
50-
inputs.nixpkgs.value = "file://${dummy-nixpkgs}";
51-
}
52-
}')
65+
self.wfile.write(json.dumps(body).encode())
5366
log_message = lambda *_: None
67+
5468
HTTPServer(("", ${hydra.port}), H).serve_forever()
5569
'';
5670
};

src/shared/management/commands/fetch_all_channels.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def handle(self, *args: Any, **kwargs: Any) -> str | None:
5252
# By pre-configuring the source location on our end, we're decoupling the routing (where to get the data) from the parameters (which piece of the data to get).
5353
# This slightly reduces our reliance on Hydra to be trustworthy:
5454
# Limit the blast radius of compromise to be denial of service for updates instead of silent poisoning of new data.
55-
assert settings.GIT_CLONE_URL == source.url, (
56-
f"Unexpected source URL: {source.url}"
55+
# FIXME(@fricklerhandwerk): The values should be directly comparable but for some reason aren't.
56+
assert str(settings.GIT_CLONE_URL) == str(source.url), (
57+
f"Unexpected source URL: {source.url!r}, expected {settings.GIT_CLONE_URL!r}"
5758
)
5859

5960
# FIXME(@fricklerhandwerk): Deduplicate the release branches beforehand.
@@ -73,7 +74,10 @@ def handle(self, *args: Any, **kwargs: Any) -> str | None:
7374
)
7475
evaluation = client.get_evaluation(latest_build.jobsetevals[0])
7576
eval_input = evaluation.jobsetevalinputs[settings.HYDRA_INPUT_NAME]
76-
assert eval_input.uri == source.url # Sanity check
77+
# FIXME(@fricklerhandwerk): The values should be directly comparable but for some reason aren't.
78+
assert str(eval_input.uri) == str(source.url), (
79+
f"Unexpected eval input URI: {eval_input.uri!r}, expected {source.url!r}"
80+
)
7781
commit = eval_input.revision
7882

7983
ch, created = NixChannel.objects.update_or_create(

0 commit comments

Comments
 (0)