mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 08:04:14 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
115 lines
3.1 KiB
Nix
115 lines
3.1 KiB
Nix
import ./make-test-python.nix (
|
|
{ lib, pkgs, ... }:
|
|
{
|
|
name = "kthxbye";
|
|
|
|
meta = with lib.maintainers; {
|
|
maintainers = [ nukaduka ];
|
|
};
|
|
|
|
nodes.server =
|
|
{ ... }:
|
|
{
|
|
environment.systemPackages = with pkgs; [ prometheus-alertmanager ];
|
|
services.prometheus = {
|
|
enable = true;
|
|
|
|
globalConfig = {
|
|
scrape_interval = "5s";
|
|
scrape_timeout = "5s";
|
|
evaluation_interval = "5s";
|
|
};
|
|
|
|
scrapeConfigs = [
|
|
{
|
|
job_name = "prometheus";
|
|
scrape_interval = "5s";
|
|
static_configs = [
|
|
{
|
|
targets = [ "localhost:9090" ];
|
|
}
|
|
];
|
|
}
|
|
];
|
|
|
|
rules = [
|
|
''
|
|
groups:
|
|
- name: test
|
|
rules:
|
|
- alert: node_up
|
|
expr: up != 0
|
|
for: 5s
|
|
labels:
|
|
severity: bottom of the barrel
|
|
annotations:
|
|
summary: node is fine
|
|
''
|
|
];
|
|
|
|
alertmanagers = [
|
|
{
|
|
static_configs = [
|
|
{
|
|
targets = [
|
|
"localhost:9093"
|
|
];
|
|
}
|
|
];
|
|
}
|
|
];
|
|
|
|
alertmanager = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
configuration.route = {
|
|
receiver = "test";
|
|
group_wait = "5s";
|
|
group_interval = "5s";
|
|
group_by = [ "..." ];
|
|
};
|
|
configuration.receivers = [
|
|
{
|
|
name = "test";
|
|
webhook_configs = [
|
|
{
|
|
url = "http://localhost:1234";
|
|
}
|
|
];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
services.kthxbye = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
extendIfExpiringIn = "30s";
|
|
logJSON = true;
|
|
maxDuration = "15m";
|
|
interval = "5s";
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
with subtest("start the server"):
|
|
start_all()
|
|
server.wait_for_unit("prometheus.service")
|
|
server.wait_for_unit("alertmanager.service")
|
|
server.wait_for_unit("kthxbye.service")
|
|
|
|
server.sleep(2) # wait for units to settle
|
|
server.systemctl("restart kthxbye.service") # make sure kthxbye comes up after alertmanager
|
|
server.sleep(2)
|
|
|
|
with subtest("set up test silence which expires in 20s"):
|
|
server.succeed('amtool --alertmanager.url "http://localhost:9093" silence add alertname="node_up" -a "nixosTest" -d "20s" -c "ACK! this server is fine!!"')
|
|
|
|
with subtest("wait for 21 seconds and check if the silence is still active"):
|
|
server.sleep(21)
|
|
server.systemctl("status kthxbye.service")
|
|
server.succeed("amtool --alertmanager.url 'http://localhost:9093' silence | grep 'ACK'")
|
|
'';
|
|
}
|
|
)
|