mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
4d3f2de7e2
* feat: add CDI GPU support for workspace containers * feat: expose GPU CDI settings in bot container UI * feat: move GPU settings into advanced container options * docs: document advanced CDI device configuration
30 lines
728 B
Go
30 lines
728 B
Go
package workspace
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestWorkspaceCDIDevicesLabelRoundTrip(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
devices := []string{" nvidia.com/gpu=0 ", "amd.com/gpu=1", "nvidia.com/gpu=0"}
|
|
value := workspaceCDIDevicesLabelValue(devices)
|
|
got := workspaceCDIDevicesFromLabels(map[string]string{
|
|
WorkspaceCDIDevicesLabelKey: value,
|
|
})
|
|
|
|
want := []string{"nvidia.com/gpu=0", "amd.com/gpu=1"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("expected devices %v, got %v", want, got)
|
|
}
|
|
}
|
|
|
|
func TestWorkspaceCDIDevicesFromLabelsIgnoresMissingValue(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if got := workspaceCDIDevicesFromLabels(nil); len(got) != 0 {
|
|
t.Fatalf("expected empty devices for nil labels, got %v", got)
|
|
}
|
|
}
|