1import ./make-test-python.nix ({ pkgs, lib, ...} : {
2 name = "envoy";
3 meta = with pkgs.lib.maintainers; {
4 maintainers = [ cameronnemo ];
5 };
6
7 nodes.machine = { pkgs, ... }: {
8 services.envoy.enable = true;
9 services.envoy.settings = {
10 admin = {
11 access_log_path = "/dev/null";
12 address = {
13 socket_address = {
14 protocol = "TCP";
15 address = "127.0.0.1";
16 port_value = 80;
17 };
18 };
19 };
20 static_resources = {
21 listeners = [];
22 clusters = [];
23 };
24 };
25 specialisation = {
26 withoutConfigValidation.configuration = { ... }: {
27 services.envoy = {
28 requireValidConfig = false;
29 settings.admin.access_log_path = lib.mkForce "/var/log/envoy/access.log";
30 };
31 };
32 };
33 };
34
35 testScript = { nodes, ... }:
36 let
37 specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
38 in
39 ''
40 machine.start()
41
42 with subtest("envoy.service starts and responds with ready"):
43 machine.wait_for_unit("envoy.service")
44 machine.wait_for_open_port(80)
45 machine.wait_until_succeeds("curl -fsS localhost:80/ready")
46
47 with subtest("envoy.service works with config path not available at eval time"):
48 machine.succeed('${specialisations}/withoutConfigValidation/bin/switch-to-configuration test')
49 machine.wait_for_unit("envoy.service")
50 machine.wait_for_open_port(80)
51 machine.wait_until_succeeds("curl -fsS localhost:80/ready")
52 machine.succeed('test -f /var/log/envoy/access.log')
53 '';
54})