@@ -23,10 +23,11 @@ import (
23
23
)
24
24
25
25
type testCase struct {
26
- name string
27
- metricsData []string
28
- expectedLabels []string
29
- minLaneCount int
26
+ name string
27
+ metricsData []string
28
+ expectedLabels []string
29
+ minLaneCount int
30
+ allowSubdeviceless bool
30
31
}
31
32
32
33
func createTestCases () []testCase {
@@ -59,12 +60,25 @@ func createTestCases() []testCase {
59
60
metricsData : []string {
60
61
`# HELP xpum_topology_link Connection type fo two GPU tiles` ,
61
62
`# TYPE xpum_topology_link gauge` ,
62
- `xpum_topology_link{dev_file="card1",dev_name="Intel(R) Graphics [0x0bdb]",pci_bdf="0000:51:00.0",pci_dev="0xbdb",src="direct",uuid="01000000-0000-0000-0000-000000510000",vendor="Intel(R) Corporation",local_cpu_affinity="0-23,48-71",local_device_id="0",local_numa_index="0",local_on_subdevice="false",local_subdevice_id="0",remote_device_id="0 ",remote_subdevice_id="0"} 1` ,
63
- `xpum_topology_link{dev_file="card1",dev_name="Intel(R) Graphics [0x0bdb]",pci_bdf="0000:51:00.0",pci_dev="0xbdb",src="direct",uuid="01000000-0000-0000-0000-000000510000",vendor="Intel(R) Corporation",local_cpu_affinity="0-23,48-71",local_device_id="0",local_numa_index="0",local_on_subdevice="false",local_subdevice_id="0",remote_device_id="1",remote_subdevice_id="0 "} 1` ,
63
+ `xpum_topology_link{dev_file="card1",dev_name="Intel(R) Graphics [0x0bdb]",pci_bdf="0000:51:00.0",pci_dev="0xbdb",src="direct",uuid="01000000-0000-0000-0000-000000510000",vendor="Intel(R) Corporation",local_cpu_affinity="0-23,48-71",local_device_id="0",local_numa_index="0",local_on_subdevice="false",local_subdevice_id="0",remote_device_id="1 ",remote_subdevice_id="0",lane_count="4 "} 1` ,
64
+ `xpum_topology_link{dev_file="card1",dev_name="Intel(R) Graphics [0x0bdb]",pci_bdf="0000:51:00.0",pci_dev="0xbdb",src="direct",uuid="01000000-0000-0000-0000-000000510000",vendor="Intel(R) Corporation",local_cpu_affinity="0-23,48-71",local_device_id="0",local_numa_index="0",local_on_subdevice="false",local_subdevice_id="0",remote_device_id="1",remote_subdevice_id="1",lane_count="4 "} 1` ,
64
65
"" ,
65
66
},
66
67
expectedLabels : []string {"xpumanager.intel.com/xe-links=" },
67
68
},
69
+ {
70
+ name : "Xelinks not on sub devices when it's allowed" ,
71
+ minLaneCount : 4 ,
72
+ metricsData : []string {
73
+ `# HELP xpum_topology_link Connection type fo two GPU tiles` ,
74
+ `# TYPE xpum_topology_link gauge` ,
75
+ `xpum_topology_link{dev_file="card1",dev_name="Intel(R) Graphics [0x0bdb]",pci_bdf="0000:51:00.0",pci_dev="0xbdb",src="direct",uuid="01000000-0000-0000-0000-000000510000",vendor="Intel(R) Corporation",local_cpu_affinity="0-23,48-71",local_device_id="0",local_numa_index="0",local_on_subdevice="false",local_subdevice_id="0",remote_device_id="1",remote_subdevice_id="0",lane_count="4"} 1` ,
76
+ `xpum_topology_link{dev_file="card1",dev_name="Intel(R) Graphics [0x0bdb]",pci_bdf="0000:51:00.0",pci_dev="0xbdb",src="direct",uuid="01000000-0000-0000-0000-000000510000",vendor="Intel(R) Corporation",local_cpu_affinity="0-23,48-71",local_device_id="0",local_numa_index="0",local_on_subdevice="false",local_subdevice_id="0",remote_device_id="1",remote_subdevice_id="1",lane_count="4"} 1` ,
77
+ "" ,
78
+ },
79
+ expectedLabels : []string {"xpumanager.intel.com/xe-links=0.0-1.0_0.0-1.1" },
80
+ allowSubdeviceless : true ,
81
+ },
68
82
{
69
83
name : "Xelinks without lan counts" ,
70
84
minLaneCount : 4 ,
@@ -208,6 +222,9 @@ func TestLabeling(t *testing.T) {
208
222
for _ , tc := range tcs {
209
223
print ("Testcase (labeling): " , tc .name , "\n " )
210
224
xms := tc .createFakeXMS (tc .metricsData , tc .minLaneCount )
225
+
226
+ xms .allowSubdevicelessLinks = tc .allowSubdeviceless
227
+
211
228
topologyInfos := xms .GetTopologyFromXPUMMetrics ([]byte (strings .Join (tc .metricsData , "\n " )))
212
229
213
230
labels := xms .createLabels (topologyInfos )
@@ -224,6 +241,8 @@ func TestIterate(t *testing.T) {
224
241
print ("Testcase (iterate): " , tc .name , "\n " )
225
242
xms := tc .createFakeXMS (tc .metricsData , tc .minLaneCount )
226
243
244
+ xms .allowSubdevicelessLinks = tc .allowSubdeviceless
245
+
227
246
root , err := os .MkdirTemp ("" , "test_new_xms" )
228
247
if err != nil {
229
248
t .Fatalf ("can't create temporary directory: %+v" , err )
0 commit comments