@@ -23,10 +23,11 @@ import (
2323)
2424
2525type 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
3031}
3132
3233func createTestCases () []testCase {
@@ -59,12 +60,25 @@ func createTestCases() []testCase {
5960 metricsData : []string {
6061 `# HELP xpum_topology_link Connection type fo two GPU tiles` ,
6162 `# 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` ,
6465 "" ,
6566 },
6667 expectedLabels : []string {"xpumanager.intel.com/xe-links=" },
6768 },
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+ },
6882 {
6983 name : "Xelinks without lan counts" ,
7084 minLaneCount : 4 ,
@@ -208,6 +222,9 @@ func TestLabeling(t *testing.T) {
208222 for _ , tc := range tcs {
209223 print ("Testcase (labeling): " , tc .name , "\n " )
210224 xms := tc .createFakeXMS (tc .metricsData , tc .minLaneCount )
225+
226+ xms .allowSubdevicelessLinks = tc .allowSubdeviceless
227+
211228 topologyInfos := xms .GetTopologyFromXPUMMetrics ([]byte (strings .Join (tc .metricsData , "\n " )))
212229
213230 labels := xms .createLabels (topologyInfos )
@@ -224,6 +241,8 @@ func TestIterate(t *testing.T) {
224241 print ("Testcase (iterate): " , tc .name , "\n " )
225242 xms := tc .createFakeXMS (tc .metricsData , tc .minLaneCount )
226243
244+ xms .allowSubdevicelessLinks = tc .allowSubdeviceless
245+
227246 root , err := os .MkdirTemp ("" , "test_new_xms" )
228247 if err != nil {
229248 t .Fatalf ("can't create temporary directory: %+v" , err )
0 commit comments