lol

nixos/tests/pacemaker: init

Astro 70c1e849 a60ab35d

+129 -1
+6
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
··· 280 280 with many features. 281 281 </para> 282 282 </listitem> 283 + <listitem> 284 + <para> 285 + <link xlink:href="https://clusterlabs.org/pacemaker/">pacemaker</link> 286 + cluster resource manager 287 + </para> 288 + </listitem> 283 289 </itemizedlist> 284 290 </section> 285 291 <section xml:id="sec-release-22.05-incompatibilities">
+2
nixos/doc/manual/release-notes/rl-2205.section.md
··· 81 81 82 82 - [blocky](https://0xerr0r.github.io/blocky/), fast and lightweight DNS proxy as ad-blocker for local network with many features. 83 83 84 + - [pacemaker](https://clusterlabs.org/pacemaker/) cluster resource manager 85 + 84 86 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 85 87 86 88 ## Backward Incompatibilities {#sec-release-22.05-incompatibilities}
+1
nixos/tests/all-tests.nix
··· 383 383 os-prober = handleTestOn ["x86_64-linux"] ./os-prober.nix {}; 384 384 osrm-backend = handleTest ./osrm-backend.nix {}; 385 385 overlayfs = handleTest ./overlayfs.nix {}; 386 + pacemaker = handleTest ./pacemaker.nix {}; 386 387 packagekit = handleTest ./packagekit.nix {}; 387 388 pam-file-contents = handleTest ./pam/pam-file-contents.nix {}; 388 389 pam-oath-login = handleTest ./pam/pam-oath-login.nix {};
+110
nixos/tests/pacemaker.nix
··· 1 + import ./make-test-python.nix ({ pkgs, lib, ... }: rec { 2 + name = "pacemaker"; 3 + meta = with pkgs.lib.maintainers; { 4 + maintainers = [ astro ]; 5 + }; 6 + 7 + nodes = 8 + let 9 + node = i: { 10 + networking.interfaces.eth1.ipv4.addresses = [ { 11 + address = "192.168.0.${toString i}"; 12 + prefixLength = 24; 13 + } ]; 14 + 15 + services.corosync = { 16 + enable = true; 17 + clusterName = "zentralwerk-network"; 18 + nodelist = lib.imap (i: name: { 19 + nodeid = i; 20 + inherit name; 21 + ring_addrs = [ 22 + (builtins.head nodes.${name}.networking.interfaces.eth1.ipv4.addresses).address 23 + ]; 24 + }) (builtins.attrNames nodes); 25 + }; 26 + environment.etc."corosync/authkey" = { 27 + source = builtins.toFile "authkey" 28 + # minimum length: 128 bytes 29 + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; 30 + mode = "0400"; 31 + }; 32 + 33 + services.pacemaker.enable = true; 34 + 35 + # used for pacemaker resource 36 + systemd.services.ha-cat = { 37 + description = "Highly available netcat"; 38 + serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l discard"; 39 + }; 40 + }; 41 + in { 42 + node1 = node 1; 43 + node2 = node 2; 44 + node3 = node 3; 45 + }; 46 + 47 + # sets up pacemaker with resources configuration, then crashes a 48 + # node and waits for service restart on another node 49 + testScript = 50 + let 51 + resources = builtins.toFile "cib-resources.xml" '' 52 + <resources> 53 + <primitive id="cat" class="systemd" type="ha-cat"> 54 + <operations> 55 + <op id="stop-cat" name="start" interval="0" timeout="1s"/> 56 + <op id="start-cat" name="start" interval="0" timeout="1s"/> 57 + <op id="monitor-cat" name="monitor" interval="1s" timeout="1s"/> 58 + </operations> 59 + </primitive> 60 + </resources> 61 + ''; 62 + in '' 63 + import re 64 + import time 65 + 66 + start_all() 67 + 68 + ${lib.concatMapStrings (node: '' 69 + ${node}.wait_until_succeeds("corosync-quorumtool") 70 + ${node}.wait_for_unit("pacemaker.service") 71 + '') (builtins.attrNames nodes)} 72 + 73 + # No STONITH device 74 + node1.succeed("crm_attribute -t crm_config -n stonith-enabled -v false") 75 + # Configure the cat resource 76 + node1.succeed("cibadmin --replace --scope resources --xml-file ${resources}") 77 + 78 + # wait until the service is started 79 + while True: 80 + output = node1.succeed("crm_resource -r cat --locate") 81 + match = re.search("is running on: (.+)", output) 82 + if match: 83 + for machine in machines: 84 + if machine.name == match.group(1): 85 + current_node = machine 86 + break 87 + time.sleep(1) 88 + 89 + current_node.log("Service running here!") 90 + current_node.crash() 91 + 92 + # pick another node that's still up 93 + for machine in machines: 94 + if machine.booted: 95 + check_node = machine 96 + # find where the service has been started next 97 + while True: 98 + output = check_node.succeed("crm_resource -r cat --locate") 99 + match = re.search("is running on: (.+)", output) 100 + # output will remain the old current_node until the crash is detected by pacemaker 101 + if match and match.group(1) != current_node.name: 102 + for machine in machines: 103 + if machine.name == match.group(1): 104 + next_node = machine 105 + break 106 + time.sleep(1) 107 + 108 + next_node.log("Service migrated here!") 109 + ''; 110 + })
+6 -1
pkgs/misc/logging/pacemaker/default.nix
··· 17 17 , pam 18 18 , pkg-config 19 19 , python3 20 + , nixosTests 20 21 21 22 # Pacemaker is compiled twice, once with forOCF = true to extract its 22 23 # OCF definitions for use in the ocf-resource-agents derivation, then ··· 87 88 rm -r $out/nix 88 89 ''; 89 90 91 + passthru.tests = { 92 + inherit (nixosTests) pacemaker; 93 + }; 94 + 90 95 meta = with lib; { 91 96 homepage = "https://clusterlabs.org/pacemaker/"; 92 97 description = "Pacemaker is an open source, high availability resource manager suitable for both small and large clusters."; 93 98 license = licenses.gpl2Plus; 94 99 platforms = platforms.linux; 95 - maintainers = with maintainers; [ ryantm ]; 100 + maintainers = with maintainers; [ ryantm astro ]; 96 101 }; 97 102 }
+4
pkgs/servers/corosync/default.nix
··· 65 65 --prefix PATH ":" "$out/sbin:${libqb}/sbin" 66 66 ''; 67 67 68 + passthru.tests = { 69 + inherit (nixosTests) pacemaker; 70 + }; 71 + 68 72 meta = { 69 73 homepage = "http://corosync.org/"; 70 74 description = "A Group Communication System with features for implementing high availability within applications";