diff options
author | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-12 11:12:41 +0530 |
---|---|---|
committer | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-12 11:12:41 +0530 |
commit | 134df3400b32ab379b99e6d493cd012ac2b8a21e (patch) | |
tree | 8255bdb51603232cf41c0af5baee510e1a3d20ea | |
parent | 65779e045af84437744597b372eb979c5090a599 (diff) |
Adding Readme, testunit file
-rw-r--r-- | README | 104 | ||||
-rw-r--r-- | TestUnits/xlators/cluster/afr/self_heal/Main.py | 69 | ||||
-rw-r--r-- | TestUnits/xlators/cluster/afr/self_heal/testunit.py | 113 |
3 files changed, 217 insertions, 69 deletions
@@ -0,0 +1,104 @@ +============================== +atf: Automated Tests Framework + +Automated Tests Framework provides libraries for automating functional testcases. +============================== + +Usage:- +------- +[automation]$ python atf.py --helpusage: atf [-h] --atfdir ATFDIR --testruninfo-file TESTRUNINFO_FILE + [--summarylog-file SUMMARYLOG_FILE] + [--summarylog-level SUMMARYLOG_LEVEL] + [--detaillog-file DETAILLOG_FILE] + [--detaillog-level DETAILLOG_LEVEL] [--stdout-dolog STDOUT_DOLOG] + [--stdoutlog-level STDOUTLOG_LEVEL] + +Runs GlusterFS Functional/Regression Test Suite + +optional arguments: + -h, --help show this help message and exit + --atfdir ATFDIR Absolute path of directory where automation framework + is installed + --testruninfo-file TESTRUNINFO_FILE + TestRunInfo FileName + --summarylog-file SUMMARYLOG_FILE + SummaryLog Filename + --summarylog-level SUMMARYLOG_LEVEL + SummaryLog LogLevel + --detaillog-file DETAILLOG_FILE + DetailLog Filename + --detaillog-level DETAILLOG_LEVEL + DetailLog LogLevel + --stdout-dolog STDOUT_DOLOG + Log to Stdout yes|no + --stdoutlog-level STDOUTLOG_LEVEL + StdoutLog LogLevel + +Report Bugs to dl-qa@gluster.com + +TestRunInfo File:- +------------------ +[TestUnits] : Define what testunits to run. + The relative path from "TestUnits" directory to the testunit + has to be specified under this section + Ex:- unit1 = xlators/cluster/afr/self_heal + unit2 = xlators/cluster/arf/basic_ops + +[Keywords] : Type of run + Ex:- keywords = art | sanity | bugs + +[GlusterVersion] : Glusterfs Version under test + Ex:- version = 3.2.5 + +Prerun:- Execute the following command from the atf directory +-------------------------------------------------------------- +export PYTHONPATH=`./export.py` + +Dependencies:- +-------------- +1) paramiko python package + +How to write testcases:- +------------------------ +# Create a directory for the feature you want to automate under TestUnits. + +# Under TestUnits the directory structure has to be the same as source +structure of glusterfs under + + Ex:- arf, self-heal functional testing + TestUnits/xlators/cluster/afr/self_heal + +# Every TestUnit should contain the following files:- + 1) testenv.cfg : Define the test environment + 2) testcaseslist : List of testcases for the feature + 3) testunit.py : Entry point for the TestUnit. For executing the testunit, + the main function of this module is called + 4) testcases.py : define the testcases here. + +# Create testunit.py (This is the entry point for the TestUnit). +Define the following functions: + 1) initialize : parse testenv.cfg, ssh_connect_allhosts + 2) setup : setup the active volume + 3) execute :parse testcaseslist to select the tests for execution, execute + each testcase + 4) cleanup : cleanup the test environment + +# testcases.py:- Define the testcase as a function. Use the framework libraries +or define new functions to automate tests + +# testcaseslist:- This file should contain names of the testcases defined in +testcases.py file. The testcase is associated with the version on which it +has to be tested. + +# testenv.cfg :- Define the test environment for the unit. The Servers, Clients, +Volume Info, Bricks, Exportdirs, MountPoints, MountDevice. + + + + + + + + + + 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 |