Skip to content

Commit

Permalink
Cluster creation and glusterd start in framework
Browse files Browse the repository at this point in the history
The handling of cluster start and glusterd start will
be done at the main level. If it is nonDisruptive TCs,
then the cluster or glusterd working won't be tampered with
unless and until there's some serious issue or a new bug.

It is only for the disruptive cases wherein the cluster recreation
and glusterd startup will come handy.

Fixes: gluster#220

Signed-off-by: srijan-sivakumar <[email protected]>
  • Loading branch information
srijan-sivakumar committed Apr 22, 2021
1 parent a828794 commit ca587b0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
35 changes: 35 additions & 0 deletions core/environ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys
sys.path.insert(1, ".")
from common.mixin import RedantMixin

class environ:
"""
Framework level control on the gluster environment. Controlling both
the setup and the complete cleanup.
"""

def __init__(self, config_hashm : dict, log_path : str, log_level : str):
"""
Redant mixin obj to be used for server setup and teardown operations
has to be created.
"""
self.server_details = config_hashm['servers_info']
machine_details = {**self.server_details}
self.redant = RedantMixin(machine_details)
self.redant.init_logger("environ", log_path, log_level)
self.redant.establish_connection()

def setup_env(self):
"""
Setting up of the environment before the TC execution begins.
"""
self.redant.start_glusterd()
self.redant.create_cluster(list(self.server_details.keys()))

def teardown_env(self):
"""
The teardown of the complete environment once the test framework
ends.
"""
pass

8 changes: 7 additions & 1 deletion core/redant_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from test_list_builder import TestListBuilder
from test_runner import TestRunner
from result_handler import ResultHandler

from environ import environ

def pars_args():
"""
Expand Down Expand Up @@ -80,11 +80,17 @@ def main():
# Pre test run test list builder is modified.
test_cases_dict = TestListBuilder.pre_test_run_list_modify(test_cases_dict)

# Environment setup.
env_obj = environ(config_hashmap, args.log_dir+"/main.log", args.log_level)
env_obj.setup_env()

# invoke the test_runner.
TestRunner.init(test_cases_dict, config_hashmap, args.log_dir,
args.log_level, args.semaphore_count)
all_test_results = TestRunner.run_tests()

# Environment cleanup. TBD.

print(f"\nTotal time taken by the framework: {time.time()-start} sec")

ResultHandler.handle_results(all_test_results, args.result_path)
Expand Down
5 changes: 3 additions & 2 deletions core/runner_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ class RunnerThread:
"""

def __init__(self, mname: str, tc_class, config_hashmap: dict,
volume_type: str, log_path: str, log_level: str):
volume_type: str, log_path: str, log_level: str,
thread_flag : bool):
# Creating the test case object from the test case.
self.tc_obj = tc_class(mname, config_hashmap, volume_type,
log_path, log_level)
thread_flag, log_path, log_level)
self.run_test_func = getattr(self.tc_obj, "parent_run_test")
self.terminate_test_func = getattr(self.tc_obj, "terminate")
self.test_stats = {
Expand Down
2 changes: 1 addition & 1 deletion core/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _run_test(cls, test_dict: dict, thread_flag: bool):
runner_thread_obj = RunnerThread(str(uuid.uuid1().int), tc_class,
cls.config_hashmap,
test_dict["volType"], tc_log_path,
cls.log_level)
cls.log_level, thread_flag)
test_stats = runner_thread_obj.run_thread()

test_stats['timeTaken'] = time.time() - start
Expand Down
7 changes: 4 additions & 3 deletions tests/parent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ParentTest(metaclass=abc.ABCMeta):
"""

def __init__(self, mname: str, config_hashmap: dict, volume_type: str,
log_path: str, log_level: str = 'I'):
thread_flag: bool, log_path: str, log_level: str = 'I'):
"""
Creates volume
And runs the specific component in the
Expand All @@ -35,8 +35,9 @@ def __init__(self, mname: str, config_hashmap: dict, volume_type: str,
self.server_list = list(server_details.keys())
self.client_list = list(client_details.keys())

self.redant.start_glusterd()
self.redant.create_cluster(self.server_list)
if not thread_flag:
self.redant.start_glusterd()
self.redant.create_cluster(self.server_list)

def _configure(self, mname: str, server_details: dict,
client_details: dict, log_path: str, log_level: str):
Expand Down

0 comments on commit ca587b0

Please sign in to comment.