From 134df3400b32ab379b99e6d493cd012ac2b8a21e Mon Sep 17 00:00:00 2001 From: Shwetha-H-Panduranga Date: Mon, 12 Dec 2011 11:12:41 +0530 Subject: Adding Readme, testunit file --- TestUnits/xlators/cluster/afr/self_heal/Main.py | 69 ------------- .../xlators/cluster/afr/self_heal/testunit.py | 113 +++++++++++++++++++++ 2 files changed, 113 insertions(+), 69 deletions(-) delete mode 100644 TestUnits/xlators/cluster/afr/self_heal/Main.py create mode 100644 TestUnits/xlators/cluster/afr/self_heal/testunit.py (limited to 'TestUnits/xlators/cluster/afr') diff --git a/TestUnits/xlators/cluster/afr/self_heal/Main.py b/TestUnits/xlators/cluster/afr/self_heal/Main.py deleted file mode 100644 index 4e37265..0000000 --- a/TestUnits/xlators/cluster/afr/self_heal/Main.py +++ /dev/null @@ -1,69 +0,0 @@ -"""Main module for the testunit. - -This module "main" function is called from atfexecute to execute the testunit. -""" -import parser -import atfutils -import glusterutils -import managerutils -import testcases - -def initialize(filename): - """ - """ - return_status = 1 - if parser.parse_testenv_configfile(filename): - return return_status - if managerutils.ssh_connect_allhosts(): - return return_status - - return 0 - -def setup(): - """ - """ - return_status = 1 - if atfutils.set_active_volume("volume1"): - return return_status - return 0 - -def execute(*testcaselist): - """ - """ - passedtestcases = 0 - failedtestcases = 0 - selectedtestcases = len(testcaselist) - - for testcase in testcaselist: - function_obj = getattr(testcases, testcase) - if function_obj: - print "Starting Test: ' %s '" % testcase - return_status = function_obj() - if return_status: - print "TestCase ' %s ' Failed" % testcase - failedtestcases += 1 - else: - print "TestCase ' %s ' Passed" % testcase - passedtestcases += 1 - print "Ending Test: ' %s '" % testcase - else: - print "TestCase %s not defined in 'testcases' module" % testcase - continue - - print "Selected %d : Passed %d, Failed %d" % (selectedtestcases, - passedtestcases, - failedtestcases) - -def cleanup(): - """ - """ - pass - -def main(testenvfile, *testcaselist): - """ - """ - initialize(testenvfile) - setup() - execute(*testcaselist) - cleanup() - return diff --git a/TestUnits/xlators/cluster/afr/self_heal/testunit.py b/TestUnits/xlators/cluster/afr/self_heal/testunit.py new file mode 100644 index 0000000..39ee2a8 --- /dev/null +++ b/TestUnits/xlators/cluster/afr/self_heal/testunit.py @@ -0,0 +1,113 @@ +"""testunit.py is the main module for the testunit. + +This module "main" function is called from atfexecute to execute the testunit. +""" +from atfglobals import GlobalObj +import os +import parser +import atfutils +import managerutils +import testcases + + +filename = os.path.abspath(__file__) +dir_path = os.path.dirname(filename) + +def initialize(): + """ + """ + logger = GlobalObj.getLoggerObj() + return_status = 1 + testenv_file = GlobalObj.testenv_file + testenv_abspath = os.path.join(dir_path, testenv_file) + + if not (os.path.isfile(testenv_abspath)): + logger.error("%s not found in %s" % (testenv_file, dir_path)) + + if parser.parse_testenv_configfile(testenv_abspath): + return return_status + if managerutils.ssh_connect_allhosts(): + return return_status + + return 0 + +def setup(): + """ + """ + return_status = 1 + if atfutils.set_active_volume("volume1"): + return return_status + return 0 + +def execute(): + """ + """ + logger = GlobalObj.getLoggerObj() + return_status = 1 + testcaseslist_file = GlobalObj.testcaseslist_file + testcaseslist_abspath = os.path.join(dir_path, testcaseslist_file) + + if not (os.path.isfile(testcaseslist_abspath)): + logger.error("%s not found in %s" % (testcaseslist_file, dir_path)) + return return_status + + else: + testcaseslist = [] + testcaseslist = parser.parse_testcaseslist_file(testcaseslist_abspath) + if not testcaseslist: + logger.error("Skipping TestUnit %s. No testcases to execute" + % dir_path) + return 0 + else: + passedtestcases = 0 + failedtestcases = 0 + selectedtestcases = len(testcaseslist) + + logger.info("Starting TestUnit: '%s' test execution" % dir_path) + for testcase in testcaseslist: + function_obj = getattr(testcases, testcase) + if function_obj: + logger.debug("Starting Test: ' %s '" % testcase) + + return_status = function_obj() + if return_status: + logger.debug("TestCase '%s' Failed" % testcase) + failedtestcases += 1 + else: + logger.debug("TestCase '%s' Passed" % testcase) + passedtestcases += 1 + + logger.debug("Ending Test: '%s'" % testcase) + + else: + logger.info("TestCase %s not defined in 'testcases' module" + % testcase) + continue + + logger.info("Selected %d : Passed %d, Failed %d" + % (selectedtestcases, + passedtestcases, + failedtestcases)) + logger.info("Ending TestUnit: '%s' test execution" % dir_path) + + return 0 + +def cleanup(): + """ + """ + pass + +def main(): + """ + """ + return_status = 1 + if initialize(): + return return_status + if setup(): + return return_status + if execute(): + return return_status + if cleanup(): + return return_status + + return 0 -- cgit