Skip to content

Commit fbcc630

Browse files
committed
chore: add VM test
libfakecache is not needed anymore. we're using NixOS VM tests to test the functionality of the cache.
1 parent 7bca661 commit fbcc630

File tree

5 files changed

+72
-71
lines changed

5 files changed

+72
-71
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ In your NixOS configuration:
4747
}
4848
```
4949

50+
TLS/ACME (when `forceSSL = true`, the default):
51+
52+
```
53+
security.acme = {
54+
acceptTerms = true;
55+
defaults.email = "[email protected]";
56+
};
57+
```
58+
5059
## Point Clients At It
5160

5261
NixOS:
@@ -134,3 +143,7 @@ extra-substituters = https://hetzner-cache.numtide.com
134143
## Support
135144

136145
Maintained by Numtide. Issues and contributions welcome.
146+
147+
## License
148+
149+
MIT — see `LICENSE`.

checks/nixos-smoke.nix

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{ pkgs, ... }:
2+
let
3+
module = import ../modules/nixos/nixos-passthru-cache;
4+
in
5+
pkgs.nixosTest {
6+
name = "nixos-passthru-cache-smoke";
7+
8+
nodes.machine = { pkgs, ... }: {
9+
imports = [ module ];
10+
11+
# Fake upstream served by the same nginx on 127.0.0.1:1234
12+
services.nginx.virtualHosts."fake-upstream" = {
13+
listen = [{ addr = "127.0.0.1"; port = 1234; ssl = false; }];
14+
serverName = "fake-upstream";
15+
locations."/".extraConfig = ''
16+
add_header Cache-Control "max-age=3600";
17+
add_header X-Fake-Upstream 1;
18+
return 200 "hello from upstream\n";
19+
'';
20+
};
21+
22+
services.nixos-passthru-cache = {
23+
enable = true;
24+
forceSSL = false;
25+
hostName = "cache.local";
26+
upstream = "http://127.0.0.1:1234";
27+
stats.enable = true;
28+
};
29+
30+
# Keep things simple for the test
31+
networking.firewall.enable = false;
32+
environment.systemPackages = [ pkgs.curl ];
33+
};
34+
35+
testScript = ''
36+
start_all()
37+
machine.wait_for_unit("nginx.service")
38+
machine.wait_for_open_port(80)
39+
machine.wait_for_open_port(1234)
40+
41+
# nix-cache-info served with correct content-type and content
42+
machine.succeed("curl -sSfI http://localhost/nix-cache-info | grep -qi 'content-type: text/x-nix-cache-info'")
43+
machine.succeed("curl -sSf http://localhost/nix-cache-info | grep -q '^StoreDir:'")
44+
45+
# Cache MISS then HIT against fake upstream
46+
machine.succeed("curl -sSfi http://localhost/foo | tee /tmp/res1 | grep -qi '^X-Cache-Status: MISS' || (echo 'expected MISS' && cat /tmp/res1 && false)")
47+
machine.succeed("curl -sSfi http://localhost/foo | tee /tmp/res2 | grep -qi '^X-Cache-Status: HIT' || (echo 'expected HIT' && cat /tmp/res2 && false)")
48+
49+
# VTS status page reachable (HTML)
50+
machine.succeed("curl -sSfI http://localhost/status | grep -q '200'")
51+
'';
52+
}

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
description = "my flake";
2+
description = "nixos-passthru-cache - Pull-through cache for Nix";
33

44
# Add all your dependencies here
55
inputs = {

packages/libfakecache.nix

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)