diff --git a/overlays/mig/internal/mig_test.go b/overlays/mig/internal/mig_test.go index da3377c6..1ba7a0ac 100644 --- a/overlays/mig/internal/mig_test.go +++ b/overlays/mig/internal/mig_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/warewulf/warewulf/internal/app/wwctl/overlay/info" "github.com/warewulf/warewulf/internal/app/wwctl/overlay/show" "github.com/warewulf/warewulf/internal/pkg/testenv" "github.com/warewulf/warewulf/internal/pkg/wwlog" @@ -42,6 +43,19 @@ func Test_migOverlay(t *testing.T) { log: migServiceHeterogeneousShortNames, }, } + infoTests := []struct { + name string + args []string + log string + stdout string + }{ + { + name: "mig:nvidia-mig.service (info)", + args: []string{"mig", "etc/systemd/system/ww-nvidia-mig.service.ww"}, + log: migInfoOutput, + stdout: migInfoStdout, + }, + } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -60,11 +74,31 @@ func Test_migOverlay(t *testing.T) { assert.Equal(t, tt.log, logbuf.String()) }) } + + for _, tt := range infoTests { + t.Run(tt.name, func(t *testing.T) { + cmd := info.GetCommand() + cmd.SetArgs(tt.args) + stdout := bytes.NewBufferString("") + stderr := bytes.NewBufferString("") + logbuf := bytes.NewBufferString("") + cmd.SetOut(stdout) + cmd.SetErr(stderr) + wwlog.SetLogWriter(logbuf) + err := cmd.Execute() + assert.NoError(t, err) + assert.Equal(t, tt.log, logbuf.String()) + assert.Equal(t, tt.stdout, stdout.String()) + assert.Empty(t, stderr.String()) + }) + } } const migServiceDefault string = `backupFile: true writeFile: true Filename: etc/systemd/system/ww-nvidia-mig.service +# This file is autogenerated by warewulf + [Unit] DefaultDependencies=no Description=Configure NVIDIA MIG (Multi-Instance GPU) partitions via Warewulf @@ -92,6 +126,8 @@ WantedBy=multi-user.target const migServiceHomogeneous string = `backupFile: true writeFile: true Filename: etc/systemd/system/ww-nvidia-mig.service +# This file is autogenerated by warewulf + [Unit] DefaultDependencies=no Description=Configure NVIDIA MIG (Multi-Instance GPU) partitions via Warewulf @@ -119,6 +155,8 @@ WantedBy=multi-user.target const migServiceHeterogeneous string = `backupFile: true writeFile: true Filename: etc/systemd/system/ww-nvidia-mig.service +# This file is autogenerated by warewulf + [Unit] DefaultDependencies=no Description=Configure NVIDIA MIG (Multi-Instance GPU) partitions via Warewulf @@ -149,6 +187,8 @@ WantedBy=multi-user.target const migServiceHeterogeneousShortNames string = `backupFile: true writeFile: true Filename: etc/systemd/system/ww-nvidia-mig.service +# This file is autogenerated by warewulf + [Unit] DefaultDependencies=no Description=Configure NVIDIA MIG (Multi-Instance GPU) partitions via Warewulf @@ -175,3 +215,12 @@ TimeoutStopSec=300 [Install] WantedBy=multi-user.target ` + +const migInfoOutput string = `Configures NVIDIA MIG (Multi-Instance GPU) settings on nodes with supported NVIDIA GPUs. Requires the NVIDIA driver and the nvidia-smi tool to be installed and functional on the node. +` + +const migInfoStdout string = ` +VARIABLE OPTION TYPE HELP +-------- ------ ---- ---- +.Tags.gpuMigProfiles string List of MIG profile IDs or short names, with commas separating instances on a GPU and colons separating GPUs by index +` diff --git a/overlays/mig/rootfs/etc/systemd/system/ww-nvidia-mig.service.ww b/overlays/mig/rootfs/etc/systemd/system/ww-nvidia-mig.service.ww index 6983a65a..34d89e30 100644 --- a/overlays/mig/rootfs/etc/systemd/system/ww-nvidia-mig.service.ww +++ b/overlays/mig/rootfs/etc/systemd/system/ww-nvidia-mig.service.ww @@ -1,3 +1,8 @@ +# This file is autogenerated by warewulf + +{{- /* wwdoc: Configures NVIDIA MIG (Multi-Instance GPU) settings on nodes with supported NVIDIA GPUs. Requires the NVIDIA driver and the nvidia-smi tool to be installed and functional on the node. */}} +{{- /* .Tags.gpuMigProfiles: List of MIG profile IDs or short names, with commas separating instances on a GPU and colons separating GPUs by index */}} + [Unit] DefaultDependencies=no Description=Configure NVIDIA MIG (Multi-Instance GPU) partitions via Warewulf