Whamcloud - gitweb
LU-10973 lnet: LUTF UDSP test suite and routing test suite
[fs/lustre-release.git] / lustre / tests / lutf / python / tests / suite_udsp / test_udsp_single_net_01.py
1 """
2 @PRIMARY: N/A
3 @PRIMARY_DESC: Verify that local nid can be prioritized for sending via UDSP
4 @SECONDARY: N/A
5 @DESIGN: N/A
6 @TESTCASE:
7 - configure one lnet and more than one nid
8 - turn on LNet discovery
9 - run lnetctl discover
10 - verify that udsp list is empty
11 - add udsp rule that gives one of the local nids higher priority
12 - get lnet stats (lnetctl net show -v 4)
13 - generate traffic by running lnetctl ping multiple times
14 - get lnet stats again
15 - verify that all sends were done using the prioritized nid
16 """
17
18 import os
19 import yaml
20 import lnetconfig
21 from lutf import agents, me
22 from lutf_basetest import *
23 from lnet import TheLNet
24 from lutf_exception import LUTFError
25 from lnet_helpers import LNetHelpers
26 from lustre_node import SimpleLustreNode
27
28 MIN_NODES = 2
29 MIN_IFS_PER_NODE = 2
30 PING_TIMES = 10
31 PING_NID_NUM = 0
32 LOCAL_NET = 'tcp'
33 USE_NID_NUM = 0
34
35 class TestLustreTraffic:
36         def __init__(self, target=None):
37                 self.lh = LNetHelpers(os.path.abspath(__file__), target=target)
38                 self.sln = SimpleLustreNode(os.path.abspath(__file__), target=target)
39
40 def run():
41         la = agents.keys()
42         if len(la) < MIN_NODES:
43                 return lutfrc(LUTF_TEST_SKIP, "Not enough agents to run the test")
44         nodes = []
45         try:
46                 for i in range(0, MIN_NODES):
47                         node = TestLustreTraffic(la[i])
48                         t = node.lh
49                         intfs = t.get_available_devs()
50                         if len(intfs) < MIN_IFS_PER_NODE:
51                                 return lutfrc(LUTF_TEST_SKIP, "Not enough interfaces")
52                         if not t.check_udsp_present():
53                                 return lutfrc(LUTF_TEST_SKIP, "UDSP feature is missing")
54                         t.configure_lnet()
55                         t.configure_net(LOCAL_NET, intfs)
56                         t.set_discovery(1)
57                         nodes.append(node)
58
59
60                 main = nodes[1]
61                 main_nids = main.lh.list_nids()
62                 agent = nodes[0]
63                 agent_nids = agent.lh.list_nids()
64
65                 rc = main.lh.check_udsp_empty()
66                 if not rc:
67                         print("UDSP list not empty")
68                         return lutfrc(LUTF_TEST_FAIL)
69                 rc = main.lh.exec_udsp_cmd(" add --src "+main_nids[USE_NID_NUM])
70                 #rc = main.lh.exec_udsp_cmd("
71
72                 before_stats_main = main.sln.get_lnet().get_net_stats()
73                 print(before_stats_main)
74
75                 for i in range(0, PING_TIMES):
76                         rc = main.lh.exec_ping(agent_nids[PING_NID_NUM])
77                         if not rc:
78                                 print("ping failed")
79                                 return lutfrc(LUTF_TEST_FAIL)
80
81                 after_stats_main = main.sln.get_lnet().get_net_stats()
82                 print(after_stats_main)
83
84                 send_count_before = -1
85                 send_count_after = -1
86                 for x in before_stats_main:
87                         if (x['net type'] == LOCAL_NET):
88                                 for y in x['local NI(s)']:
89                                         if y['nid'] == main_nids[USE_NID_NUM]:
90                                                 send_count_before = y['statistics']['send_count']
91                 for x in after_stats_main:
92                         if (x['net type'] == LOCAL_NET):
93                                 for y in x['local NI(s)']:
94                                         if y['nid'] == main_nids[USE_NID_NUM]:
95                                                 send_count_after = y['statistics']['send_count']
96                 if send_count_before < 0 or send_count_after < 0:
97                         print("failed to parse net stats")
98                         return lutfrc(LUTF_TEST_FAIL)
99
100                 if send_count_after - send_count_before < PING_TIMES:
101                         print("Unexpected number of sends: ", send_count_after - send_count_before)
102                         return lutfrc(LUTF_TEST_FAIL)
103
104                 for n in nodes:
105                         n.lh.unconfigure_lnet()
106
107                 return lutfrc(LUTF_TEST_PASS)
108         except Exception as e:
109                 for n in nodes:
110                         n.lh.uninit()
111                 raise e
112