From 4cd70e125d1baabb0846bdbfd4d87cf69e5fed8a Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Thu, 29 Jun 2023 10:43:06 +0800 Subject: [PATCH] nixos/bpftune: init basic test --- nixos/tests/all-tests.nix | 1 + nixos/tests/bpftune.nix | 37 ++++++++++++++++++++++ pkgs/os-specific/linux/bpftune/default.nix | 5 +++ 3 files changed, 43 insertions(+) create mode 100644 nixos/tests/bpftune.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 723b030072e..5f4aefad890 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -138,6 +138,7 @@ in { borgbackup = handleTest ./borgbackup.nix {}; botamusique = handleTest ./botamusique.nix {}; bpf = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bpf.nix {}; + bpftune = handleTest ./bpftune.nix {}; breitbandmessung = handleTest ./breitbandmessung.nix {}; brscan5 = handleTest ./brscan5.nix {}; btrbk = handleTest ./btrbk.nix {}; diff --git a/nixos/tests/bpftune.nix b/nixos/tests/bpftune.nix new file mode 100644 index 00000000000..63fcfc8b819 --- /dev/null +++ b/nixos/tests/bpftune.nix @@ -0,0 +1,37 @@ +import ./make-test-python.nix ({ lib, pkgs, ... }: { + + name = "bpftune"; + + meta = { + maintainers = with lib.maintainers; [ nickcao ]; + }; + + nodes = { + client = { pkgs, ... }: { + services.bpftune.enable = true; + + boot.kernel.sysctl."net.ipv4.tcp_rmem" = "4096 131072 1310720"; + + environment.systemPackages = [ pkgs.iperf3 ]; + }; + + server = { ... }: { + services.iperf3 = { + enable = true; + openFirewall = true; + }; + }; + }; + + testScript = '' + with subtest("bpftune startup"): + client.wait_for_unit("bpftune.service") + client.wait_for_console_text("bpftune works fully") + + with subtest("bpftune tcp buffer size"): + server.wait_for_unit("iperf3.service") + client.succeed("iperf3 --reverse -c server") + client.wait_for_console_text("need to increase TCP buffer size") + ''; + +}) diff --git a/pkgs/os-specific/linux/bpftune/default.nix b/pkgs/os-specific/linux/bpftune/default.nix index 09d5f475619..089aee11fb3 100644 --- a/pkgs/os-specific/linux/bpftune/default.nix +++ b/pkgs/os-specific/linux/bpftune/default.nix @@ -7,6 +7,7 @@ , libbpf , libcap , libnl +, nixosTests }: stdenv.mkDerivation rec { @@ -55,6 +56,10 @@ stdenv.mkDerivation rec { "stackprotector" ]; + passthru.tests = { + inherit (nixosTests) bpftune; + }; + meta = with lib; { description = "BPF-based auto-tuning of Linux system parameters"; homepage = "https://github.com/oracle-samples/bpftune";