mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-29 21:07:54 +02:00
test: make agent and systemd fixtures portable (#2461)
This commit is contained in:
30
agent/gpu_nvml_unsupported_test.go
Normal file
30
agent/gpu_nvml_unsupported_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
//go:build testing && !(amd64 && (windows || (linux && glibc)))
|
||||
|
||||
package agent
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// This fallback requires NVML initialisation to fail, as guaranteed by the unsupported implementation.
|
||||
func TestNewGPUManagerPriorityNvmlFallbackToNvidiaSmi(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
t.Setenv("PATH", dir)
|
||||
t.Setenv("BESZEL_AGENT_GPU_COLLECTOR", "nvml,nvidia-smi")
|
||||
|
||||
gpuCommandFixture(t, dir, "nvidia-smi", `0, NVIDIA Fallback GPU, 41, 256, 1024, 8, 14`+"\n")
|
||||
|
||||
gm, err := NewGPUManager()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, gm)
|
||||
|
||||
waitGPUs(t, gm, "0")
|
||||
gm.Lock()
|
||||
defer gm.Unlock()
|
||||
gpu, ok := gm.GpuDataMap["0"]
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "Fallback GPU", gpu.Name)
|
||||
}
|
||||
Reference in New Issue
Block a user