3 @PRIMARY_DESC: Verify functionality of UDSP rule that prioritizes a source net
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
16 from lutf import agents, me
17 from lutf_basetest import *
18 from lnet import TheLNet
19 from lutf_exception import LUTFError
20 from lnet_helpers import LNetHelpers
21 from lustre_node import SimpleLustreNode
27 LOCAL_NETS = ['tcp', 'tcp1']
30 class TestLustreTraffic:
31 def __init__(self, target=None):
32 self.lh = LNetHelpers(os.path.abspath(__file__), target=target)
33 self.sln = SimpleLustreNode(os.path.abspath(__file__), target=target)
35 def getStatNet(stats_dict, net_list, net_num, nid_stat_str):
38 if (x['net type'] == net_list[net_num]):
39 for y in x['local NI(s)']:
40 stat_val += y['statistics'][nid_stat_str]
46 if len(la) < MIN_NODES:
47 return lutfrc(LUTF_TEST_SKIP, "Not enough agents to run the test")
50 for i in range(0, MIN_NODES):
51 node = TestLustreTraffic(la[i])
53 intfs = t.get_available_devs()
54 if len(intfs) < MIN_IFS_PER_NODE:
55 return lutfrc(LUTF_TEST_SKIP, "Not enough interfaces")
57 if not t.check_udsp_present():
58 return lutfrc(LUTF_TEST_SKIP, "UDSP feature is missing")
59 for j, net in enumerate(LOCAL_NETS):
60 half = len(intfs)//len(LOCAL_NETS)
61 net_intfs_list = intfs[half*(j):half*(j+1)]
62 t.configure_net(net, net_intfs_list)
67 main_nids = main.lh.list_nids()
69 agent_nids = agent.lh.list_nids()
71 # discover all the peers from main
72 if len(main.lh.discover(agent_nids[0])) == 0:
73 return lutfrc(LUTF_TEST_FAIL, "unable to discover" ,
76 rc = main.lh.check_udsp_empty()
78 return lutfrc(LUTF_TEST_FAIL, "UDSP list not empty")
80 for net_num in USE_NET_NUM:
81 rc = main.lh.exec_udsp_cmd(" add --src "+LOCAL_NETS[net_num])
83 before_stats_main = main.lh.get_net_stats()
84 print(before_stats_main)
86 for i in range(0, PING_TIMES):
87 rc = main.lh.exec_ping(agent_nids[PING_NID_NUM])
89 return lutfrc(LUTF_TEST_FAIL, "ping failed")
91 after_stats_main = main.lh.get_net_stats()
92 print(after_stats_main)
94 send_count_before = {}
96 total_send_count_before = 0
97 total_send_count_after = 0
98 for net_num in USE_NET_NUM:
99 send_count_before[net_num] = getStatNet(before_stats_main, LOCAL_NETS, net_num, 'send_count')
100 total_send_count_before += send_count_before[net_num]
101 send_count_after[net_num] = getStatNet(after_stats_main, LOCAL_NETS, net_num, 'send_count')
102 total_send_count_after += send_count_after[net_num]
104 print(send_count_before, send_count_after)
108 # 1) expect the total send_count to be no less than the number of pings issued
109 # 2) expect the send count on the preferred net to increase by no less than the
110 # number of pings issued
111 if (total_send_count_after - total_send_count_before) < PING_TIMES:
112 return lutfrc(LUTF_TEST_FAIL, "total send count mismatch")
114 for net_num in USE_NET_NUM:
115 if abs(send_count_after[net_num] - send_count_before[net_num]) < PING_TIMES:
116 print("send count increase on network ", LOCAL_NETS[net_num],
117 " insufficient. Expected ", PING_TIMES, " got",
118 abs(send_count_after[net_num] - send_count_before[net_num]))
119 return lutfrc(LUTF_TEST_FAIL, "send count increase insufficient")
122 n.lh.unconfigure_lnet()
124 return lutfrc(LUTF_TEST_PASS)
125 except Exception as e: