1 import ./make-test-python.nix ({ lib, pkgs, ... }:
5 meta = with lib.maintainers; {
6 maintainers = [ nukaduka ];
9 nodes.server = { ... }: {
10 environment.systemPackages = with pkgs; [ prometheus-alertmanager ];
11 services.prometheus = {
15 scrape_interval = "5s";
16 scrape_timeout = "5s";
17 evaluation_interval = "5s";
22 job_name = "prometheus";
23 scrape_interval = "5s";
26 targets = [ "localhost:9090" ];
41 severity: bottom of the barrel
62 configuration.route = {
65 group_interval = "5s";
68 configuration.receivers = [
73 url = "http://localhost:1234";
84 extendIfExpiringIn = "30s";
92 with subtest("start the server"):
94 server.wait_for_unit("prometheus.service")
95 server.wait_for_unit("alertmanager.service")
96 server.wait_for_unit("kthxbye.service")
98 server.sleep(2) # wait for units to settle
99 server.systemctl("restart kthxbye.service") # make sure kthxbye comes up after alertmanager
102 with subtest("set up test silence which expires in 20s"):
103 server.succeed('amtool --alertmanager.url "http://localhost:9093" silence add alertname="node_up" -a "nixosTest" -d "20s" -c "ACK! this server is fine!!"')
105 with subtest("wait for 21 seconds and check if the silence is still active"):
107 server.systemctl("status kthxbye.service")
108 server.succeed("amtool --alertmanager.url 'http://localhost:9093' silence | grep 'ACK'")