nixos/tests: add predictable-interface-names.nix (#34305)
This commit is contained in:
parent
a51cda85ff
commit
0146074560
@ -440,8 +440,12 @@ rec {
|
||||
init = list: assert list != []; take (length list - 1) list;
|
||||
|
||||
|
||||
/* FIXME(zimbatm) Not used anywhere
|
||||
*/
|
||||
/* return the image of the cross product of some lists by a function
|
||||
|
||||
Example:
|
||||
crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]]
|
||||
=> [ "13" "14" "23" "24" ]
|
||||
*/
|
||||
crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f];
|
||||
|
||||
|
||||
|
@ -41,6 +41,7 @@ in rec {
|
||||
nfs3
|
||||
openssh
|
||||
php-pcre
|
||||
predictable-interface-names
|
||||
proxy
|
||||
simple;
|
||||
installer = {
|
||||
|
@ -326,6 +326,7 @@ in rec {
|
||||
tests.pgmanage = callTest tests/pgmanage.nix {};
|
||||
tests.postgis = callTest tests/postgis.nix {};
|
||||
#tests.pgjwt = callTest tests/pgjwt.nix {};
|
||||
tests.predictable-interface-names = callSubTests tests/predictable-interface-names.nix {};
|
||||
tests.printing = callTest tests/printing.nix {};
|
||||
tests.prometheus = callTest tests/prometheus.nix {};
|
||||
tests.proxy = callTest tests/proxy.nix {};
|
||||
|
27
nixos/tests/predictable-interface-names.nix
Normal file
27
nixos/tests/predictable-interface-names.nix
Normal file
@ -0,0 +1,27 @@
|
||||
{ system ? builtins.currentSystem
|
||||
, pkgs ? import ../.. { inherit system; }
|
||||
}:
|
||||
with import ../lib/testing.nix { inherit system; };
|
||||
let boolToString = x: if x then "yes" else "no"; in
|
||||
let testWhenSetTo = predictable: withNetworkd:
|
||||
makeTest {
|
||||
name = "${if predictable then "" else "un"}predictableInterfaceNames${if withNetworkd then "-with-networkd" else ""}";
|
||||
meta = {};
|
||||
|
||||
machine = { config, pkgs, ... }: {
|
||||
networking.usePredictableInterfaceNames = pkgs.stdenv.lib.mkForce predictable;
|
||||
networking.useNetworkd = withNetworkd;
|
||||
networking.dhcpcd.enable = !withNetworkd;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
print $machine->succeed("ip link");
|
||||
$machine->succeed("ip link show ${if predictable then "ens3" else "eth0"}");
|
||||
$machine->fail("ip link show ${if predictable then "eth0" else "ens3"}");
|
||||
'';
|
||||
}; in
|
||||
with pkgs.stdenv.lib.lists;
|
||||
with pkgs.stdenv.lib.attrsets;
|
||||
listToAttrs (map (drv: nameValuePair drv.name drv) (
|
||||
crossLists testWhenSetTo [[true false] [true false]]
|
||||
))
|
Loading…
Reference in New Issue
Block a user