mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
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:
parent
a3c9a2b22d
commit
7460b01893
@ -27,13 +27,14 @@ def testCaseLogger(message, logger=None):
|
|||||||
logger.debug(message)
|
logger.debug(message)
|
||||||
|
|
||||||
class TestCaseExecuteEngine(object):
|
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
|
Initialize the testcase execution engine, just the basics here
|
||||||
@var testcaseLogFile: client log file
|
@var testcaseLogFile: client log file
|
||||||
@var testResultLogFile: summary report file
|
@var testResultLogFile: summary report file
|
||||||
"""
|
"""
|
||||||
self.testclient = testclient
|
self.testclient = testclient
|
||||||
|
self.config = config
|
||||||
self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
|
self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
|
||||||
self.loader = unittest.loader.TestLoader()
|
self.loader = unittest.loader.TestLoader()
|
||||||
self.suite = None
|
self.suite = None
|
||||||
@ -83,6 +84,7 @@ class TestCaseExecuteEngine(object):
|
|||||||
|
|
||||||
#inject testclient and logger into each unittest
|
#inject testclient and logger into each unittest
|
||||||
setattr(test, "testClient", self.testclient)
|
setattr(test, "testClient", self.testclient)
|
||||||
|
setattr(test, "config", self.config)
|
||||||
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
|
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
|
||||||
setattr(test.__class__, "clstestclient", self.testclient)
|
setattr(test.__class__, "clstestclient", self.testclient)
|
||||||
if hasattr(test, "UserName"):
|
if hasattr(test, "UserName"):
|
||||||
|
|||||||
@ -46,21 +46,30 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
deploy.deploy()
|
deploy.deploy()
|
||||||
|
|
||||||
format = "text"
|
fmt = "text"
|
||||||
xmlDir = None
|
xmlDir = None
|
||||||
if options.xmlrunner is not None:
|
if options.xmlrunner is not None:
|
||||||
xmlDir = options.xmlrunner
|
xmlDir = options.xmlrunner
|
||||||
format = "xml"
|
fmt = "xml"
|
||||||
|
|
||||||
if options.testCaseFolder is None:
|
if options.testCaseFolder is None:
|
||||||
if options.module is None:
|
if options.module is None:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
exit(1)
|
exit(1)
|
||||||
else:
|
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.loadTestsFromFile(options.module)
|
||||||
engine.run()
|
engine.run()
|
||||||
else:
|
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.loadTestsFromDir(options.testCaseFolder)
|
||||||
engine.run()
|
engine.run()
|
||||||
|
|||||||
@ -349,6 +349,11 @@ class deployDataCenters():
|
|||||||
self.config.mgtSvr[0].securityKey = securityKey
|
self.config.mgtSvr[0].securityKey = securityKey
|
||||||
return apiKey, securityKey
|
return apiKey, securityKey
|
||||||
|
|
||||||
|
def getCfg(self):
|
||||||
|
if self.config:
|
||||||
|
return self.config
|
||||||
|
return None
|
||||||
|
|
||||||
def loadCfg(self):
|
def loadCfg(self):
|
||||||
try:
|
try:
|
||||||
self.config = configGenerator.get_setup_config(self.configFile)
|
self.config = configGenerator.get_setup_config(self.configFile)
|
||||||
|
|||||||
@ -58,6 +58,7 @@ class MarvinPlugin(Plugin):
|
|||||||
deploy = deployDataCenter.deployDataCenters(options.config)
|
deploy = deployDataCenter.deployDataCenters(options.config)
|
||||||
deploy.loadCfg() if options.load else deploy.deploy()
|
deploy.loadCfg() if options.load else deploy.deploy()
|
||||||
self.setClient(deploy.testClient)
|
self.setClient(deploy.testClient)
|
||||||
|
self.setConfig(deploy.getCfg())
|
||||||
|
|
||||||
cfg = nose.config.Config()
|
cfg = nose.config.Config()
|
||||||
cfg.logStream = self.result_stream
|
cfg.logStream = self.result_stream
|
||||||
@ -104,6 +105,10 @@ class MarvinPlugin(Plugin):
|
|||||||
if client:
|
if client:
|
||||||
self.testclient = client
|
self.testclient = client
|
||||||
|
|
||||||
|
def setConfig(self, config):
|
||||||
|
if config:
|
||||||
|
self.config = config
|
||||||
|
|
||||||
def _injectClients(self, test):
|
def _injectClients(self, test):
|
||||||
testcaselogger = logging.getLogger("testclient.testcase.%s" % test.__name__)
|
testcaselogger = logging.getLogger("testclient.testcase.%s" % test.__name__)
|
||||||
self.debug_stream.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s"))
|
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)
|
testcaselogger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
setattr(test, "testClient", self.testclient)
|
setattr(test, "testClient", self.testclient)
|
||||||
|
setattr(test, "config", self.config)
|
||||||
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
|
setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
|
||||||
setattr(test, "clstestclient", self.testclient)
|
setattr(test, "clstestclient", self.testclient)
|
||||||
if hasattr(test, "UserName"):
|
if hasattr(test, "UserName"):
|
||||||
|
|||||||
@ -101,6 +101,8 @@ def describeResources(config):
|
|||||||
'''Add mgt server'''
|
'''Add mgt server'''
|
||||||
mgt = managementServer()
|
mgt = managementServer()
|
||||||
mgt.mgtSvrIp = config.get('environment', 'mshost')
|
mgt.mgtSvrIp = config.get('environment', 'mshost')
|
||||||
|
mgt.user = config.get('environment', 'mshost.user')
|
||||||
|
mgt.passwd = config.get('environment', 'mshost.passwd')
|
||||||
zs.mgtSvr.append(mgt)
|
zs.mgtSvr.append(mgt)
|
||||||
|
|
||||||
'''Add a database'''
|
'''Add a database'''
|
||||||
|
|||||||
@ -36,6 +36,8 @@ secstorage.allowed.internal.sites=10.147.28.0/24
|
|||||||
[environment]
|
[environment]
|
||||||
dns=10.147.28.6
|
dns=10.147.28.6
|
||||||
mshost=10.147.29.111
|
mshost=10.147.29.111
|
||||||
|
mshost.user=root
|
||||||
|
mshost.passwd=password
|
||||||
mysql.host=10.147.29.111
|
mysql.host=10.147.29.111
|
||||||
mysql.cloud.user=cloud
|
mysql.cloud.user=cloud
|
||||||
mysql.cloud.passwd=cloud
|
mysql.cloud.passwd=cloud
|
||||||
|
|||||||
@ -102,6 +102,8 @@ def describeResources(config):
|
|||||||
'''Add mgt server'''
|
'''Add mgt server'''
|
||||||
mgt = managementServer()
|
mgt = managementServer()
|
||||||
mgt.mgtSvrIp = config.get('environment', 'mshost')
|
mgt.mgtSvrIp = config.get('environment', 'mshost')
|
||||||
|
mgt.user = config.get('environment', 'mshost.user')
|
||||||
|
mgt.passwd = config.get('environment', 'mshost.passwd')
|
||||||
zs.mgtSvr.append(mgt)
|
zs.mgtSvr.append(mgt)
|
||||||
|
|
||||||
'''Add a database'''
|
'''Add a database'''
|
||||||
|
|||||||
@ -36,6 +36,8 @@ secstorage.allowed.internal.sites=10.147.28.0/24
|
|||||||
[environment]
|
[environment]
|
||||||
dns=10.147.28.6
|
dns=10.147.28.6
|
||||||
mshost=10.147.39.69
|
mshost=10.147.39.69
|
||||||
|
mshost.user=root
|
||||||
|
mshost.passwd=password
|
||||||
mysql.host=10.147.39.69
|
mysql.host=10.147.39.69
|
||||||
mysql.cloud.user=cloud
|
mysql.cloud.user=cloud
|
||||||
mysql.cloud.passwd=cloud
|
mysql.cloud.passwd=cloud
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"zones": [
|
"zones": [
|
||||||
{
|
{
|
||||||
@ -193,6 +192,8 @@
|
|||||||
"mgtSvr": [
|
"mgtSvr": [
|
||||||
{
|
{
|
||||||
"mgtSvrIp": "localhost",
|
"mgtSvrIp": "localhost",
|
||||||
|
"passwd": "password",
|
||||||
|
"user": "root",
|
||||||
"port": 8096
|
"port": 8096
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -103,6 +103,8 @@ def describeResources(config):
|
|||||||
'''Add mgt server'''
|
'''Add mgt server'''
|
||||||
mgt = managementServer()
|
mgt = managementServer()
|
||||||
mgt.mgtSvrIp = config.get('environment', 'mshost')
|
mgt.mgtSvrIp = config.get('environment', 'mshost')
|
||||||
|
mgt.user = config.get('environment', 'mshost.user')
|
||||||
|
mgt.passwd = config.get('environment', 'mshost.passwd')
|
||||||
zs.mgtSvr.append(mgt)
|
zs.mgtSvr.append(mgt)
|
||||||
|
|
||||||
'''Add a database'''
|
'''Add a database'''
|
||||||
|
|||||||
@ -37,6 +37,8 @@ secstorage.allowed.internal.sites=10.147.28.0/24
|
|||||||
[environment]
|
[environment]
|
||||||
dns=10.147.28.6
|
dns=10.147.28.6
|
||||||
mshost=localhost
|
mshost=localhost
|
||||||
|
mshost.user=root
|
||||||
|
mshost.passwd=password
|
||||||
mysql.host=localhost
|
mysql.host=localhost
|
||||||
mysql.cloud.user=cloud
|
mysql.cloud.user=cloud
|
||||||
mysql.cloud.passwd=cloud
|
mysql.cloud.passwd=cloud
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user