Whamcloud - gitweb
LU-10973 lnet: LUTF dynamic discovery test suite
[fs/lustre-release.git] / lustre / tests / lutf / python / tests / suite_dynamic-discovery / test_dd_UT-DD-EN-0001.py
1 """
2 @PRIMARY: N/A
3 @PRIMARY_DESC: N/A
4 @SECONDARY: N/A
5 @DESIGN: N/A
6 @TESTCASE: - MR Node with more than two interface, P1..Pn
7 - MR Peers with more than one interface
8 - Ping all the peers from the node
9 - Verify that node sees different peers per NID
10 - Discover all the peers' first NID from the node
11 - Verify that node sees one MR peer with all its NIDS
12 """
13
14 import os
15 import yaml, random
16 import lnetconfig
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 lutf_file import LutfFile
23
24 def run():
25         la = agents.keys()
26         if len(la) < 2:
27                 return lutfrc(LUTF_TEST_SKIP, "Not enough agents to run the test")
28         helpers = []
29         try:
30                 # configure all the nodes
31                 for i in range(0, len(la)):
32                         t = LNetHelpers(target=la[i])
33                         intfs = t.get_available_devs()
34                         if len(intfs) < 2:
35                                 return lutfrc(LUTF_TEST_SKIP, "Not enough interfaces")
36                         t.configure_lnet()
37                         t.configure_net('tcp', intfs)
38                         t.set_discovery(1)
39                         helpers.append(t)
40
41                 # ping all the nodes from main
42                 main = helpers[0]
43                 main_prim_nid = main.list_nids()[0]
44                 total_nids = 0
45                 for i in range(1, len(helpers)):
46                         actual_nids = helpers[i].list_nids()
47                         total_nids += len(actual_nids)
48                         for nid in actual_nids:
49                                 if len(main.ping(nid)) == 0:
50                                         return lutfrc(LUTF_TEST_FAIL, "unable to ping" ,
51                                                 target=nid)
52
53                 # check that the peers created
54                 peers = main.get_peers()
55                 if len(peers['peer']) != total_nids:
56                         return lutfrc(LUTF_TEST_FAIL, "1. unexpected number of peers" ,
57                                         peers=peers, expected_num_peers=len(peers), actual_num_peers=total_nids)
58                 prim_nids = []
59                 for peer in peers['peer']:
60                         prim_nids.append(peer['primary nid'])
61                 for i in range(1, len(helpers)):
62                         actual_nids = helpers[i].list_nids()
63                         for nid in actual_nids:
64                                 if not nid in prim_nids:
65                                         return lutfrc(LUTF_TEST_FAIL, "unexpected peer set" ,
66                                                 actual_nids=actual_nids, prim_nids=prim_nids)
67
68                 # discover all the peers from main
69                 for i in range(1, len(helpers)):
70                         actual_nids = helpers[i].list_nids()
71                         if len(main.discover(actual_nids[0])) == 0:
72                                 return lutfrc(LUTF_TEST_FAIL, "unable to discover" ,
73                                         target=actual_nids[0])
74
75                 # make sure the peers is what we'd expect
76                 peers = main.get_peers()
77                 if len(peers['peer']) != len(helpers) - 1:
78                         return lutfrc(LUTF_TEST_FAIL, "2. unexpected number of peers" ,
79                                         peers=peers, expected_num_peers=len(peers), actual_num_peers=len(helpers)-1)
80                 for i in range(1, len(helpers)):
81                         actual_nids = helpers[i].list_nids()
82                         for peer in peers['peer']:
83                                 if peer['primary nid'] == actual_nids[0] and \
84                                    len(peer['peer ni']) != len(actual_nids):
85                                         return lutfrc(LUTF_TEST_FAIL, "3. unexpected number of peers",
86                                                         peers=peers, peer_nids=actual_nids)
87                                 elif peer['primary nid'] == actual_nids[0]:
88                                         for ni in peer['peer ni']:
89                                                 if not ni['nid'] in actual_nids:
90                                                         return lutfrc(LUTF_TEST_FAIL, "unexpected peer nid",
91                                                                 unkown_nid=ni['nid'], actual_nids=actual_nids)
92
93                 for h in helpers:
94                         h.unconfigure_lnet()
95
96                 return lutfrc(LUTF_TEST_PASS)
97         except Exception as e:
98                 for h in helpers:
99                         h.uninit()
100                 raise e
101