Skip to content

Commit 31acea1

Browse files
Passing the config hashmap to the parent test. (#194)
* Passing the config hashmap to the parent test. The config hashmap is passed from the params handler to the parent test. Fixes: #193 Signed-off-by: Nishith Vihar Sakinala <[email protected]> * Added volume_types as class variable in parent test Fixes: #193 Signed-off-by: Nishith Vihar Sakinala <[email protected]> * Retuning the hashmap as a class variable Returning hashmap as a class variable unlike using a temporary variable. Fixes: #193 Signed-off-by: Nishith Vihar Sakinala <[email protected]>
1 parent c217e8e commit 31acea1

File tree

5 files changed

+83
-53
lines changed

5 files changed

+83
-53
lines changed

core/parsing/params_handler.py

+68-40
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ParamsHandler:
1313
"""
1414

1515
@classmethod
16-
def get_config_hashmap(cls, filepath: str):
16+
def set_config_hashmap(cls, filepath: str):
1717
"""
1818
Gets the configuration hashmap generated from the
1919
api in Parser class and sets the reuired class variable.
@@ -46,49 +46,77 @@ def get_client_ip_list(cls) -> list:
4646
return client_ip_list
4747

4848
@classmethod
49-
def get_nodes_info(cls) -> dict:
49+
def get_config_hashmap(cls) -> dict:
5050
"""
51-
Returns a dictionary consisting of server info
51+
Returns the config hashmap which is parsed from
52+
the config file
5253
Returns:
53-
dict: dictionary consisting of server info
54-
format of dictionary:
55-
{
56-
servers: {
57-
"10.4.28.93": {
58-
"user" : root
59-
"passwd" : redhat
60-
},
61-
"23.43.12.87": {
62-
"user" : root
63-
"passwd" : redhat
64-
}
54+
dict: dictionary consisting of servers info,
55+
clients info and volume types info.
56+
format of dictionary:
57+
{
58+
servers_info: {
59+
"10.4.28.93": {
60+
"user" : root
61+
"passwd" : redhat
62+
},
63+
"23.43.12.87": {
64+
"user" : root
65+
"passwd" : redhat
66+
}
67+
}
68+
clients_info: {
69+
"10.3.28.92": {
70+
"user" : root
71+
"passwd" : redhat
72+
},
73+
"15.12.43.98": {
74+
"user" : root
75+
"passwd" : redhat
76+
}
77+
}
78+
volume_types: {
79+
"distributed": {
80+
"dist_count": "4"
81+
"transport": "tcp"
82+
}
83+
"replicated": {
84+
"replica_count": "3"
85+
"transport": "tcp"
86+
}
87+
"distributed-replicated": {
88+
"dist_count": "2"
89+
"replica_count": "3"
90+
"transport": "tcp"
91+
}
92+
"dispersed": {
93+
"disperse_count": "6"
94+
"redundancy_count": "2"
95+
"transport": "tcp"
96+
}
97+
"distributed-dispersed": {
98+
"dist_count": "2"
99+
"disperse_count": "6"
100+
"redundancy_count": "2"
101+
"transport": "tcp"
102+
}
103+
"arbiter": {
104+
"replica_count": "3"
105+
"arbiter_count": "1"
106+
"transport": "tcp"
107+
}
108+
"distributed-arbiter": {
109+
"dist_count": "2"
110+
"replica_count": "3"
111+
"arbiter_count": "1"
112+
"transport": "tcp"
113+
}
114+
}
115+
65116
}
66-
clients: {
67-
"10.3.28.92": {
68-
"user" : root
69-
"passwd" : redhat
70-
},
71-
"15.12.43.98": {
72-
"user" : root
73-
"passwd" : redhat
74-
}
75-
}
76-
}
77-
"""
78-
79-
nodes_info = {}
80-
s_info = cls.config_hashmap["servers_info"]
81-
c_info = cls.config_hashmap["clients_info"]
117+
"""
82118

83-
servers = list(s_info.keys())
84-
85-
for server in servers:
86-
s_info[server].pop("brick_root")
87-
88-
nodes_info['servers'] = s_info
89-
nodes_info['clients'] = c_info
90-
91-
return nodes_info
119+
return cls.config_hashmap
92120

93121
@classmethod
94122
def get_brick_root_list(cls, server_ip: str) -> list:

core/redant_main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def main():
5757
start = time.time()
5858
args = pars_args()
5959

60-
ParamsHandler.get_config_hashmap(args.config_file)
60+
ParamsHandler.set_config_hashmap(args.config_file)
6161

6262
# Obtain the client and server dict.
63-
mach_conn_dict = ParamsHandler.get_nodes_info()
63+
config_hashmap = ParamsHandler.get_config_hashmap()
6464

6565
# Building the test list and obtaining the TC details.
6666
test_cases_tuple = TestListBuilder.create_test_dict(args.test_dir,
@@ -78,7 +78,7 @@ def main():
7878
test_cases_dict = TestListBuilder.pre_test_run_list_modify(test_cases_dict)
7979

8080
# invoke the test_runner.
81-
TestRunner.init(test_cases_dict, mach_conn_dict, args.log_dir,
81+
TestRunner.init(test_cases_dict, config_hashmap, args.log_dir,
8282
args.log_level, args.semaphore_count)
8383
all_test_results = TestRunner.run_tests()
8484

core/runner_thread.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ class RunnerThread:
99
functions for running it.
1010
"""
1111

12-
def __init__(self, mname: str, tc_class, client_dict: dict,
13-
server_dict: dict, volume_type: str, log_path: str,
14-
log_level: str):
12+
def __init__(self, mname: str, tc_class, config_hashmap: dict,
13+
volume_type: str, log_path: str,log_level: str):
1514
# Creating the test case object from the test case.
16-
self.tc_obj = tc_class(mname, client_dict, server_dict, volume_type,
15+
self.tc_obj = tc_class(mname, config_hashmap, volume_type,
1716
log_path, log_level)
1817
self.run_test_func = getattr(self.tc_obj, "parent_run_test")
1918
self.terminate_test_func = getattr(self.tc_obj, "terminate")

core/test_runner.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class TestRunner:
1818
"""
1919

2020
@classmethod
21-
def init(cls, test_run_dict: dict, mach_conn_dict: dict,
21+
def init(cls, test_run_dict: dict, config_hashmap: dict,
2222
base_log_path: str, log_level: str, semaphore_count: int):
23-
cls.mach_conn_dict = mach_conn_dict
23+
cls.config_hashmap = config_hashmap
2424
cls.semaphore = Semaphore(semaphore_count)
2525
cls.base_log_path = base_log_path
2626
cls.log_level = log_level
@@ -82,8 +82,7 @@ def _run_test(cls, test_dict: dict, thread_flag: bool):
8282
# to calculate time spent to execute the test
8383
start = time.time()
8484
runner_thread_obj = RunnerThread(str(uuid.uuid1().int), tc_class,
85-
cls.mach_conn_dict["clients"],
86-
cls.mach_conn_dict["servers"],
85+
cls.config_hashmap,
8786
test_dict["volType"], tc_log_path,
8887
cls.log_level)
8988
test_stats = runner_thread_obj.run_thread()

tests/parent_test.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ class ParentTest(metaclass=abc.ABCMeta):
1313
1414
"""
1515

16-
def __init__(self, mname: str, client_details: dict, server_details: dict,
17-
volume_type: str, log_path: str, log_level: str = 'I'):
16+
def __init__(self, mname: str, config_hashmap: dict, volume_type: str,
17+
log_path: str, log_level: str = 'I'):
1818
"""
1919
Creates volume
2020
And runs the specific component in the
2121
test case
2222
"""
2323

24+
server_details = config_hashmap['servers_info']
25+
client_details = config_hashmap['clients_info']
26+
2427
self.TEST_RES = True
2528
self.volume_type = volume_type
2629
self.server_list = []
2730
self.client_list = []
31+
self.volume_types_info = config_hashmap['volume_types']
2832
self._configure(mname, server_details, client_details, log_path,
2933
log_level)
3034
self.server_list = list(server_details.keys())

0 commit comments

Comments
 (0)