mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-10 06:55:10 +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
81 lines
2.0 KiB
Nix
81 lines
2.0 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
addrShared = "192.168.0.1";
|
|
addrHostA = "192.168.0.10";
|
|
addrHostB = "192.168.0.11";
|
|
|
|
mkUcarpHost =
|
|
addr:
|
|
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
|
|
{
|
|
address = addr;
|
|
prefixLength = 24;
|
|
}
|
|
];
|
|
|
|
networking.ucarp = {
|
|
enable = true;
|
|
interface = "eth1";
|
|
srcIp = addr;
|
|
vhId = 1;
|
|
passwordFile = "${pkgs.writeText "ucarp-pass" "secure"}";
|
|
addr = addrShared;
|
|
upscript = pkgs.writeScript "upscript" ''
|
|
#!/bin/sh
|
|
${pkgs.iproute2}/bin/ip addr add "$2"/24 dev "$1"
|
|
'';
|
|
downscript = pkgs.writeScript "downscript" ''
|
|
#!/bin/sh
|
|
${pkgs.iproute2}/bin/ip addr del "$2"/24 dev "$1"
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
name = "ucarp";
|
|
meta.maintainers = with lib.maintainers; [ oxzi ];
|
|
|
|
nodes = {
|
|
hostA = mkUcarpHost addrHostA;
|
|
hostB = mkUcarpHost addrHostB;
|
|
};
|
|
|
|
testScript = ''
|
|
def is_master(host):
|
|
ipOutput = host.succeed("ip addr show dev eth1")
|
|
return "inet ${addrShared}/24" in ipOutput
|
|
|
|
|
|
start_all()
|
|
|
|
# First, let both hosts start and let a master node be selected
|
|
for host, peer in [(hostA, "${addrHostB}"), (hostB, "${addrHostA}")]:
|
|
host.wait_for_unit("ucarp.service")
|
|
host.succeed(f"ping -c 1 {peer}")
|
|
|
|
hostA.sleep(5)
|
|
|
|
hostA_master, hostB_master = is_master(hostA), is_master(hostB)
|
|
assert hostA_master != hostB_master, "only one master node is allowed"
|
|
|
|
master_host = hostA if hostA_master else hostB
|
|
backup_host = hostB if hostA_master else hostA
|
|
|
|
# Let's crash the master host and let the backup take over
|
|
master_host.crash()
|
|
|
|
backup_host.sleep(5)
|
|
assert is_master(backup_host), "backup did not take over"
|
|
'';
|
|
}
|
|
)
|