nixpkgs/nixos/tests/gobgpd.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
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-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

88 lines
2.3 KiB
Nix

import ./make-test-python.nix (
{ pkgs, ... }:
let
ifAddr =
node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
in
{
name = "gobgpd";
meta = with pkgs.lib.maintainers; {
maintainers = [ higebu ];
};
nodes = {
node1 =
{ nodes, ... }:
{
environment.systemPackages = [ pkgs.gobgp ];
networking.firewall.allowedTCPPorts = [ 179 ];
services.gobgpd = {
enable = true;
settings = {
global = {
config = {
as = 64512;
router-id = "192.168.255.1";
};
};
neighbors = [
{
config = {
neighbor-address = ifAddr nodes.node2 "eth1";
peer-as = 64513;
};
}
];
};
};
};
node2 =
{ nodes, ... }:
{
environment.systemPackages = [ pkgs.gobgp ];
networking.firewall.allowedTCPPorts = [ 179 ];
services.gobgpd = {
enable = true;
settings = {
global = {
config = {
as = 64513;
router-id = "192.168.255.2";
};
};
neighbors = [
{
config = {
neighbor-address = ifAddr nodes.node1 "eth1";
peer-as = 64512;
};
}
];
};
};
};
};
testScript =
{ nodes, ... }:
let
addr1 = ifAddr nodes.node1 "eth1";
addr2 = ifAddr nodes.node2 "eth1";
in
''
start_all()
for node in node1, node2:
with subtest("should start gobgpd node"):
node.wait_for_unit("gobgpd.service")
with subtest("should open port 179"):
node.wait_for_open_port(179)
with subtest("should show neighbors by gobgp cli and BGP state should be ESTABLISHED"):
node1.wait_until_succeeds("gobgp neighbor ${addr2} | grep -q ESTABLISHED")
node2.wait_until_succeeds("gobgp neighbor ${addr1} | grep -q ESTABLISHED")
'';
}
)