summaryrefslogtreecommitdiffstats
path: root/atf.py
diff options
context:
space:
mode:
authorShwetha-H-Panduranga <shwetha@gluster.com>2011-12-06 14:11:13 +0530
committerShwetha-H-Panduranga <shwetha@gluster.com>2011-12-06 14:11:13 +0530
commit18445ae1a94366c955cc7626fb8ec749dedcf73e (patch)
treeaf8b3a9db47f3a472aa4abae4629b517aa71885b /atf.py
parent5b847067495a65c71c56ad477780ed57e9e0fb2f (diff)
Adding New/Updated Automation Files
Diffstat (limited to 'atf.py')
-rwxr-xr-xatf.py296
1 files changed, 14 insertions, 282 deletions
diff --git a/atf.py b/atf.py
index e60bbb9..63b0f9d 100755
--- a/atf.py
+++ b/atf.py
@@ -1,222 +1,16 @@
-#!/usr/bin/env python
+"""atf module is the entry point of the regression suite.
-import sys
+CommandLine Usage: python atf.py -f testruninfo.cfg
+"""
import argparse
-import ConfigParser
-import ATFInit
-import ATFSetup
-import ATFExecute
-import ATFCleanup
-import ATFUtils
-
-##########################################################################
-## commandline : command executed to start the TestRun.
-##########################################################################
-commandline = ''
-
-##########################################################################
-## Configuration File Parser Object
-##########################################################################
-Config = ConfigParser.SafeConfigParser()
-
-def ConfigSectionMap(section):
- """
- Description:
- Get the key=value pair for the Section 'section' in the Config File
-
- Parameters:
- section: Section Name in the Config File
-
- Returns:
- Success: Dictionary: List of key=value pairs from section 'section'
- Failure: 1
- """
-
- dict1 = {}
-
- try:
- options = Config.options(section)
-
- except ConfigParser.NoSectionError:
- return 1
-
- else:
- for option in options:
- dict1[option] = Config.get(section, option)
-
- return dict1
-
-def parse_configfile(filename):
- """
- Description:
- Function to Parse the Configuration file
-
- Parameters:
- filename: Name of the configuration file
-
- Returns:
- Success: 0
- Failure: 1
- """
-
- keyword = ''
- workunit = ''
-
- status = Config.read(filename)
-
- if status == []:
- print "Configuration File: " + filename + "Not Found"
- return 1
- else:
- ### Parse Section: [Keywords] ###
- Map = ConfigSectionMap('Keywords')
-
- if Map == 1:
- print "Section: [Keywords] Not Found"
- return 1
- else:
- keyword = Map['keystring']
- ATFUtils.TestsObj.add_keywords(keyword)
-
- ### Parse Section: [WorkUnits] ###
- Map = ConfigSectionMap('WorkUnits')
-
- if Map == 1:
- print "Section: [WorkUnits] Not Found"
- return 1
- else:
- for key in Map.keys():
- workunit = Map[key]
- ATFUtils.TestsObj.add_testunits(workunit)
- ATFUtils.TestsObj.sort_testunits()
-
- ### Parse Section: [ATFRoot] ###
- Map = ConfigSectionMap('ATFRoot')
-
- if Map == 1:
- print "Section: [ATFRoot] Not Found"
- return 1
- else:
- atfroot = Map['rootdir']
-
- if atfroot == None:
- print "ATF_ROOT Not defined. "
- return 1
- else:
- if ATFUtils.set_environ(ATF_ROOT = atfroot):
- return 1
-
- ### Parse Section: [SummaryLog] ###
- Map = ConfigSectionMap('SummaryLog')
-
- if Map == 1:
- print "Section: [SummaryLog] Not Found"
- return 1
- else:
- summarylog_filename = Map['filename']
- summarylog_level = Map['loglevel']
-
- if summarylog_filename == None:
- summarylog_filename = 'SummaryLog.out'
-
- if summarylog_level == None:
- summarylog_level = 'INFO'
-
- ATFUtils.LogObj.set_summarylog(filename=summarylog_filename,
- loglevel=summarylog_level)
- abspath = atfroot + "/" + summarylog_filename
-
- if ATFUtils.set_environ(ATF_SUMMARYLOG = abspath):
- return 1
-
- ### Parse Detail Log Section ###
- Map = ConfigSectionMap('DetailLog')
-
- if Map == 1:
- print "Section: [DetailLog] Not Found"
- return 1
- else:
- detaillog_filename = Map['filename']
- detaillog_level = Map['loglevel']
-
- if detaillog_filename == None:
- detaillog_filename = 'DetailLog.out'
-
- if detaillog_level == None:
- detaillog_level = 'DEBUG'
-
- ATFUtils.LogObj.set_detaillog(filename=detaillog_filename,
- loglevel=detaillog_level)
-
- ### Parse Stdout Log Section ###
- Map = ConfigSectionMap('StdoutLog')
-
- if Map == 1:
- print "Section: [StdoutLog] Not Found"
- else:
- stdoutlog_log = Map['do_log']
- stdoutlog_level = Map['loglevel']
-
- if stdoutlog_log == 'true':
- if stdoutlog_level == None:
- stdoutlog_level = 'INFO'
- ATFUtils.LogObj.set_stdoutlog(loglevel=stdoutlog_level)
-
- ### Parse GlobalParam Section ###
- Map = ConfigSectionMap('GlobalParam')
-
- if Map == 1:
- print "Section: [GlobalParam] Not Found"
- return 1
- else:
- globalparamfile = Map['filename']
-
- if globalparamfile == None:
- print "Global Param File Not defined."
- return 1
- else :
- ATFUtils.TestEnvObj.set_globalparamfile(globalparamfile)
-
- #### Log the contents of Config File to SummaryLog and Stdout ####
- abspath = atfroot + "/" + summarylog_filename
-
- try:
- fhr = open(filename, "r")
-
- except IOError:
- print "IOError: Cannot Open Config FIle for Reading" + abspath
- return 1
-
- else:
- try:
- fhw = open(abspath, "w")
-
- except IOError:
- print "IOError: Cannot Open Summary Log FIle " + abspath
- fhr.close()
- return 1
-
- else:
- lines = fhr.readlines()
- fhw.write("Starting the Glusterfs Regression Tests")
- fhw.write("\n\nCommandLine: " + commandline + "\n\n")
- fhw.write(("-" * 50) + "\nConfiguration File Contents: \n" +
- ("-" * 50) + "\n")
- fhw.writelines(lines)
-
- fhw.close()
- fhr.close()
-
- return 0
+import atfinit
+import atfexecute
def main(args):
"""
Description:
- 1) Parse the Configuration File
- 2) Initialize the Loggers, TestEnvironment
- 3) Set-up TestBed for TestRun Execution
- 4) Execute the Tests for the WorkUnits Specified
- 5) Cleanup the TestEnvironment after the Test Execution is complete
+ *) Initialize TestRun
+ *) Execute TestUnits
Parameters:
args: Command Line Arguments passed to 'atf'
@@ -225,95 +19,33 @@ def main(args):
Success: 0
Failure: 1
"""
-
- configfilename = args.file[0]
- if parse_configfile(configfilename):
- exit(1)
-
- if ATFInit.initialize():
- exit(1)
-
- if ATFSetup.setup():
+ if atfinit.initialize(args):
exit(1)
- if ATFExecute.execute():
- exit(1)
-
- if ATFCleanup.cleanup():
+ if atfexecute.execute():
exit(1)
else:
exit(0)
if __name__ == "__main__":
-
- for arg in sys.argv:
- commandline = commandline + arg + " "
- parser = argparse.ArgumentParser(
- description="Runs GlusterFS Regression Test Suite",
+ argparser = argparse.ArgumentParser(
+ description="Runs GlusterFS Functional/Regression Test Suite",
epilog="Report Bugs to dl-qa@gluster.com")
- parser.add_argument('-f', '--file', nargs=1, required=True, type=str,
- help="Configuration FIleName")
+ argparser.add_argument('-f', '--file', required=True, type=str,
+ help="TestRunInfo FileName")
- args = parser.parse_args()
+ args = argparser.parse_args()
main(args)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-