4 @PRIMARY_DESC: Verify that multiple local nids can be prioritized for sending via UDSP
8 - configure one lnet and more than two nids
9 - turn on LNet discovery
10 - run lnetctl discover
11 - verify that udsp list is empty
12 - add udsp rule that gives two of the local nids higher priority
13 - get lnet stats (lnetctl net show -v 4)
14 - generate traffic by running lnetctl ping multiple times
15 - get lnet stats again
16 - verify that all sends were done using the prioritized nids
22 from lutf import agents, me
23 from lutf_basetest import *
24 from lnet import TheLNet
25 from lutf_exception import LUTFError
26 from lnet_helpers import LNetHelpers
27 from lustre_node import SimpleLustreNode
36 class TestLustreTraffic:
37 def __init__(self, target=None):
38 self.lh = LNetHelpers(os.path.abspath(__file__), target=target)
39 self.sln = SimpleLustreNode(os.path.abspath(__file__), target=target)
41 def getStatNID(stats_dict, nid_list, nid_num, nid_stat_str):
43 if (x['net type'] == LOCAL_NET):
44 for y in x['local NI(s)']:
45 if y['nid'] == nid_list[nid_num]:
46 return y['statistics'][nid_stat_str]
52 if len(la) < MIN_NODES:
53 return lutfrc(LUTF_TEST_SKIP, "Not enough agents to run the test")
56 for i in range(0, MIN_NODES):
57 node = TestLustreTraffic(la[i])
59 intfs = t.get_available_devs()
60 if len(intfs) < MIN_IFS_PER_NODE:
61 return lutfrc(LUTF_TEST_SKIP, "Not enough interfaces")
62 if not t.check_udsp_present():
63 return lutfrc(LUTF_TEST_SKIP, "UDSP feature is missing")
65 t.configure_net(LOCAL_NET, intfs)
70 main_nids = main.lh.list_nids()
72 agent_nids = agent.lh.list_nids()
73 print("nids: ", main_nids)
75 # discover all the peers from main
76 if len(main.lh.discover(agent_nids[0])) == 0:
77 return lutfrc(LUTF_TEST_FAIL, "unable to discover" ,
80 rc = main.lh.check_udsp_empty()
82 print("UDSP list not empty")
83 return lutfrc(LUTF_TEST_FAIL)
85 for nid_num in USE_NID_NUM:
86 rc = main.lh.exec_udsp_cmd(" add --src "+main_nids[nid_num])
88 before_stats_main = main.sln.get_lnet().get_net_stats()
89 print(before_stats_main)
91 for i in range(0, PING_TIMES):
92 rc = main.lh.exec_ping(agent_nids[PING_NID_NUM])
95 return lutfrc(LUTF_TEST_FAIL)
97 after_stats_main = main.sln.get_lnet().get_net_stats()
98 print(after_stats_main)
100 send_count_before = {}
101 send_count_after = {}
102 total_send_count_before = 0
103 total_send_count_after = 0
104 for nid_num in USE_NID_NUM:
105 #print({nid_num: getStatNID(before_stats_main, main_nids, nid_num, 'send_count')})
106 #print({nid_num: getStatNID(after_stats_main, main_nids, nid_num, 'send_count')})
107 send_count_before[nid_num] = getStatNID(before_stats_main, main_nids, nid_num, 'send_count')
108 total_send_count_before += send_count_before[nid_num]
109 send_count_after[nid_num] = getStatNID(after_stats_main, main_nids, nid_num, 'send_count')
110 total_send_count_after += send_count_after[nid_num]
113 for x in before_stats_main:
114 if (x['net type'] == LOCAL_NET):
115 for y in x['local NI(s)']:
116 if y['nid'] == main_nids[USE_NID_NUM]:
117 send_count_before = y['statistics']['send_count']
118 for x in after_stats_main:
119 if (x['net type'] == LOCAL_NET):
120 for y in x['local NI(s)']:
121 if y['nid'] == main_nids[USE_NID_NUM]:
122 send_count_after = y['statistics']['send_count']
123 if send_count_before < 0 or send_count_after < 0:
124 print("failed to parse net stats")
125 return lutfrc(LUTF_TEST_FAIL)
127 if send_count_after - send_count_before < PING_TIMES:
128 print("Unexpected number of sends: ", send_count_after - send_count_before)
129 return lutfrc(LUTF_TEST_FAIL)
132 print(send_count_before, send_count_after)
135 # 1) expect send counts on both interfaces to increase
136 # 2) expect the total send_count to be no less than the number of pings issued
137 # 3) expect the send counts on the two interfaces used to be close (diff < 2)
138 if (total_send_count_after - total_send_count_before) < PING_TIMES:
139 print("total send count mismatch")
140 return lutfrc(LUTF_TEST_FAIL)
142 if abs(send_count_after[0] - send_count_after[1]) > 1:
143 print("uneven tx traffic distribution across interfaces")
144 return lutfrc(LUTF_TEST_FAIL)
148 n.lh.unconfigure_lnet()
150 return lutfrc(LUTF_TEST_PASS)
151 except Exception as e: