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