summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TestUnits/xlators/cluster/afr/self_heal/testcases.py1
-rw-r--r--TestUnits/xlators/cluster/afr/self_heal/testenv.cfg8
-rwxr-xr-xatf.py66
-rw-r--r--atfexecute.py77
-rw-r--r--atfinit.py40
-rw-r--r--atfsetup.py58
-rwxr-xr-xexport.py2
-rwxr-xr-xlibs/connect/ssh.py32
-rw-r--r--libs/globals/atfglobals.py53
-rwxr-xr-xlibs/globals/testenv.py22
-rw-r--r--libs/globals/testruninfo.py74
-rw-r--r--libs/parser/parser.py52
-rw-r--r--libs/utils/atfutils.py11
-rw-r--r--libs/utils/clientutils.py52
-rw-r--r--libs/utils/glusterutils.py210
-rw-r--r--libs/utils/hostutils.py74
-rw-r--r--libs/utils/managerutils.py11
-rw-r--r--libs/utils/serverutils.py7
-rwxr-xr-xtestruninfo.cfg49
19 files changed, 466 insertions, 433 deletions
diff --git a/TestUnits/xlators/cluster/afr/self_heal/testcases.py b/TestUnits/xlators/cluster/afr/self_heal/testcases.py
index 0015e5f..e175ba7 100644
--- a/TestUnits/xlators/cluster/afr/self_heal/testcases.py
+++ b/TestUnits/xlators/cluster/afr/self_heal/testcases.py
@@ -10,6 +10,7 @@ import atfutils
import clientutils
import serverutils
import parser
+import pdb
def reset_testenv():
return_status = 1
diff --git a/TestUnits/xlators/cluster/afr/self_heal/testenv.cfg b/TestUnits/xlators/cluster/afr/self_heal/testenv.cfg
index a8b15c8..290f50f 100644
--- a/TestUnits/xlators/cluster/afr/self_heal/testenv.cfg
+++ b/TestUnits/xlators/cluster/afr/self_heal/testenv.cfg
@@ -12,6 +12,7 @@ downloadpath =
dir = /export
fstype = xfs
device = /dev/sdb1
+options =
[export2]
dir = /export
@@ -39,6 +40,13 @@ path = export1
hostname = server2.hostname
path = export2
+[brick3]
+hostname = server1.hostname
+path = /opt/export1
+
+[brick4]
+hostname = server2.hostname
+path = /opt/export1
# Volume Section
# Necessary Options: volumename, volumetype, count, transporttype, bricks
diff --git a/atf.py b/atf.py
index 63b0f9d..7ee9d13 100755
--- a/atf.py
+++ b/atf.py
@@ -4,42 +4,62 @@ CommandLine Usage: python atf.py -f testruninfo.cfg
"""
import argparse
import atfinit
+import atfsetup
import atfexecute
+import pdb
-def main(args):
- """
- Description:
- *) Initialize TestRun
- *) Execute TestUnits
+if __name__ == "__main__":
+
+ argparser = argparse.ArgumentParser(
+ prog='atf',
+ description="Runs GlusterFS Functional/Regression Test Suite",
+ epilog="Report Bugs to dl-qa@gluster.com")
+
+ argparser.add_argument('--atfdir', required=True, type=str,
+ help="Absolute path of directory where automation framework is installed")
+
+ argparser.add_argument('--testruninfo-file', required=True, type=str,
+ help="TestRunInfo FileName")
- Parameters:
- args: Command Line Arguments passed to 'atf'
+ argparser.add_argument('--summarylog-file', type=str,
+ default="summarylog.out",
+ help="SummaryLog Filename")
+
+ argparser.add_argument('--summarylog-level', type=str,
+ default='INFO',
+ help="SummaryLog LogLevel")
+
+ argparser.add_argument('--detaillog-file', type=str,
+ default="detaillog.out",
+ help="DetailLog Filename")
+
+ argparser.add_argument('--detaillog-level', type=str,
+ default='DEBUG',
+ help="DetailLog LogLevel")
+
+ argparser.add_argument('--stdout-dolog', type=str,
+ default='yes',
+ help="Log to Stdout yes|no")
+
+ argparser.add_argument('--stdoutlog-level', type=str,
+ default='INFO',
+ help="StdoutLog LogLevel")
+
+ args = argparser.parse_args()
- Returns:
- Success: 0
- Failure: 1
- """
if atfinit.initialize(args):
exit(1)
+ if atfsetup.setup():
+ exit(1)
+
if atfexecute.execute():
exit(1)
else:
exit(0)
-if __name__ == "__main__":
-
- argparser = argparse.ArgumentParser(
- description="Runs GlusterFS Functional/Regression Test Suite",
- epilog="Report Bugs to dl-qa@gluster.com")
-
- argparser.add_argument('-f', '--file', required=True, type=str,
- help="TestRunInfo FileName")
-
- args = argparser.parse_args()
-
- main(args)
+
diff --git a/atfexecute.py b/atfexecute.py
index a60402b..c793cbb 100644
--- a/atfexecute.py
+++ b/atfexecute.py
@@ -1,53 +1,56 @@
"""atfexecute
"""
-
import os.path
import sys
-import parser
+import imp
from atfglobals import GlobalObj
+import pdb
-def _execute_testunit(testunit):
+def _execute_testunit(testunitname):
"""
*) Parse the testcaseslist file in the 'testunit' and select test cases
specified for testing 'glusterversion'
*) Call Main.py of 'testunit' to execute the testcases.
"""
return_status = 1
- testruninfo_obj = GlobalObj.getTestrunInfoObj()
- atfdir = testruninfo_obj.getAtfDir()
- testunit_abspath = atfdir + "/TestUnits/" + testunit
-
- testenvfile = testunit_abspath + "/testenv.cfg"
- testcaseslistfile = testunit_abspath + "/testcaseslist"
-
- if not os.path.exists(testenvfile):
- default_testenvfile = atfdir + "testenv.cfg"
- if not os.path.exists(testenvfile):
- print "Skipping TestUnit %s . TestEnv File Not Found" % testenvfile
- return return_status
- else:
- testenvfile = default_testenvfile
-
- if not os.path.exists(testcaseslistfile):
- print "Skipping TestUnit %s" % testunit
- return return_status
+ logger = GlobalObj.getLoggerObj()
+ detaillog_file = GlobalObj.detaillog_file
+ detaillog_level = GlobalObj.detaillog_level
+ atfdir = GlobalObj.atfdir
+ testunits_maindir = GlobalObj.testunits_maindir
+ testunit_mainmodule = GlobalObj.testunit_mainmodule
+ testunit_abspath = os.path.join(atfdir, testunits_maindir, testunitname)
+
+
+ _file, path, description = imp.find_module(testunit_mainmodule,
+ [testunit_abspath])
+
+ if _file is None:
+ logger.error("TestUnit: %s not found" % testunit_abspath)
+ return 0
+
+ sys.path.append(testunit_abspath)
+ try:
+ module = imp.load_module(testunit_mainmodule, _file, path, description)
+
+ except ImportError:
+ logger.error("Unable to load '%s' in testunit %s" %
+ (testunit_mainmodule, testunitname))
+ logger.error("%s execution Failed" % testunitname)
+ return_status = 0
+
else:
- testcaseslist = []
- testcasespassed = None
- testcasesfailed = None
- totaltestcases = None
-
- testcaseslist = parser.parse_testcaseslist_file(testcaseslistfile)
- if not testcaseslist:
- print "Skipping TestUnit %s. No testcases to execute" % testunit
- return return_status
- else:
- sys.path.append(testunit_abspath)
- import Main
- print "Executing TestUnit: %s" % testunit
- print "-" * 50
- return_status = Main.main(testenvfile, *testcaseslist)
- return return_status
+ detaillog_abspath = os.path.join(testunit_abspath, detaillog_file)
+ if logger.addDetaillogHandler(detaillog_abspath, detaillog_level):
+ logger.error("Unbale to add Detaillog Handler for testunit: %s" %
+ testunitname)
+ return_status = module.main()
+ logger.removelogHandler('detaillog')
+
+ finally:
+ _file.close()
+ sys.path.remove(testunit_abspath)
+ return return_status
def execute():
"""
diff --git a/atfinit.py b/atfinit.py
index f50eefb..39b27fd 100644
--- a/atfinit.py
+++ b/atfinit.py
@@ -1,27 +1,35 @@
"""atfinit module
-
"""
import os.path
-import parser
from atfglobals import GlobalObj
-def _initialize_testrun_info(testrun_info_filename):
- """
- """
- return_status = 1
- if not os.path.exists(testrun_info_filename):
- print "Testrun Info File ' %s ' not found" % testrun_info_filename
- return return_status
- else:
- return_status = parser.parse_testrun_info_file(testrun_info_filename)
- return return_status
-
def initialize(args):
"""
*) Initialize TestrunInfo File
"""
- testrun_info_filename = args.file
- return_status = _initialize_testrun_info(testrun_info_filename)
- return return_status
+ atfdir = os.path.abspath(args.atfdir)
+ if not (os.path.exists(atfdir) and os.path.isdir(atfdir)):
+ print "ATFDIR '%s' doesn't exist" % atfdir
+ return 1
+
+ testruninfo_abspath = os.path.abspath(args.testruninfo_file)
+ if not (os.path.exists(testruninfo_abspath) and
+ os.path.isfile(testruninfo_abspath)):
+ testruninfo_abspath = os.path.join(atfdir, args.testruninfo_file)
+ if not (os.path.exists(testruninfo_abspath) and
+ os.patn.isfile(testruninfo_abspath)):
+ print "TestrunInfoFile '%s' doesn't exist" % args.testruninfo_file
+ return 1
+
+ GlobalObj.atfdir = atfdir
+ GlobalObj.testruninfo_file = testruninfo_abspath
+ GlobalObj.detaillog_file = args.detaillog_file
+ GlobalObj.detaillog_level = args.detaillog_level
+ GlobalObj.stdout_dolog = args.stdout_dolog
+ GlobalObj.stdoutlog_level = args.stdoutlog_level
+ GlobalObj.summarylog_file = args.summarylog_file
+ GlobalObj.summarylog_level = args.summarylog_level
+
+ return 0
__all__ = ['initialize']
diff --git a/atfsetup.py b/atfsetup.py
index 8631ab4..f8eb99a 100644
--- a/atfsetup.py
+++ b/atfsetup.py
@@ -1,37 +1,53 @@
"""atf setup
"""
-
+import re
+import os.path
from atfglobals import GlobalObj
+import parser
def _setup_loggers():
"""
"""
- testruninfo_obj = GlobalObj.getTestrunInfoObj()
- logger_obj = GlobalObj.getLoggerObj()
-
- summaryloginfo = testruninfo_obj.getSummaryLogInfo()
- detailloginfo = testruninfo_obj.getDetailLogInfo()
- stdoutloginfo = testruninfo_obj.getStdoutLogInfo()
-
- logger_obj.setSummaryLog(summaryloginfo['filename'],
- summaryloginfo['loglevel'])
- loggerobj.setDetailLog(detailloginfo['filename'],
- detailloginfo['loglevel'])
- loggerobj.setStdoutLog(stdoutloginfo['do_log'],
- stdoutloginfo['loglevel'])
+ return_status = 1
+ GlobalObj.initLoggerObj()
+ atfdir = GlobalObj.atfdir
+ summarylog_file = GlobalObj.summarylog_file
+ summarylog_level = GlobalObj.summarylog_level
+ stdout_dolog = GlobalObj.stdout_dolog
+ stdoutlog_level = GlobalObj.stdoutlog_level
+ logger = GlobalObj.getLoggerObj()
+
+ summarylog_abspath = os.path.join(atfdir, summarylog_file)
+ if logger.addSummarylogHandler(summarylog_abspath, summarylog_level):
+ print "IOError: %s" % "Error in Creating SummaryLog"
+ return return_status
+ if re.match("yes", stdout_dolog, re.IGNORECASE):
+ logger.addStdoutlogHandler(stdoutlog_level)
- atfdir = testruninfo_obj.getAtfDir()
- return_status = logger_obj.createLogger(atfdir)
- if return_status:
- print "Unable to create Loggers"
- return return_status
+ return 0
+def _setup_testrun_info():
+ """
+ """
+ testrun_info_file = GlobalObj.testruninfo_file
+ return_status = parser.parse_testrun_info_file(testrun_info_file)
+ return return_status
+
def setup():
"""
- *) Setup SummaryLogs , DetailLogs Handlers
+ # Setup Summary/Detail/Stdout LogHandlers
+ # Parser TestRunInfo file
+ #
"""
return_status = _setup_loggers()
- return return_status
+ if return_status:
+ return return_status
+
+ return_status = _setup_testrun_info()
+ if return_status:
+ return return_status
+
+ return 0
__all__ = ['setup']
diff --git a/export.py b/export.py
index e33812a..999a89c 100755
--- a/export.py
+++ b/export.py
@@ -4,7 +4,7 @@ import os
import os
exportstr = ''
-libdir = os.getcwd() + "/SharedModules/"
+libdir = os.getcwd() + "/libs/"
for dirname, dirnames, filenames in os.walk(libdir):
for subdirname in dirnames:
exportstr = exportstr + os.path.join(dirname, subdirname) + ':'
diff --git a/libs/connect/ssh.py b/libs/connect/ssh.py
index a9952bb..a419c31 100755
--- a/libs/connect/ssh.py
+++ b/libs/connect/ssh.py
@@ -3,16 +3,15 @@
remote server using SSH Protocol.
"""
import paramiko
-import pdb
import time
+from atfglobals import GlobalObj
class SshConnection():
- def __init__(self):
- self._connection = None
+ def __init__(self):
self._connection = paramiko.SSHClient()
- def connect(self, host, user=None, password=None):
+ def connect(self, host, user, password):
"""
Objective:
SSH to Server "host" as User "user"
@@ -26,30 +25,24 @@ class SshConnection():
Success: 0
Failure: 1
"""
+ logger = GlobalObj.getLoggerObj()
self._connection.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- if user == None:
- user = "root"
-
- if password == None:
- password = "syst3m"
-
try:
self._connection.connect(host, username=user, password=password)
except paramiko.BadHostKeyException as result:
- print(
- "BadHostKeyException: Unable to Connect to Server: '" + host +
- "' as User: '" + user + "'")
+ logger.error("BadHostKeyException: Unable to Connect to Server: '" + host +
+ "' as User: '" + user + "'")
return 1
except paramiko.AuthenticationException:
- print("AuthenticationException: Unable to Authenticate "
- + user + "@" + host)
+ logger.error("AuthenticationException: Unable to Authenticate " +
+ user + "@" + host)
return 1
except paramiko.SSHException:
- print("SSHException: Unknown server " + host)
+ logger.error("SSHException: Unknown server " + host)
return 1
return 0
@@ -74,6 +67,7 @@ class SshConnection():
Success: 0
Failure: 1
"""
+ logger = GlobalObj.getLoggerObj()
output = {}
output["exitstatus"] = None
output["stdoutdata"] = None
@@ -93,8 +87,8 @@ class SshConnection():
if commandInput:
stdin.write(commandInput)
else:
- print "This command requirs Command Input \
- after executing comamnd for command completion"
+ logger.error("This command requirs Command Input \
+ after executing comamnd for command completion")
stdin.write("\n")
return output
@@ -107,7 +101,7 @@ class SshConnection():
output["stderrdata"] = stderr.readlines()
except paramiko.SSHException:
- print("Unable to Execute Command: " + command)
+ logger.error("Unable to Execute Command: " + command)
return output
diff --git a/libs/globals/atfglobals.py b/libs/globals/atfglobals.py
index ff1faad..f1e6946 100644
--- a/libs/globals/atfglobals.py
+++ b/libs/globals/atfglobals.py
@@ -16,28 +16,43 @@ import testenv
import manager
class AtfGlobals:
-
-
def __init__(self):
self._testruninfo = None
- self._logger = logger.Log()
+ self._logger = None
self._env = None
- self._connectionsmanager = manager.ConnectionsManager()
-
- def getTestrunInfoObj(self):
- """Returns TestrunInfo Object
+ self._connectionsmanager = None
+ self.logname = "ATFLOG"
+ self.atfdir = None
+ self.testruninfo_file = None
+ self.summarylog_file = "summarylog.out"
+ self.summarylog_level = 'INFO'
+ self.detaillog_file = "detaillog.out"
+ self.detaillog_level = 'DEBUG'
+ self.stdoutlog_dolog = 'yes'
+ self.stdoutlog_level = 'INFO'
+ self.testunits_maindir = "TestUnits"
+ self.testunit_mainmodule = "testunit"
+ self.testenv_file = "testenv.cfg"
+ self.testcaseslist_file = "testcaseslist"
+ self.glusterd_dir = "/etc/glusterd/*"
+ self.glusterd_log_paths = ["/var/log/glusterfs/*.log",
+ "/var/log/glusterfs/bricks/*"]
+
+
+ def initLoggerObj(self):
+ """Instantiation of Logger Object
"""
- return self._testruninfo
-
+ self._logger = logger.Log(self.logname)
+
def getLoggerObj(self):
"""Returns Logger Object
"""
return self._logger
- def getTestenvObj(self):
- """Returns Current TestEnvironment Object.
+ def initConnectionsManagerObj(self):
+ """Instantiation of ConnectionsManager Object
"""
- return self._env
+ self._connectionsmanager = manager.ConnectionsManager()
def getConnectionsManagerObj(self):
"""Returns ConnectionsManager Object
@@ -48,21 +63,21 @@ class AtfGlobals:
"""Instantiation of TestrunInfo Object
"""
self._testruninfo = testruninfo.TestRunInfo()
-
- def initLoggerObj(self):
- """Instantiation of Logger Object
+
+ def getTestrunInfoObj(self):
+ """Returns TestrunInfo Object
"""
- self._logger = logger.Log()
+ return self._testruninfo
def initTestenvObj(self):
"""Instantiation of Testenv Object
"""
self._env = testenv.TestEnv()
- def initConnectionsManagerObj(self):
- """Instantiation of ConnectionsManager Object
+ def getTestenvObj(self):
+ """Returns Current TestEnvironment Object.
"""
- self._connectionsmanager = manager.ConnectionsManager()
+ return self._env
GlobalObj = AtfGlobals()
__all__ = ['GlobalObj']
diff --git a/libs/globals/testenv.py b/libs/globals/testenv.py
index 9aa8ec8..0720c2c 100755
--- a/libs/globals/testenv.py
+++ b/libs/globals/testenv.py
@@ -23,7 +23,7 @@ class TestEnv():
self._active_volume = None
self._exportdir_tuple = namedtuple('ExportDir',
- ['dir', 'fstype', 'device'])
+ ['dir', 'fstype', 'device', 'options'])
self._server_tuple = namedtuple('Server',
['hostname', 'user', 'password',
@@ -50,14 +50,19 @@ class TestEnv():
def addExportdir(self, key, dir_, **arguments):
"""
"""
- fstype = device = None
+ fstype = None
+ device = None
+ options = None
if (arguments.has_key('fstype') and arguments['fstype']):
fstype = arguments['fstype']
if (arguments.has_key('device') and arguments['device']):
device = arguments['device']
-
- exportdir_obj = self._exportdir_tuple(dir_, fstype, device)
+
+ if (arguments.has_key('options') and arguments['options']):
+ options = arguments['options']
+
+ exportdir_obj = self._exportdir_tuple(dir_, fstype, device, options)
self._exportdirs[key] = exportdir_obj
def getExportdir(self, exportdirkey):
@@ -167,7 +172,7 @@ class TestEnv():
path_value = brick_obj.path
if re.match("^\/", path_value):
- path = path_value
+ newpath = path_value
else:
exportdir_obj = self.getExportdir(path_value)
if exportdir_obj:
@@ -204,11 +209,14 @@ class TestEnv():
brick_keys.extend(self._bricks.keys())
return brick_keys
- def addBricksToVolume(self, volumekey="ActiveVolume", *bricks):
+ def addBricksToVolume(self, *bricks, **arguments):
"""
"""
volume_obj = None
- if volumekey == "ActiveVolume":
+
+ if arguments.has_key("volumekey"):
+ volumekey = arguments[volumekey]
+ else:
volumekey = self._active_volume
if not (volumekey and self._volumes.has_key(volumekey)):
diff --git a/libs/globals/testruninfo.py b/libs/globals/testruninfo.py
index 9b012e8..76137f1 100644
--- a/libs/globals/testruninfo.py
+++ b/libs/globals/testruninfo.py
@@ -10,10 +10,6 @@ class TestRunInfo():
self._testunits = []
self._keywords = ''
self._glusterversion = ''
- self._atfdir = ''
- self._summaryloginfo = {}
- self._detailloginfo = {}
- self._stdoutloginfo = {}
def addGlusterVersion(self, version):
"""
@@ -24,77 +20,7 @@ class TestRunInfo():
"""
"""
return self._glusterversion
-
- def addSummaryLogInfo(self, filename, loglevel):
- """
- """
- if not filename:
- filename = "SummaryLog.out"
-
- if not loglevel:
- loglevel = "info"
-
- self._summaryloginfo['filename'] = filename
- self._summaryloginfo['loglevel'] = loglevel
-
- def getSummaryLogInfo(self):
- """
- """
- return self._summaryloginfo
-
- def addDetailLogInfo(self, filename, loglevel):
- """
- """
- if not filename:
- filename = "DetailLog.out"
-
- if not loglevel:
- loglevel = "info"
-
- self._detailloginfo['filename'] = filename
- self._detailloginfo['loglevel'] = loglevel
-
- def getDetailLogInfo(self):
- """
- """
- return self._detailloginfo
- def addStdoutLogInfo(self, do_log, loglevel):
- """
- """
- true_pattern = re.compile('True|Yes', re.IGNORECASE)
- false_pattern = re.compile('False|No', re.IGNORECASE)
-
- if not loglevel:
- loglevel = "info"
-
- if true_pattern.match(do_log):
- do_log = True
-
- elif false_pattern.match(do_log):
- do_log = False
-
- else:
- do_log = True
-
- self._stdoutloginfo['do_log'] = do_log
- self._stdoutloginfo['loglevel'] = loglevel
-
- def getStdoutLogInfo(self):
- """
- """
- return self._stdoutloginfo
-
- def addAtfDir(self, atfdir):
- """
- """
- self._atfdir = atfdir
-
- def getAtfDir(self):
- """
- """
- return self._atfdir
-
def addTestUnits(self, testunit):
"""
Description:
diff --git a/libs/parser/parser.py b/libs/parser/parser.py
index ee3a2d1..70619c9 100644
--- a/libs/parser/parser.py
+++ b/libs/parser/parser.py
@@ -24,11 +24,13 @@ def verify_necessary_options(cp, section, necessary_options):
Success: True (if all necessary_options are found in 'section')
Failure: False ( if any of the necessaty_options not found in 'section')
"""
+ logger = GlobalObj.getLoggerObj()
all_options_found = True
items = dict(cp.items(section))
for option in necessary_options:
if not (items.has_key(option) and items[option]):
- print "' %s ' Should be defined in Section: %s" % (option, section)
+ logger.error("' %s ' Should be defined in Section: %s" %
+ (option, section))
all_options_found = False
return all_options_found
@@ -40,14 +42,13 @@ def parse_testrun_info_file(filename):
GlobalObj.initTestrunInfoObj()
testruninfo_obj = GlobalObj.getTestrunInfoObj()
cp = ConfigParser.SafeConfigParser()
- necessary_sections = ["keywords", "testunits", "atfdir",
- "summarylog","detaillog", "stdoutlog",
- "glusterversion"]
+ necessary_sections = ["keywords", "testunits", "glusterversion"]
matched_sections = []
unmatched_sections = []
+ logger = GlobalObj.getLoggerObj()
if not cp.read(filename):
- print "Error reading file ' %s '.File Not found " % filename
+ logger.error("Error reading file ' %s '.File Not found " % filename)
return 1
else:
available_sections = cp.sections()
@@ -63,8 +64,8 @@ def parse_testrun_info_file(filename):
if not found_all_sections:
for section in unmatched_sections:
- print "Section %s Not Found" % section
- print "Please define the above sections in TestRunInfo File"
+ logger.error("Section %s Not Found" % section)
+ logger.error("Please define the above sections in TestRunInfo File")
return 1
else:
@@ -81,37 +82,12 @@ def parse_testrun_info_file(filename):
if testunit:
testruninfo_obj.addTestUnits(testunit)
- elif re.match("atfdir", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- atfdir = Map['dir']
- if not atfdir:
- print "dir option not defined in ATFDir. " + \
- "The 'dir'option should be defined"
- return 1
- else:
- testruninfo_obj.addAtfDir(atfdir)
-
- elif re.match("summarylog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addSummaryLogInfo(Map['filename'],
- Map['loglevel'])
-
- elif re.match("detaillog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addDetailLogInfo(Map['filename'],
- Map['loglevel'])
-
- elif re.match("stdoutlog", section, re.IGNORECASE):
- Map = dict(cp.items(section))
- testruninfo_obj.addStdoutLogInfo(Map['do_log'],
- Map['loglevel'])
-
elif re.match("glusterversion", section, re.IGNORECASE):
Map = dict(cp.items(section))
glusterversion = Map['version']
if not glusterversion:
- print "version option not defined in GlusterVersion. " + \
- "The 'version' option should be defined"
+ logger.error("version option not defined in GlusterVersion. " + \
+ "The 'version' option should be defined")
return 1
else:
testruninfo_obj.addGlusterVersion(glusterversion)
@@ -124,8 +100,10 @@ def parse_testcaseslist_file(filename):
"""
return_status = 1
testcaseslist = []
+ logger = GlobalObj.getLoggerObj()
+
if not os.path.exists(filename):
- print "%s file not found." % filename
+ logger.error("%s file not found." % filename)
return return_status
testruninfo_obj = GlobalObj.getTestrunInfoObj()
@@ -190,8 +168,10 @@ def parse_testenv_configfile(filename):
"mount" : "addMount",
"defaults" : "addDefaults"}
section_pattern = re.compile('(export|server|brick|volume|client|mountdevice|mount)*')
+ logger = GlobalObj.getLoggerObj()
+
if not cp.read(filename):
- print "Error reading file ' %s '.File Not found " % filename
+ logger.error("Error reading file ' %s '.File Not found " % filename)
return 1
else:
defaults = dict(cp.defaults())
diff --git a/libs/utils/atfutils.py b/libs/utils/atfutils.py
index 980c286..9b91ae2 100644
--- a/libs/utils/atfutils.py
+++ b/libs/utils/atfutils.py
@@ -30,23 +30,26 @@ def assert_failure(**arguments):
def print_stdout(stdoutdata):
"""
"""
+ logger = GlobalObj.getLoggerObj()
if not stdoutdata == None:
for data in stdoutdata:
- print data
+ logger.debug(data)
def print_stderr(stderrdata):
+ logger = GlobalObj.getLoggerObj()
if not stderrdata == None:
for data in stderrdata:
- print data
+ logger.debug(data)
def set_active_volume(volumekey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
return_status = env.setActiveVolume(volumekey)
if return_status:
- print "Unable to set Active Volume. '%s' Not defined in TestEnvironment"\
- % volumekey
+ logger.error("Unable to set Active Volume. \
+ '%s' Not defined in TestEnvironment" % volumekey )
return return_status
diff --git a/libs/utils/clientutils.py b/libs/utils/clientutils.py
index ad5d593..33f036e 100644
--- a/libs/utils/clientutils.py
+++ b/libs/utils/clientutils.py
@@ -12,6 +12,7 @@ Supported Wrappers :-
import atfutils
import hostutils
from atfglobals import GlobalObj
+import pdb
def umount(mountkey):
"""unmounts a mountpoint
@@ -24,23 +25,26 @@ def umount(mountkey):
Success : 0
Failure : 1`
"""
- base_command = "umount "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "umount"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
mount_obj = env.getMount(mountkey)
if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
+ logger.error("InValid Mount. '%s' not defined in TestEnvironment"
+ % mountkey)
return 1
clientkey = mount_obj.client
client_connection = cm.getConnection(clientkey)
if not client_connection:
- print "SSH connection to host '%s' has not been established" % clientkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % clientkey)
return 1
- command = base_command + mount_obj.dir
- print "%s : %s" % (clientkey, command)
+ command = ' '.join([base_command, mount_obj.dir])
+ logger.debug('%s: Executing Command: %s' % (clientkey, command))
output = client_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -51,7 +55,7 @@ def umount(mountkey):
return_status = 0
else:
- print "Unable to umount %s" % mountkey
+ logger.error("Unable to umount %s" % mountkey)
return return_status
@@ -91,41 +95,44 @@ def mount(mountkey):
Success : 0
Failure : 1`
"""
-
- base_command = command = "mount "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "mount"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
+ options = []
mount_obj = env.getMount(mountkey)
if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
+ logger.error("InValid Mount. %s not defined in TestEnvironment"
+ % mountkey)
return 1
clientkey = mount_obj.client
client_connection = cm.getConnection(clientkey)
if not client_connection:
- print "SSH connection to host '%s' has not been established" % clientkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % clientkey)
return 1
+ return_status = hostutils.mkdir(clientkey, mount_obj.dir)
+ if return_status:
+ return return_status
+
mountdevice_obj = mount_obj.device
device = mountdevice_obj.hostname + ":/" + mountdevice_obj.volumename
- options = ["-t", mount_obj.type]
+ options.extend(["-t", mount_obj.type])
if mount_obj.logfile:
options.extend(["-o", ("log-file="+mount_obj.logfile),
"log-level=INFO"])
-
if mount_obj.options:
options.extend([mount_obj.option])
-
options.extend([device, mount_obj.dir])
- for index, option in enumerate(options):
- command = command + option + " "
+
+ command.extend(options)
+ command = ' '.join(command)
- return_status = hostutils.mkdir(clientkey, mount_obj.dir)
- if return_status:
- return return_status
-
- print "%s : %s" % (clientkey, command)
+ logger.debug('%s: Executing Command: %s' % (clientkey, command))
output = client_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -156,12 +163,15 @@ def mountall():
def execute_on_mount(mountkey, command, commandInput=None):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
mount_obj = env.getMount(mountkey)
if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
+ logger.error("InValid Mount. %s not defined in TestEnvironment"
+ % mountkey)
return 1
+
clientkey = mount_obj.client
mountdir = mount_obj.dir
command = "cd " + mountdir + " ;" + command
diff --git a/libs/utils/glusterutils.py b/libs/utils/glusterutils.py
index 0c15af1..7ab41d0 100644
--- a/libs/utils/glusterutils.py
+++ b/libs/utils/glusterutils.py
@@ -27,17 +27,18 @@ import atfutils
import hostutils
from atfglobals import GlobalObj
-
def glusterd_start(serverkey, force=False):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
commands_to_execute = ["which glusterd", "ps -e | grep glusterd"]
gluster_version = env.getServer(serverkey).glusterversion
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
""" Check if gluster is already running. If already Running and force=True,
@@ -55,7 +56,7 @@ def glusterd_start(serverkey, force=False):
command = commands_to_execute.pop()
output = host_connection.executecommand(command)
if output["exitstatus"]:
- print "Unable to start glusterd"
+ logger.error("Unable to start glusterd")
return_status = atfutils.assert_success(**output)
return return_status
else:
@@ -63,7 +64,7 @@ def glusterd_start(serverkey, force=False):
gluster_path = None
gluster_path = output["stdoutdata"][0].strip("\n")
else:
- print "Unable to find gluster path"
+ logger.error("Unable to find gluster path")
return_status = atfutils.assert_success(**output)
return return_status
@@ -72,17 +73,18 @@ def glusterd_start(serverkey, force=False):
output = host_connection.executecommand(command)
if not output["stdoutdata"] == None:
if re.search(gluster_version, str(output["stdoutdata"])):
- print "%s : %s" % (serverkey, gluster_path)
+ logger.debug('%s: Executing Command: %s'
+ %(serverkey, gluster_path))
output = host_connection.executecommand(gluster_path)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
atfutils.print_stderr(output['stderrdata'])
return return_status
else:
- print "Unable to start glusterd"
+ logger.error("Unable to start glusterd")
return 1
else:
- print "Unable to start glusterd"
+ logger.error("Unable to start glusterd")
return 1
def glusterd_start_allservers(force=False):
@@ -100,12 +102,14 @@ def glusterd_start_allservers(force=False):
def glusterd_stop(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "kill -KILL "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
gluster_pid_list = []
@@ -121,7 +125,7 @@ def glusterd_stop(serverkey):
for pid in gluster_pid_list:
command = base_command + pid
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -156,21 +160,26 @@ def glusterd_restart(serverkey):
def glusterd_remove_dir(serverkey):
"""
"""
- command = "rm -rf /etc/glusterd/*"
+ logger = GlobalObj.getLoggerObj()
+ base_command = "rm -rf"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ glusterd_dir = GlobalObj.glusterd_dir
server_obj = env.getServer(serverkey)
if not server_obj:
- print "Invalid Host. %s not defined in TestEnvironment" % serverkey
+ logger.error("Invalid Host. %s not defined in TestEnvironment"
+ % serverkey)
return 1
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
-
- print "%s : %s" % (serverkey, command)
+
+ command = ' '.join([base_command, glusterd_dir])
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -191,8 +200,9 @@ def glusterd_remove_dir_allservers():
def glusterd_remove_logs(serverkey):
"""
"""
- base_command = "rm -rf "
- log_paths = ["/var/log/glusterfs/*.log", "/var/log/glusterfs/bricks/*"]
+ logger = GlobalObj.getLoggerObj()
+ base_command = "rm -rf"
+ log_paths = GlobalObj.glusterd_log_paths
absolute_path_list = []
prefix_path = ''
env = GlobalObj.getTestenvObj()
@@ -200,12 +210,14 @@ def glusterd_remove_logs(serverkey):
server_obj = env.getServer(serverkey)
if not server_obj:
- print "Invalid Host. %s not defined in TestEnvironment" % serverkey
+ logger.error("Invalid Host. %s not defined in TestEnvironment"
+ % serverkey)
return 1
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
if server_obj.installpath:
@@ -215,8 +227,8 @@ def glusterd_remove_logs(serverkey):
absolute_path_list.append(prefix_path + path)
for path in absolute_path_list:
- command = base_command + path
- print "%s : %s" % (serverkey, command)
+ command = ' '.join([base_command, path])
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -237,21 +249,24 @@ def glusterd_remove_logs_allservers():
def volume_delete(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume delete "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "Invalid Volume.ActiveVolume not defined for the TestEnvironment"
+ logger.error("Invalid Volume.ActiveVolume not defined" +
+ "for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -261,30 +276,30 @@ def volume_delete(serverkey):
def volume_create(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume create "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
-
- command = base_command + \
- active_volume.volumename + " " + \
- active_volume.volumetype + " " + \
- active_volume.count + " " + \
- "transport " + active_volume.transporttype + " "
+
+ command = ' '.join([base_command, active_volume.volumename,
+ active_volume.volumetype, active_volume.count,
+ "transport", active_volume.transporttype])
for brick_obj in active_volume.bricks:
brick_value = brick_obj.hostname + ":" + brick_obj.path
- command = command + brick_value + " "
+ command = ' '.join([command, brick_value])
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if return_status:
@@ -297,12 +312,13 @@ def volume_create(serverkey):
def volume_start(serverkey, force=False):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume start "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
@@ -311,10 +327,11 @@ def volume_start(serverkey, force=False):
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if return_status:
@@ -327,12 +344,13 @@ def volume_start(serverkey, force=False):
def volume_stop(serverkey, force=False):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume stop "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
@@ -341,10 +359,11 @@ def volume_stop(serverkey, force=False):
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -354,29 +373,35 @@ def volume_stop(serverkey, force=False):
def volume_addbrick(serverkey, *bricks):
"""
"""
- base_command = "gluster volume add-brick "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "gluster volume add-brick"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
+ command = [base_command]
+
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
- volumename = active_volume.volumenameGlobalObj.getConnectionsManagerObj()
- command = base_command + volumename + " "
+ volumename = active_volume.volumename
+
+ command.extend([volumename])
for brick in bricks:
brick_obj = env.getBrick(brick)
if not brick_obj:
- print "Invalid Brick. Brick Not defined in TestEnvironment"
+ logger.error("Invalid Brick. Brick Not defined in TestEnvironment")
return 1
brick_value = brick_obj.hostname + ":" + brick_obj.path
- command = command + brick_value
-
+ command.extend([brick_value])
+
+ command = ' '.join(command)
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if not return_status:
@@ -389,25 +414,33 @@ def volume_addbrick(serverkey, *bricks):
def volume_replacebrick(serverkey, replacebrick_key, tobrick_key):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume replace-brick "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
+
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
- command = base_command + volumename + " "
replace_brick = env.getbrick(replacebrick_key)
to_brick = env.getbrick(tobrick_key)
- command = command + replace_brick + " " + to_brick
-
+
+ if not (to_brick and replace_brick):
+ logger.error("Invalid Brick. Brick Not defined in TestEnvironment")
+ return 1
+
+ command.extend([volumename, replace_brick, to_brick])
+ command = ' '.join(command)
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
if not return_status:
@@ -420,21 +453,28 @@ def volume_replacebrick(serverkey, replacebrick_key, tobrick_key):
def volume_set(serverkey, key, value):
"""
"""
- base_command = "gluster volume set "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "gluster volume set"
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
+
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
- command = base_command + volumename + " " + key + " " + value
+
+ command.extend([volumename, key, value])
+ command = ' '.join(command)
+
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -444,21 +484,23 @@ def volume_set(serverkey, key, value):
def volume_reset(serverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster volume reset "
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
active_volume = env.getActiveVolume()
if not active_volume:
- print "ActiveVolume not defined for the TestEnvironment"
+ logger.error("ActiveVolume not defined for the TestEnvironment")
return 1
volumename = active_volume.volumename
command = base_command + volumename
host_connection = cm.getConnection(serverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = host_connection.executecommand(command, commandInput="y\n")
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -468,8 +510,9 @@ def volume_reset(serverkey):
def peer_probe(fromserverkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "gluster peer probe "
- command = base_command
+ command = [base_command]
all_servers = {}
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
@@ -481,14 +524,16 @@ def peer_probe(fromserverkey):
continue
else:
server_obj = all_servers[key]
- command = command + server_obj.hostname + " "
-
+ command.extend([server_obj.hostname])
+
+ command = ' '.join(command)
host_connection = cm.getConnection(fromserverkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
- print "%s : %s" % (fromserverkey, command)
+ logger.debug('%s: Executing Command: %s' % (fromserverkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -498,6 +543,7 @@ def peer_probe(fromserverkey):
def create_brick(brickkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
return_status = 1
env = GlobalObj.getTestenvObj()
brick_obj = env.getRawBrick(brickkey)
@@ -513,20 +559,20 @@ def create_brick(brickkey):
if re.match("^\/", exportdir):
dirpath = exportdir
- command = base_command + dirpath
else:
export_obj = env.getExportdir(exportdir)
dirpath = export_obj.dir
device = export_obj.device
fstype = export_obj.fstype
+ options = export_obj.options
- print "%s : %s" % (serverkey, 'create_brick')
+ logger.debug('%s: Executing Command: %s'% (serverkey, 'create_brick'))
if device:
if umount_device(serverkey, device):
return return_status
if hostutils.mkfs(serverkey, device, fstype):
return return_status
- if mount_exportdir(serverkey, device, fstype, dirpath):
+ if mount_exportdir(serverkey, device, fstype, options, dirpath):
return return_status
return 0
@@ -541,19 +587,21 @@ def create_brick(brickkey):
def umount_device(serverkey, device):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "umount "
cm = GlobalObj.getConnectionsManagerObj()
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
mountpoints = hostutils.find_mountpoints(serverkey, device)
for mountpoint in mountpoints:
command = base_command + mountpoint
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -568,23 +616,31 @@ def umount_device(serverkey, device):
return 0
-def mount_exportdir(serverkey, device, fstype, dirpath):
+def mount_exportdir(serverkey, device, fstype, options, dirpath):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "mount "
cm = GlobalObj.getConnectionsManagerObj()
+ command = [base_command]
server_connection = cm.getConnection(serverkey)
if not server_connection:
- print "SSH connection to host '%s' has not been established" % serverkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % serverkey)
return 1
if fstype is None:
fstype = "xfs"
+ command.extend(["-t", fstype])
+
+ if options:
+ command.extend([options])
+
+ command.extend([device, dirpath])
+ command = ' '.join(command)
- command = base_command + "-t " + fstype + " " + device + " " + dirpath
-
- print "%s : %s" % (serverkey, command)
+ logger.debug('%s: Executing Command: %s' % (serverkey, command))
output = server_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
diff --git a/libs/utils/hostutils.py b/libs/utils/hostutils.py
index 68bb1bf..9992bb6 100644
--- a/libs/utils/hostutils.py
+++ b/libs/utils/hostutils.py
@@ -12,18 +12,23 @@ Supported Wrappers:
import re
import atfutils
from atfglobals import GlobalObj
+import pdb
+
+system_dirs = re.compile('(/bin|/boot|/dev|/etc|/lib|/mnt|/net|/opt|/root|/sbin|/usr|/var|/sys)\/?$')
def cd(hostkey, dirpath):
"""
"""
- base_command = "cd "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "cd"
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' " % hostkey)
return 1
- command = base_command + dirpath
- print "%s : %s" % (hostkey, command)
+
+ command = ' '.join([base_command, dirpath])
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -33,20 +38,22 @@ def cd(hostkey, dirpath):
def rmdir(hostkey, dirpath):
"""
"""
- base_command = "rm -rf "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "rm -rf"
cm = GlobalObj.getConnectionsManagerObj()
- system_dirs = re.compile('(/bin|/boot|/dev|/etc|/lib|/mnt|/net|/opt|/root|/sbin|/usr|/var|/sys)\/?$')
if system_dirs.match(dirpath):
- print "System Directiories cannot be deleted"
+ logger.error("System Directiories cannot be deleted")
return 1
else:
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' "
+ % hostkey)
return 1
- command = base_command + dirpath
- print "%s : %s" % (hostkey, command)
+
+ command = ' '.join([base_command, dirpath])
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -56,20 +63,23 @@ def rmdir(hostkey, dirpath):
def mkdir(hostkey, dirpath):
"""
"""
- base_command = "mkdir -p "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "mkdir -p"
cm = GlobalObj.getConnectionsManagerObj()
- system_dirs = re.compile('(/bin|/boot|/dev|/etc|/lib|/mnt|/net|/opt|/root|/sbin|/usr|/var|/sys)\/?$')
+
if system_dirs.match(dirpath):
- print "System Directiories cannot be created"
+ logger.error("System Directiories cannot be created")
return 1
else:
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' "
+ % hostkey)
return 1
- command = base_command + dirpath
- print "%s : %s" % (hostkey, command)
+
+ command = ' '.join([base_command, dirpath])
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -79,18 +89,25 @@ def mkdir(hostkey, dirpath):
def mkfs(hostkey, device, fstype=None):
"""
"""
- base_command = "mkfs "
+ logger = GlobalObj.getLoggerObj()
+ base_command = "mkfs"
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
+ command = [base_command]
+ options = []
+
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' " % hostkey)
return 1
if fstype is None:
fstype = "xfs"
-
- command = base_command + " -t " + fstype + " -f " + device
- print "%s : %s" % (hostkey, command)
+
+ options.extend(["-t", fstype, "-f", device])
+
+ command.extend(options)
+ command = ' '.join(command)
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -100,17 +117,19 @@ def mkfs(hostkey, device, fstype=None):
def find_mountpoints(hostkey, device):
"""
"""
+ logger = GlobalObj.getLoggerObj()
base_command = "mount | grep "
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH connection to host '%s' has not been established" % hostkey
+ logger.error("SSH connection to host '%s' has not been established"
+ % hostkey)
return 1
mountpoints = []
command = base_command + device
- print "%s : %s" % (hostkey, command)
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(command)
if not output["exitstatus"]:
for data in output["stdoutdata"]:
@@ -121,14 +140,16 @@ def find_mountpoints(hostkey, device):
def execute_command(hostkey, command, commandInput=None):
"""
"""
+ logger = GlobalObj.getLoggerObj()
cm = GlobalObj.getConnectionsManagerObj()
host_connection = cm.getConnection(hostkey)
if not host_connection:
- print "SSH Connection Not established to host '%s' " % hostkey
+ logger.error("SSH Connection Not established to host '%s' "
+ % hostkey)
return 1
new_command = _substitute_value_for_variables(hostkey, command)
- print "%s : %s" % (hostkey, command)
+ logger.debug('%s: Executing Command: %s' % (hostkey, command))
output = host_connection.executecommand(new_command, commandInput)
return_status = atfutils.assert_success(**output)
atfutils.print_stdout(output['stdoutdata'])
@@ -139,6 +160,7 @@ def execute_command(hostkey, command, commandInput=None):
def _substitute_value_for_variables(hostkey, command):
"""
"""
+ logger = GlobalObj.getLoggerObj()
pattern_for_variables = re.compile("<[a-z]+\d*>")
pattern_for_hosts = re.compile('(server|client|master)*')
variables_to_replace = []
@@ -166,7 +188,7 @@ def _substitute_value_for_variables(hostkey, command):
host = function(hostkey)
if not host:
- print "No Host to execute the command\n"
+ logger.error("No Host to execute the command\n")
return 1
for variable in variables:
diff --git a/libs/utils/managerutils.py b/libs/utils/managerutils.py
index ca38b3f..6f72e99 100644
--- a/libs/utils/managerutils.py
+++ b/libs/utils/managerutils.py
@@ -13,13 +13,19 @@ from atfglobals import GlobalObj
def ssh_connect(hostkey):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
+ if cm is None:
+ logger.error("Init ConnectionsManager")
+ return 1
+
host_connection = cm.getConnection(hostkey)
if not host_connection:
host_obj = env.getHost(hostkey)
if not host_obj:
- print "Invalid Host. %s is not defined in TestEnvironment" % hostkey
+ logger.error("Invalid Host. %s is not defined in TestEnvironment"
+ % hostkey)
return 1
else:
host_connection = ssh.SshConnection()
@@ -33,13 +39,14 @@ def ssh_connect(hostkey):
cm.addClient(hostkey, host_connection)
return 0
else:
- print "Connection to %s already exist" % hostkey
+ logger.debug("Connection to %s already exist" % hostkey)
return 0
def ssh_connect_allhosts():
"""
"""
+ GlobalObj.initConnectionsManagerObj()
env = GlobalObj.getTestenvObj()
cm = GlobalObj.getConnectionsManagerObj()
hosts_keys = env.getHostsKeys()
diff --git a/libs/utils/serverutils.py b/libs/utils/serverutils.py
index 618ee23..78e48b8 100644
--- a/libs/utils/serverutils.py
+++ b/libs/utils/serverutils.py
@@ -7,17 +7,20 @@ from atfglobals import GlobalObj
def execute_on_brick(brickkey, command, commandInput=None):
"""
"""
+ logger = GlobalObj.getLoggerObj()
env = GlobalObj.getTestenvObj()
raw_brick_obj = env.getRawBrick(brickkey)
if not raw_brick_obj:
- print "InValid Brick. %s not defined in TestEnvironment" % brickkey
+ logger.error("InValid Brick. %s not defined in TestEnvironment"
+ % brickkey)
return 1
serverkey = re.split("\.", raw_brick_obj.hostname, maxsplit=1)[0]
brick_obj = env.getBrick(brickkey)
if not brick_obj:
- print "InValid Brick. %s not defined in TestEnvironment" % brickkey
+ logger.error("InValid Brick. %s not defined in TestEnvironment"
+ % brickkey)
return 1
exportdirpath = brick_obj.path
diff --git a/testruninfo.cfg b/testruninfo.cfg
index ed65461..afaafe9 100755
--- a/testruninfo.cfg
+++ b/testruninfo.cfg
@@ -31,55 +31,8 @@ keywords =
## unit4 = Stripe
#############################################################################
[TestUnits]
-unit1 = replicate/self_heal
+unit1 = xlators/cluster/afr/self_heal/
-#############################################################################
-## Section: [ATFDir]
-## atfdir = absolute path of the directory where Automation Framework
-## is Installed
-## Example:
-## dir = /ATF
-## dir = /home/qa/ATF
-#############################################################################
-[ATFDir]
-dir = /home/shwetha/PythonCustomLibs/ATF
-
-#############################################################################
-## Section: [SummaryLog]
-## filename = FileName to Log SummaryLogs
-## loglevel = LogLevel could be debug| info | warning | error
-## Example:
-## filename = SummaryLog.out
-## loglevel = info
-#############################################################################
-[SummaryLog]
-filename =
-loglevel =
-
-#############################################################################
-## Section: [DetailLog]
-## filename = FileName to Log DetailLogs of test case execution
-## loglevel = LogLevel could be debug| info | warning | error
-## Example:
-## filename = DetailLog.out
-## loglevel = info
-#############################################################################
-[DetailLog]
-filename =
-loglevel =
-
-#############################################################################
-## Section: [StdoutLog]
-## do_log = true | false.
-## If do_log = true, Log to STDOUT. Else, do not log to STDOUT.
-## loglevel = LogLevel could be debug| info | warning | error
-## Example:
-## do_log = true
-## loglevel = info
-#############################################################################
-[StdoutLog]
-do_log =
-loglevel =
#############################################################################
## Section: [GlusterVersion]