2018-09-07 17:13:50 +00:00
|
|
|
package nvidia
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"sort"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
hclog "github.com/hashicorp/go-hclog"
|
2018-10-05 20:50:18 +00:00
|
|
|
"github.com/hashicorp/nomad/devices/gpu/nvidia/nvml"
|
2018-09-07 17:13:50 +00:00
|
|
|
"github.com/hashicorp/nomad/helper"
|
|
|
|
"github.com/hashicorp/nomad/plugins/device"
|
2018-11-12 00:36:20 +00:00
|
|
|
"github.com/hashicorp/nomad/plugins/shared/structs"
|
2018-09-07 17:13:50 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFilterStatsByID(t *testing.T) {
|
|
|
|
for _, testCase := range []struct {
|
|
|
|
Name string
|
|
|
|
ProvidedStats []*nvml.StatsData
|
|
|
|
ProvidedIDs map[string]struct{}
|
|
|
|
ExpectedResult []*nvml.StatsData
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Name: "All ids are in the map",
|
|
|
|
ProvidedStats: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ProvidedIDs: map[string]struct{}{
|
|
|
|
"UUID1": {},
|
|
|
|
"UUID2": {},
|
|
|
|
"UUID3": {},
|
|
|
|
},
|
|
|
|
ExpectedResult: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Odd are not provided in the map",
|
|
|
|
ProvidedStats: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ProvidedIDs: map[string]struct{}{
|
|
|
|
"UUID2": {},
|
|
|
|
},
|
|
|
|
ExpectedResult: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Even are not provided in the map",
|
|
|
|
ProvidedStats: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ProvidedIDs: map[string]struct{}{
|
|
|
|
"UUID1": {},
|
|
|
|
"UUID3": {},
|
|
|
|
},
|
|
|
|
ExpectedResult: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "No Stats were provided",
|
|
|
|
ProvidedIDs: map[string]struct{}{
|
|
|
|
"UUID1": {},
|
|
|
|
"UUID2": {},
|
|
|
|
"UUID3": {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "No Ids were provided",
|
|
|
|
ProvidedStats: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
actualResult := filterStatsByID(testCase.ProvidedStats, testCase.ProvidedIDs)
|
|
|
|
require.New(t).Equal(testCase.ExpectedResult, actualResult)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStatsForItem(t *testing.T) {
|
|
|
|
for _, testCase := range []struct {
|
|
|
|
Name string
|
|
|
|
Timestamp time.Time
|
|
|
|
ItemStat *nvml.StatsData
|
|
|
|
ExpectedResult *device.DeviceStats
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Name: "All fields in ItemStat are not nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Power usage is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: nil,
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "PowerW is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: nil,
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "GPUUtilization is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: nil,
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "MemoryUtilization is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: nil,
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "EncoderUtilization is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: nil,
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "DecoderUtilization is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: nil,
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Temperature is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: nil,
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "UsedMemoryMiB is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: nil,
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "MemoryMiB is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: nil,
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "BAR1UsedMiB is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: nil,
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "BAR1MiB is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: nil,
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "ECCErrorsL1Cache is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: nil,
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "ECCErrorsL2Cache is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: nil,
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "ECCErrorsDevice is nil",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ItemStat: &nvml.StatsData{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: nil,
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceStats{
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
StringVal: helper.StringToPtr(notAvailable),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
actualResult := statsForItem(testCase.ItemStat, testCase.Timestamp)
|
|
|
|
require.New(t).Equal(testCase.ExpectedResult, actualResult)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStatsForGroup(t *testing.T) {
|
|
|
|
for _, testCase := range []struct {
|
|
|
|
Name string
|
|
|
|
Timestamp time.Time
|
|
|
|
GroupStats []*nvml.StatsData
|
|
|
|
GroupName string
|
|
|
|
ExpectedResult *device.DeviceGroupStats
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Name: "make sure that all data is transformed correctly",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
GroupName: "DeviceName1",
|
|
|
|
GroupStats: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName2"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(2),
|
|
|
|
GPUUtilization: helper.UintToPtr(2),
|
|
|
|
MemoryUtilization: helper.UintToPtr(2),
|
|
|
|
EncoderUtilization: helper.UintToPtr(2),
|
|
|
|
DecoderUtilization: helper.UintToPtr(2),
|
|
|
|
TemperatureC: helper.UintToPtr(2),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(2),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(200),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName3"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
PowerW: helper.UintToPtr(3),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(3),
|
|
|
|
GPUUtilization: helper.UintToPtr(3),
|
|
|
|
MemoryUtilization: helper.UintToPtr(3),
|
|
|
|
EncoderUtilization: helper.UintToPtr(3),
|
|
|
|
DecoderUtilization: helper.UintToPtr(3),
|
|
|
|
TemperatureC: helper.UintToPtr(3),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(3),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(300),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ExpectedResult: &device.DeviceGroupStats{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName1",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID1": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
"UUID2": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
"UUID3": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
actualResult := statsForGroup(testCase.GroupName, testCase.GroupStats, testCase.Timestamp)
|
|
|
|
require.New(t).Equal(testCase.ExpectedResult, actualResult)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWriteStatsToChannel(t *testing.T) {
|
|
|
|
for _, testCase := range []struct {
|
|
|
|
Name string
|
|
|
|
ExpectedWriteToChannel *device.StatsResponse
|
|
|
|
Timestamp time.Time
|
|
|
|
Device *NvidiaDevice
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Name: "NVML wrapper returns error",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
ExpectedWriteToChannel: &device.StatsResponse{
|
|
|
|
Error: errors.New(""),
|
|
|
|
},
|
|
|
|
Device: &NvidiaDevice{
|
|
|
|
nvmlClient: &MockNvmlClient{
|
|
|
|
StatsError: errors.New(""),
|
|
|
|
},
|
|
|
|
logger: hclog.NewNullLogger(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Check that stats with multiple DeviceNames are assigned to different groups",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
Device: &NvidiaDevice{
|
|
|
|
devices: map[string]struct{}{
|
|
|
|
"UUID1": {},
|
|
|
|
"UUID2": {},
|
|
|
|
"UUID3": {},
|
|
|
|
},
|
|
|
|
nvmlClient: &MockNvmlClient{
|
|
|
|
StatsResponseReturned: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName2"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(2),
|
|
|
|
GPUUtilization: helper.UintToPtr(2),
|
|
|
|
MemoryUtilization: helper.UintToPtr(2),
|
|
|
|
EncoderUtilization: helper.UintToPtr(2),
|
|
|
|
DecoderUtilization: helper.UintToPtr(2),
|
|
|
|
TemperatureC: helper.UintToPtr(2),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(2),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(200),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName3"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
PowerW: helper.UintToPtr(3),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(3),
|
|
|
|
GPUUtilization: helper.UintToPtr(3),
|
|
|
|
MemoryUtilization: helper.UintToPtr(3),
|
|
|
|
EncoderUtilization: helper.UintToPtr(3),
|
|
|
|
DecoderUtilization: helper.UintToPtr(3),
|
|
|
|
TemperatureC: helper.UintToPtr(3),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(3),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(300),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logger: hclog.NewNullLogger(),
|
|
|
|
},
|
|
|
|
ExpectedWriteToChannel: &device.StatsResponse{
|
|
|
|
Groups: []*device.DeviceGroupStats{
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName1",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID1": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName2",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID2": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName3",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID3": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Check that stats with multiple DeviceNames are assigned to different groups 2",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
Device: &NvidiaDevice{
|
|
|
|
devices: map[string]struct{}{
|
|
|
|
"UUID1": {},
|
|
|
|
"UUID2": {},
|
|
|
|
"UUID3": {},
|
|
|
|
},
|
|
|
|
nvmlClient: &MockNvmlClient{
|
|
|
|
StatsResponseReturned: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName2"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(2),
|
|
|
|
GPUUtilization: helper.UintToPtr(2),
|
|
|
|
MemoryUtilization: helper.UintToPtr(2),
|
|
|
|
EncoderUtilization: helper.UintToPtr(2),
|
|
|
|
DecoderUtilization: helper.UintToPtr(2),
|
|
|
|
TemperatureC: helper.UintToPtr(2),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(2),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(200),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName2"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
PowerW: helper.UintToPtr(3),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(3),
|
|
|
|
GPUUtilization: helper.UintToPtr(3),
|
|
|
|
MemoryUtilization: helper.UintToPtr(3),
|
|
|
|
EncoderUtilization: helper.UintToPtr(3),
|
|
|
|
DecoderUtilization: helper.UintToPtr(3),
|
|
|
|
TemperatureC: helper.UintToPtr(3),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(3),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(300),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logger: hclog.NewNullLogger(),
|
|
|
|
},
|
|
|
|
ExpectedWriteToChannel: &device.StatsResponse{
|
|
|
|
Groups: []*device.DeviceGroupStats{
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName1",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID1": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName2",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID3": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(3),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(3),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(300),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
"UUID2": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Check that only devices from NvidiaDevice.device map stats are reported",
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
Device: &NvidiaDevice{
|
|
|
|
devices: map[string]struct{}{
|
|
|
|
"UUID1": {},
|
|
|
|
"UUID2": {},
|
|
|
|
},
|
|
|
|
nvmlClient: &MockNvmlClient{
|
|
|
|
StatsResponseReturned: []*nvml.StatsData{
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID1",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName1"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
PowerW: helper.UintToPtr(1),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(1),
|
|
|
|
GPUUtilization: helper.UintToPtr(1),
|
|
|
|
MemoryUtilization: helper.UintToPtr(1),
|
|
|
|
EncoderUtilization: helper.UintToPtr(1),
|
|
|
|
DecoderUtilization: helper.UintToPtr(1),
|
|
|
|
TemperatureC: helper.UintToPtr(1),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(1),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(1),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(100),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(100),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID2",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName2"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
PowerW: helper.UintToPtr(2),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(2),
|
|
|
|
GPUUtilization: helper.UintToPtr(2),
|
|
|
|
MemoryUtilization: helper.UintToPtr(2),
|
|
|
|
EncoderUtilization: helper.UintToPtr(2),
|
|
|
|
DecoderUtilization: helper.UintToPtr(2),
|
|
|
|
TemperatureC: helper.UintToPtr(2),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(2),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(2),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(200),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(200),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DeviceData: &nvml.DeviceData{
|
|
|
|
UUID: "UUID3",
|
|
|
|
DeviceName: helper.StringToPtr("DeviceName3"),
|
|
|
|
MemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
PowerW: helper.UintToPtr(3),
|
|
|
|
BAR1MiB: helper.Uint64ToPtr(256),
|
|
|
|
},
|
|
|
|
PowerUsageW: helper.UintToPtr(3),
|
|
|
|
GPUUtilization: helper.UintToPtr(3),
|
|
|
|
MemoryUtilization: helper.UintToPtr(3),
|
|
|
|
EncoderUtilization: helper.UintToPtr(3),
|
|
|
|
DecoderUtilization: helper.UintToPtr(3),
|
|
|
|
TemperatureC: helper.UintToPtr(3),
|
|
|
|
UsedMemoryMiB: helper.Uint64ToPtr(3),
|
|
|
|
BAR1UsedMiB: helper.Uint64ToPtr(3),
|
|
|
|
ECCErrorsL1Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsL2Cache: helper.Uint64ToPtr(300),
|
|
|
|
ECCErrorsDevice: helper.Uint64ToPtr(300),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logger: hclog.NewNullLogger(),
|
|
|
|
},
|
|
|
|
ExpectedWriteToChannel: &device.StatsResponse{
|
|
|
|
Groups: []*device.DeviceGroupStats{
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName1",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID1": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(1),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(1),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(100),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Vendor: vendor,
|
|
|
|
Type: deviceType,
|
|
|
|
Name: "DeviceName2",
|
|
|
|
InstanceStats: map[string]*device.DeviceStats{
|
|
|
|
"UUID2": {
|
2018-11-12 00:36:20 +00:00
|
|
|
Summary: &structs.StatValue{
|
2018-12-06 12:10:22 +00:00
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
2018-11-12 00:36:20 +00:00
|
|
|
Stats: &structs.StatObject{
|
|
|
|
Attributes: map[string]*structs.StatValue{
|
2018-09-07 17:13:50 +00:00
|
|
|
PowerUsageAttr: {
|
|
|
|
Unit: PowerUsageUnit,
|
|
|
|
Desc: PowerUsageDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
GPUUtilizationAttr: {
|
|
|
|
Unit: GPUUtilizationUnit,
|
|
|
|
Desc: GPUUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryUtilizationAttr: {
|
|
|
|
Unit: MemoryUtilizationUnit,
|
|
|
|
Desc: MemoryUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
EncoderUtilizationAttr: {
|
|
|
|
Unit: EncoderUtilizationUnit,
|
|
|
|
Desc: EncoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
DecoderUtilizationAttr: {
|
|
|
|
Unit: DecoderUtilizationUnit,
|
|
|
|
Desc: DecoderUtilizationDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
TemperatureAttr: {
|
|
|
|
Unit: TemperatureUnit,
|
|
|
|
Desc: TemperatureDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
MemoryStateAttr: {
|
|
|
|
Unit: MemoryStateUnit,
|
|
|
|
Desc: MemoryStateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(2),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
BAR1StateAttr: {
|
|
|
|
Unit: BAR1StateUnit,
|
|
|
|
Desc: BAR1StateDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(2),
|
|
|
|
IntDenominatorVal: helper.Int64ToPtr(256),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL1CacheAttr: {
|
|
|
|
Unit: ECCErrorsL1CacheUnit,
|
|
|
|
Desc: ECCErrorsL1CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsL2CacheAttr: {
|
|
|
|
Unit: ECCErrorsL2CacheUnit,
|
|
|
|
Desc: ECCErrorsL2CacheDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
ECCErrorsDeviceAttr: {
|
|
|
|
Unit: ECCErrorsDeviceUnit,
|
|
|
|
Desc: ECCErrorsDeviceDesc,
|
2018-11-13 15:06:44 +00:00
|
|
|
IntNumeratorVal: helper.Int64ToPtr(200),
|
2018-09-07 17:13:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Timestamp: time.Date(1974, time.May, 19, 1, 2, 3, 4, time.UTC),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
channel := make(chan *device.StatsResponse, 1)
|
|
|
|
testCase.Device.writeStatsToChannel(channel, testCase.Timestamp)
|
|
|
|
actualResult := <-channel
|
|
|
|
// writeStatsToChannel iterates over map keys
|
|
|
|
// and insterts results to an array, so order of elements in output array
|
|
|
|
// may be different
|
|
|
|
// actualResult, expectedWriteToChannel arrays has to be sorted firsted
|
|
|
|
sort.Slice(actualResult.Groups, func(i, j int) bool {
|
|
|
|
return actualResult.Groups[i].Name < actualResult.Groups[j].Name
|
|
|
|
})
|
|
|
|
sort.Slice(testCase.ExpectedWriteToChannel.Groups, func(i, j int) bool {
|
|
|
|
return testCase.ExpectedWriteToChannel.Groups[i].Name < testCase.ExpectedWriteToChannel.Groups[j].Name
|
|
|
|
})
|
|
|
|
require.New(t).Equal(testCase.ExpectedWriteToChannel, actualResult)
|
|
|
|
}
|
|
|
|
}
|