Summary: provide deployment config access to marvin's testcase

Detail:
Sometimes tests need ssh access to the management server to perform
verification such as:

1. Pings from mgmt_server to agents
2. snapshots exist on secondary storage - mountable from mgmt server

For these the tests will need access to the config of the deployment and
the ip address of the mgmt server.

Egs: integration/component/test_egress.py and integration/component/test_snapshots.py

BUG-ID : CLOUDSTACK-377
Reported-by: Prasanna Santhanam
Signed-off-by: Prasanna Santhanam <tsp@apache.org> 1350624903 +0530
This commit is contained in:
Prasanna Santhanam 2012-10-19 11:05:03 +05:30
parent a3c9a2b22d
commit 7460b01893
11 changed files with 41 additions and 6 deletions

View File

@ -27,13 +27,14 @@ def testCaseLogger(message, logger=None):
logger.debug(message)
class TestCaseExecuteEngine(object):
def __init__(self, testclient, testcaseLogFile=None, testResultLogFile=None, format="text", xmlDir="xml-reports"):
def __init__(self, testclient, config, testcaseLogFile=None, testResultLogFile=None, format="text", xmlDir="xml-reports"):
"""
Initialize the testcase execution engine, just the basics here
@var testcaseLogFile: client log file
@var testResultLogFile: summary report file
"""
self.testclient = testclient
self.config = config
self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
self.loader = unittest.loader.TestLoader()
self.suite = None
@ -83,6 +84,7 @@ class TestCaseExecuteEngine(object):
#inject testclient and logger into each unittest
setattr(test, "testClient", self.testclient)
setattr(test, "config", self.config)
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
setattr(test.__class__, "clstestclient", self.testclient)
if hasattr(test, "UserName"):

View File

@ -46,21 +46,30 @@ if __name__ == "__main__":
else:
deploy.deploy()
format = "text"
fmt = "text"
xmlDir = None
if options.xmlrunner is not None:
xmlDir = options.xmlrunner
format = "xml"
fmt = "xml"
if options.testCaseFolder is None:
if options.module is None:
parser.print_usage()
exit(1)
else:
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format, xmlDir)
engine = \
TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient,
deploy.getCfg(),
testCaseLogFile,
testResultLogFile, fmt,
xmlDir)
engine.loadTestsFromFile(options.module)
engine.run()
else:
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient, testCaseLogFile, testResultLogFile, format, xmlDir)
engine = TestCaseExecuteEngine.TestCaseExecuteEngine(deploy.testClient,
deploy.getCfg(),
testCaseLogFile,
testResultLogFile,
fmt, xmlDir)
engine.loadTestsFromDir(options.testCaseFolder)
engine.run()

View File

@ -349,6 +349,11 @@ class deployDataCenters():
self.config.mgtSvr[0].securityKey = securityKey
return apiKey, securityKey
def getCfg(self):
if self.config:
return self.config
return None
def loadCfg(self):
try:
self.config = configGenerator.get_setup_config(self.configFile)

View File

@ -58,6 +58,7 @@ class MarvinPlugin(Plugin):
deploy = deployDataCenter.deployDataCenters(options.config)
deploy.loadCfg() if options.load else deploy.deploy()
self.setClient(deploy.testClient)
self.setConfig(deploy.getCfg())
cfg = nose.config.Config()
cfg.logStream = self.result_stream
@ -104,6 +105,10 @@ class MarvinPlugin(Plugin):
if client:
self.testclient = client
def setConfig(self, config):
if config:
self.config = config
def _injectClients(self, test):
testcaselogger = logging.getLogger("testclient.testcase.%s" % test.__name__)
self.debug_stream.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s"))
@ -111,6 +116,7 @@ class MarvinPlugin(Plugin):
testcaselogger.setLevel(logging.DEBUG)
setattr(test, "testClient", self.testclient)
setattr(test, "config", self.config)
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
setattr(test, "clstestclient", self.testclient)
if hasattr(test, "UserName"):

View File

@ -101,6 +101,8 @@ def describeResources(config):
'''Add mgt server'''
mgt = managementServer()
mgt.mgtSvrIp = config.get('environment', 'mshost')
mgt.user = config.get('environment', 'mshost.user')
mgt.passwd = config.get('environment', 'mshost.passwd')
zs.mgtSvr.append(mgt)
'''Add a database'''

View File

@ -36,6 +36,8 @@ secstorage.allowed.internal.sites=10.147.28.0/24
[environment]
dns=10.147.28.6
mshost=10.147.29.111
mshost.user=root
mshost.passwd=password
mysql.host=10.147.29.111
mysql.cloud.user=cloud
mysql.cloud.passwd=cloud

View File

@ -102,6 +102,8 @@ def describeResources(config):
'''Add mgt server'''
mgt = managementServer()
mgt.mgtSvrIp = config.get('environment', 'mshost')
mgt.user = config.get('environment', 'mshost.user')
mgt.passwd = config.get('environment', 'mshost.passwd')
zs.mgtSvr.append(mgt)
'''Add a database'''

View File

@ -36,6 +36,8 @@ secstorage.allowed.internal.sites=10.147.28.0/24
[environment]
dns=10.147.28.6
mshost=10.147.39.69
mshost.user=root
mshost.passwd=password
mysql.host=10.147.39.69
mysql.cloud.user=cloud
mysql.cloud.passwd=cloud

View File

@ -16,7 +16,6 @@
# under the License.
{
"zones": [
{
@ -193,6 +192,8 @@
"mgtSvr": [
{
"mgtSvrIp": "localhost",
"passwd": "password",
"user": "root",
"port": 8096
}
]

View File

@ -103,6 +103,8 @@ def describeResources(config):
'''Add mgt server'''
mgt = managementServer()
mgt.mgtSvrIp = config.get('environment', 'mshost')
mgt.user = config.get('environment', 'mshost.user')
mgt.passwd = config.get('environment', 'mshost.passwd')
zs.mgtSvr.append(mgt)
'''Add a database'''

View File

@ -37,6 +37,8 @@ secstorage.allowed.internal.sites=10.147.28.0/24
[environment]
dns=10.147.28.6
mshost=localhost
mshost.user=root
mshost.passwd=password
mysql.host=localhost
mysql.cloud.user=cloud
mysql.cloud.passwd=cloud