diff --git a/tools/marvin/marvin/TestCaseExecuteEngine.py b/tools/marvin/marvin/TestCaseExecuteEngine.py index 44a44aa141c..63e7d0de6aa 100644 --- a/tools/marvin/marvin/TestCaseExecuteEngine.py +++ b/tools/marvin/marvin/TestCaseExecuteEngine.py @@ -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"): diff --git a/tools/marvin/marvin/deployAndRun.py b/tools/marvin/marvin/deployAndRun.py index 1c82d9fcc2e..e7b005caf68 100644 --- a/tools/marvin/marvin/deployAndRun.py +++ b/tools/marvin/marvin/deployAndRun.py @@ -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() diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index 571d5a4ff72..f9d837fa2c0 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -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) diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index 0251e96a2bb..c15fa4d38e9 100644 --- a/tools/marvin/marvin/marvinPlugin.py +++ b/tools/marvin/marvin/marvinPlugin.py @@ -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"): diff --git a/tools/marvin/marvin/sandbox/advanced/advanced_env.py b/tools/marvin/marvin/sandbox/advanced/advanced_env.py index 136629fe944..1873f31d50f 100644 --- a/tools/marvin/marvin/sandbox/advanced/advanced_env.py +++ b/tools/marvin/marvin/sandbox/advanced/advanced_env.py @@ -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''' diff --git a/tools/marvin/marvin/sandbox/advanced/setup.properties b/tools/marvin/marvin/sandbox/advanced/setup.properties index 966d1f9a52c..ba44d5146b6 100644 --- a/tools/marvin/marvin/sandbox/advanced/setup.properties +++ b/tools/marvin/marvin/sandbox/advanced/setup.properties @@ -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 diff --git a/tools/marvin/marvin/sandbox/basic/basic_env.py b/tools/marvin/marvin/sandbox/basic/basic_env.py index 7c2a0b1d957..e588fdcc882 100644 --- a/tools/marvin/marvin/sandbox/basic/basic_env.py +++ b/tools/marvin/marvin/sandbox/basic/basic_env.py @@ -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''' diff --git a/tools/marvin/marvin/sandbox/basic/setup.properties b/tools/marvin/marvin/sandbox/basic/setup.properties index e9c0f4d70e3..8833b507252 100644 --- a/tools/marvin/marvin/sandbox/basic/setup.properties +++ b/tools/marvin/marvin/sandbox/basic/setup.properties @@ -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 diff --git a/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg b/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg index 7d250c84ec0..219c4dbbff5 100644 --- a/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg +++ b/tools/marvin/marvin/sandbox/demo/simulator/simulator.cfg @@ -16,7 +16,6 @@ # under the License. - { "zones": [ { @@ -193,6 +192,8 @@ "mgtSvr": [ { "mgtSvrIp": "localhost", + "passwd": "password", + "user": "root", "port": 8096 } ] diff --git a/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py b/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py index 2bd52f14345..0d341408aea 100644 --- a/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py +++ b/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py @@ -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''' diff --git a/tools/marvin/marvin/sandbox/demo/simulator/simulatordemo.properties b/tools/marvin/marvin/sandbox/demo/simulator/simulatordemo.properties index aa3deb0afa1..9d9f14b70a4 100644 --- a/tools/marvin/marvin/sandbox/demo/simulator/simulatordemo.properties +++ b/tools/marvin/marvin/sandbox/demo/simulator/simulatordemo.properties @@ -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