diff --git a/nixos/modules/services/computing/slurm/slurm.nix b/nixos/modules/services/computing/slurm/slurm.nix index 019d7fbb16c..cf00d894655 100644 --- a/nixos/modules/services/computing/slurm/slurm.nix +++ b/nixos/modules/services/computing/slurm/slurm.nix @@ -34,6 +34,15 @@ in }; + package = mkOption { + type = types.package; + default = pkgs.slurm-llnl; + example = literalExample "pkgs.slurm-llnl-full"; + description = '' + The packge to use for slurm binaries. + ''; + }; + controlMachine = mkOption { type = types.nullOr types.str; default = null; @@ -91,38 +100,69 @@ in ###### implementation - config = mkIf (cfg.client.enable || cfg.server.enable) { + config = + let + wrappedSlurm = pkgs.stdenv.mkDerivation { + name = "wrappedSlurm"; - environment.systemPackages = [ pkgs.slurm-llnl ]; + propagatedBuildInputs = [ cfg.package configFile ]; + + builder = pkgs.writeText "builder.sh" '' + source $stdenv/setup + mkdir -p $out/bin + find ${cfg.package}/bin -type f -executable | while read EXE + do + exename="$(basename $EXE)" + wrappername="$out/bin/$exename" + cat > "$wrappername" <waitForUnit("default.target"); + + $node->succeed("mkdir /etc/munge"); + $node->succeed("echo '${mungekey}' > /etc/munge/munge.key"); + $node->succeed("chmod 0400 /etc/munge/munge.key"); + $node->succeed("systemctl restart munged"); + } + + # Restart the services since they have probably failed due to the munge init + # failure + + subtest "can_start_slurmctld", sub { + $control->succeed("systemctl restart slurmctld"); + $control->waitForUnit("slurmctld.service"); + }; + + subtest "can_start_slurmd", sub { + foreach my $node (($control,$node1,$node2,$node3)) + { + $node->succeed("systemctl restart slurmd.service"); + $node->waitForUnit("slurmd"); + } + }; + + # Test that the cluster work and can distribute jobs; + + subtest "run_distributed_command", sub { + # Run `hostname` on 3 nodes of the partition (so on all the 3 nodes). + # The output must contain the 3 different names + $control->succeed("srun -N 3 hostname | sort | uniq | wc -l | xargs test 3 -eq"); + }; + ''; +})