3 @PRIMARY_DESC: Verify that UDSP rule prioritizing a source net works correctly if deleted and re-applied
7 - configure two networks, multiple nids per network
8 - add udsp rule that gives one of the networks highest priority
10 - verify that the network with the highest priority was used
11 - delete the rule and repeat for the second network
17 from lutf import agents, me
18 from lutf_basetest import *
19 from lnet import TheLNet
20 from lutf_exception import LUTFError
21 from lnet_helpers import LNetHelpers
22 from lustre_node import SimpleLustreNode
28 LOCAL_NETS = ['tcp', 'tcp1']
31 class TestLustreTraffic:
32 def __init__(self, target=None):
33 self.lh = LNetHelpers(os.path.abspath(__file__), target=target)
34 self.sln = SimpleLustreNode(os.path.abspath(__file__), target=target)
36 def getStatNet(stats_dict, net_list, net_num, nid_stat_str):
39 if (x['net type'] == net_list[net_num]):
40 for y in x['local NI(s)']:
41 stat_val += y['statistics'][nid_stat_str]
47 if len(la) < MIN_NODES:
48 return lutfrc(LUTF_TEST_SKIP, "Not enough agents to run the test")
51 for i in range(0, MIN_NODES):
52 node = TestLustreTraffic(la[i])
54 intfs = t.get_available_devs()
55 if len(intfs) < MIN_IFS_PER_NODE:
56 return lutfrc(LUTF_TEST_SKIP, "Not enough interfaces")
58 if not t.check_udsp_present():
59 return lutfrc(LUTF_TEST_SKIP, "UDSP feature is missing")
60 for j, net in enumerate(LOCAL_NETS):
61 half = len(intfs)//len(LOCAL_NETS)
62 net_intfs_list = intfs[half*(j):half*(j+1)]
63 t.configure_net(net, net_intfs_list)
68 main_nids = main.lh.list_nids()
70 agent_nids = agent.lh.list_nids()
72 # discover all the peers from main
73 if len(main.lh.discover(agent_nids[0])) == 0:
74 return lutfrc(LUTF_TEST_FAIL, "unable to discover" ,
77 for prio_net_num in USE_NET_NUM:
79 rc = main.lh.check_udsp_empty()
81 return lutfrc(LUTF_TEST_FAIL, "UDSP list not empty")
83 rc = main.lh.exec_udsp_cmd(" add --src "+LOCAL_NETS[prio_net_num])
85 before_stats_main = main.lh.get_net_stats()
86 #print(before_stats_main)
88 for i in range(0, PING_TIMES):
89 rc = main.lh.exec_ping(agent_nids[PING_NID_NUM])
91 return lutfrc(LUTF_TEST_FAIL, "ping failed")
93 after_stats_main = main.lh.get_net_stats()
94 #print(after_stats_main)
96 send_count_before = {}
98 total_send_count_before = 0
99 total_send_count_after = 0
101 send_count_before[prio_net_num] = getStatNet(before_stats_main, LOCAL_NETS, prio_net_num, 'send_count')
102 total_send_count_before += send_count_before[prio_net_num]
103 send_count_after[prio_net_num] = getStatNet(after_stats_main, LOCAL_NETS, prio_net_num, 'send_count')
104 total_send_count_after += send_count_after[prio_net_num]
106 #print(send_count_before, send_count_after)
109 # 1) expect the total send_count to be no less than the number of pings issued
110 # 2) expect the send count on the preferred net to increase by no less than the
111 # number of pings issued
112 if (total_send_count_after - total_send_count_before) < PING_TIMES:
113 return lutfrc(LUTF_TEST_FAIL, "total send count mismatch")
115 if abs(send_count_after[prio_net_num] - send_count_before[prio_net_num]) < PING_TIMES:
116 print("send count increase on network ", LOCAL_NETS[prio_net_num],
117 " insufficient. Expected ", PING_TIMES, " got",
118 abs(send_count_after[prio_net_num] - send_count_before[prio_net_num]))
119 return lutfrc(LUTF_TEST_FAIL, "send count increase insufficient")
121 rc = main.lh.exec_udsp_cmd(" del --idx 0")
123 n.lh.unconfigure_lnet()
125 return lutfrc(LUTF_TEST_PASS)
126 except Exception as e: