nixos/tests/prometheus: migrate to runTest

This commit is contained in:
Defelo 2025-04-27 17:16:21 +02:00
parent 9f489ef1a6
commit 008a4657dd
No known key found for this signature in database
GPG key ID: 2A05272471204DD3
8 changed files with 597 additions and 676 deletions

View file

@ -1115,7 +1115,7 @@ in
private-gpt = handleTest ./private-gpt.nix { };
privatebin = runTest ./privatebin.nix;
privoxy = handleTest ./privoxy.nix { };
prometheus = handleTest ./prometheus { };
prometheus = import ./prometheus { inherit runTest; };
prometheus-exporters = handleTest ./prometheus-exporters.nix { };
prosody = handleTest ./xmpp/prosody.nix { };
prosody-mysql = handleTest ./xmpp/prosody-mysql.nix { };

View file

@ -1,7 +1,6 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{ pkgs, ... }:
{
{
name = "prometheus-alertmanager";
nodes = {
@ -20,11 +19,7 @@ import ../make-test-python.nix (
{
scheme = "http";
static_configs = [
{
targets = [
"alertmanager:${toString config.services.prometheus.alertmanager.port}"
];
}
{ targets = [ "alertmanager:${toString config.services.prometheus.alertmanager.port}" ]; }
];
}
];
@ -48,21 +43,13 @@ import ../make-test-python.nix (
{
job_name = "alertmanager";
static_configs = [
{
targets = [
"alertmanager:${toString config.services.prometheus.alertmanager.port}"
];
}
{ targets = [ "alertmanager:${toString config.services.prometheus.alertmanager.port}" ]; }
];
}
{
job_name = "node";
static_configs = [
{
targets = [
"node:${toString config.services.prometheus.exporters.node.port}"
];
}
{ targets = [ "node:${toString config.services.prometheus.exporters.node.port}" ]; }
];
}
];
@ -156,5 +143,4 @@ import ../make-test-python.nix (
alertmanager.log(alertmanager.succeed("systemd-analyze security alertmanager.service | grep -v ''"))
'';
}
)
}

View file

@ -1,7 +1,4 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{
{
name = "prometheus-config-reload";
nodes = {
@ -19,13 +16,7 @@ import ../make-test-python.nix (
scrapeConfigs = [
{
job_name = "prometheus";
static_configs = [
{
targets = [
"prometheus:${toString config.services.prometheus.port}"
];
}
];
static_configs = [ { targets = [ "prometheus:${toString config.services.prometheus.port}" ]; } ];
}
];
};
@ -42,9 +33,7 @@ import ../make-test-python.nix (
{
job_name = "node";
static_configs = [
{
targets = [ "node:${toString config.services.prometheus.exporters.node.port}" ];
}
{ targets = [ "node:${toString config.services.prometheus.exporters.node.port}" ]; }
];
}
];
@ -116,5 +105,4 @@ import ../make-test-python.nix (
"""
)
'';
}
)
}

View file

@ -1,14 +1,10 @@
{
system ? builtins.currentSystem,
config ? { },
pkgs ? import ../../.. { inherit system config; },
}:
{ runTest }:
{
alertmanager = import ./alertmanager.nix { inherit system pkgs; };
config-reload = import ./config-reload.nix { inherit system pkgs; };
federation = import ./federation.nix { inherit system pkgs; };
prometheus-pair = import ./prometheus-pair.nix { inherit system pkgs; };
pushgateway = import ./pushgateway.nix { inherit system pkgs; };
remote-write = import ./remote-write.nix { inherit system pkgs; };
alertmanager = runTest ./alertmanager.nix;
config-reload = runTest ./config-reload.nix;
federation = runTest ./federation.nix;
prometheus-pair = runTest ./prometheus-pair.nix;
pushgateway = runTest ./pushgateway.nix;
remote-write = runTest ./remote-write.nix;
}

View file

@ -1,7 +1,4 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{
{
name = "prometheus-federation";
nodes = {
@ -116,22 +113,12 @@ import ../make-test-python.nix (
{
job_name = "node";
static_configs = [
{
targets = [
"node1:${toString config.services.prometheus.exporters.node.port}"
];
}
{ targets = [ "node1:${toString config.services.prometheus.exporters.node.port}" ]; }
];
}
{
job_name = "prometheus";
static_configs = [
{
targets = [
"prometheus1:${toString config.services.prometheus.port}"
];
}
];
static_configs = [ { targets = [ "prometheus1:${toString config.services.prometheus.port}" ]; } ];
}
];
};
@ -152,22 +139,12 @@ import ../make-test-python.nix (
{
job_name = "node";
static_configs = [
{
targets = [
"node2:${toString config.services.prometheus.exporters.node.port}"
];
}
{ targets = [ "node2:${toString config.services.prometheus.exporters.node.port}" ]; }
];
}
{
job_name = "prometheus";
static_configs = [
{
targets = [
"prometheus2:${toString config.services.prometheus.port}"
];
}
];
static_configs = [ { targets = [ "prometheus2:${toString config.services.prometheus.port}" ]; } ];
}
];
};
@ -223,5 +200,4 @@ import ../make-test-python.nix (
+ "jq '.data.result[0].value[1]' | grep '\"4\"'"
)
'';
}
)
}

View file

@ -1,7 +1,6 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{ pkgs, ... }:
{
{
name = "prometheus-pair";
nodes = {
@ -89,5 +88,4 @@ import ../make-test-python.nix (
prometheus1.log(prometheus1.succeed("systemd-analyze security prometheus.service | grep -v ''"))
'';
}
)
}

View file

@ -1,7 +1,6 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{ pkgs, ... }:
{
{
name = "prometheus-pushgateway";
nodes = {
@ -19,13 +18,7 @@ import ../make-test-python.nix (
scrapeConfigs = [
{
job_name = "pushgateway";
static_configs = [
{
targets = [
"pushgateway:9091"
];
}
];
static_configs = [ { targets = [ "pushgateway:9091" ]; } ];
}
];
};
@ -41,10 +34,7 @@ import ../make-test-python.nix (
};
};
client =
{ config, pkgs, ... }:
{
};
client = { config, pkgs, ... }: { };
};
testScript = ''
@ -98,5 +88,4 @@ import ../make-test-python.nix (
pushgateway.log(pushgateway.succeed("systemd-analyze security pushgateway.service | grep -v ''"))
'';
}
)
}

View file

@ -1,7 +1,4 @@
import ../make-test-python.nix (
{ lib, pkgs, ... }:
{
{
name = "prometheus-remote-write";
nodes = {
@ -31,21 +28,13 @@ import ../make-test-python.nix (
enable = true;
globalConfig.scrape_interval = "2s";
remoteWrite = [
{
url = "http://receiver:9090/api/v1/write";
}
];
remoteWrite = [ { url = "http://receiver:9090/api/v1/write"; } ];
scrapeConfigs = [
{
job_name = "node";
static_configs = [
{
targets = [
"node:${toString config.services.prometheus.exporters.node.port}"
];
}
{ targets = [ "node:${toString config.services.prometheus.exporters.node.port}" ]; }
];
}
];
@ -77,5 +66,4 @@ import ../make-test-python.nix (
+ "jq '.data.result[0].value[1]' | grep '\"1\"'"
)
'';
}
)
}