at 24.11-pre 2.0 kB view raw
1# This is a simple distributed test involving a topology with two 2# separate virtual networks - the "inside" and the "outside" - with a 3# client on the inside network, a server on the outside network, and a 4# router connected to both that performs Network Address Translation 5# for the client. 6import ./make-test-python.nix ({ pkgs, lib, ... }: 7 let 8 routerBase = 9 lib.mkMerge [ 10 { virtualisation.vlans = [ 2 1 ]; 11 networking.nftables.enable = true; 12 networking.nat.internalIPs = [ "192.168.1.0/24" ]; 13 networking.nat.externalInterface = "eth1"; 14 } 15 ]; 16 in 17 { 18 name = "dublin-traceroute"; 19 meta = with pkgs.lib.maintainers; { 20 maintainers = [ baloo ]; 21 }; 22 23 nodes.client = { nodes, ... }: { 24 imports = [ ./common/user-account.nix ]; 25 virtualisation.vlans = [ 1 ]; 26 27 networking.defaultGateway = 28 (builtins.head nodes.router.networking.interfaces.eth2.ipv4.addresses).address; 29 networking.nftables.enable = true; 30 31 programs.dublin-traceroute.enable = true; 32 }; 33 34 nodes.router = { ... }: { 35 virtualisation.vlans = [ 2 1 ]; 36 networking.nftables.enable = true; 37 networking.nat.internalIPs = [ "192.168.1.0/24" ]; 38 networking.nat.externalInterface = "eth1"; 39 networking.nat.enable = true; 40 }; 41 42 nodes.server = { ... }: { 43 virtualisation.vlans = [ 2 ]; 44 networking.firewall.enable = false; 45 services.httpd.enable = true; 46 services.httpd.adminAddr = "foo@example.org"; 47 services.vsftpd.enable = true; 48 services.vsftpd.anonymousUser = true; 49 }; 50 51 testScript = '' 52 client.start() 53 router.start() 54 server.start() 55 56 server.wait_for_unit("network.target") 57 router.wait_for_unit("network.target") 58 client.wait_for_unit("network.target") 59 60 # Make sure we can trace from an unprivileged user 61 client.succeed("sudo -u alice dublin-traceroute server") 62 ''; 63 })