nixos/tests/envoy: migrate to runTests

This commit is contained in:
Adam C. Stephens 2025-03-31 17:17:52 -04:00
parent d237b5096b
commit 6ac38abf29
No known key found for this signature in database
2 changed files with 57 additions and 56 deletions

View file

@ -407,7 +407,10 @@ in
enlightenment = handleTest ./enlightenment.nix { };
env = handleTest ./env.nix { };
envfs = handleTest ./envfs.nix { };
envoy = handleTest ./envoy.nix { };
envoy = runTest {
imports = [ ./envoy.nix ];
_module.args.envoyPackage = pkgs.envoy;
};
ergo = handleTest ./ergo.nix { };
ergochat = handleTest ./ergochat.nix { };
eris-server = handleTest ./eris-server.nix { };

View file

@ -1,62 +1,60 @@
import ./make-test-python.nix (
{ pkgs, lib, ... }:
{
name = "envoy";
meta = with pkgs.lib.maintainers; {
maintainers = [ cameronnemo ];
};
{ envoyPackage, lib, ... }:
{
name = envoyPackage.pname;
nodes.machine =
{ pkgs, ... }:
{
services.envoy.enable = true;
services.envoy.settings = {
admin = {
access_log_path = "/dev/null";
address = {
socket_address = {
protocol = "TCP";
address = "127.0.0.1";
port_value = 80;
};
};
meta = with lib.maintainers; {
maintainers = [ cameronnemo ];
};
nodes.machine = {
services.envoy.enable = true;
services.envoy.package = envoyPackage;
services.envoy.settings = {
admin = {
access_log_path = "/dev/null";
address = {
socket_address = {
protocol = "TCP";
address = "127.0.0.1";
port_value = 80;
};
static_resources = {
listeners = [ ];
clusters = [ ];
};
};
specialisation = {
withoutConfigValidation.configuration =
{ ... }:
{
services.envoy = {
requireValidConfig = false;
settings.admin.access_log_path = lib.mkForce "/var/log/envoy/access.log";
};
};
};
};
static_resources = {
listeners = [ ];
clusters = [ ];
};
};
specialisation = {
withoutConfigValidation.configuration =
{ ... }:
{
services.envoy = {
requireValidConfig = false;
settings.admin.access_log_path = lib.mkForce "/var/log/envoy/access.log";
};
};
};
};
testScript =
{ nodes, ... }:
let
specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
in
''
machine.start()
testScript =
{ nodes, ... }:
let
specialisations = "${nodes.machine.system.build.toplevel}/specialisation";
in
''
machine.start()
with subtest("envoy.service starts and responds with ready"):
machine.wait_for_unit("envoy.service")
machine.wait_for_open_port(80)
machine.wait_until_succeeds("curl -fsS localhost:80/ready")
with subtest("envoy.service starts and responds with ready"):
machine.wait_for_unit("envoy.service")
machine.wait_for_open_port(80)
machine.wait_until_succeeds("curl -fsS localhost:80/ready")
with subtest("envoy.service works with config path not available at eval time"):
machine.succeed('${specialisations}/withoutConfigValidation/bin/switch-to-configuration test')
machine.wait_for_unit("envoy.service")
machine.wait_for_open_port(80)
machine.wait_until_succeeds("curl -fsS localhost:80/ready")
machine.succeed('test -f /var/log/envoy/access.log')
'';
}
)
with subtest("envoy.service works with config path not available at eval time"):
machine.succeed('${specialisations}/withoutConfigValidation/bin/switch-to-configuration test')
machine.wait_for_unit("envoy.service")
machine.wait_for_open_port(80)
machine.wait_until_succeeds("curl -fsS localhost:80/ready")
machine.succeed('test -f /var/log/envoy/access.log')
'';
}