You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/31 22:40:03 UTC
[48/50] [abbrv] git commit: Support added for attrib,
multiprocess and Xunit coverage plugins
Support added for attrib, multiprocess and Xunit coverage plugins
Conflicts:
tools/marvin/marvin/NoseTestExecuteEngine.py
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/0ab7a928
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/0ab7a928
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/0ab7a928
Branch: refs/heads/vpc
Commit: 0ab7a9289f52acc3f25f92984c9508684c1321fd
Parents: 84b69e6
Author: Prasanna Santhanam <Pr...@citrix.com>
Authored: Fri Jul 20 17:26:42 2012 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Mon Jul 30 15:32:34 2012 +0530
----------------------------------------------------------------------
tools/marvin/marvin/NoseTestExecuteEngine.py | 75 +++++++-------------
tools/marvin/marvin/cloudstackTestCase.py | 2 +-
2 files changed, 27 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/0ab7a928/tools/marvin/marvin/NoseTestExecuteEngine.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/NoseTestExecuteEngine.py b/tools/marvin/marvin/NoseTestExecuteEngine.py
index 9499c90..25d5c93 100644
--- a/tools/marvin/marvin/NoseTestExecuteEngine.py
+++ b/tools/marvin/marvin/NoseTestExecuteEngine.py
@@ -24,52 +24,10 @@ import sys
import logging
import xmlrunner
from cloudstackTestCase import cloudstackTestCase
-
-def testCaseLogger(message, logger=None):
- if logger is not None:
- logger.debug(message)
-
-class NoseCloudStackTestLoader(nose.loader.TestLoader):
- """
- Custom test loader for the cloudstackTestCase to be loaded into nose
- """
-
- def loadTestsFromTestCase(self, testCaseClass):
- if issubclass(testCaseClass, cloudstackTestCase):
- testCaseNames = self.getTestCaseNames(testCaseClass)
- tests = []
- for testCaseName in testCaseNames:
- testCase = testCaseClass(testCaseName)
- self._injectClients(testCase)
- tests.append(testCase)
- return self.suiteClass(tests)
- else:
- return super(NoseCloudStackTestLoader, self).loadTestsFromTestCase(testCaseClass)
-
- def loadTestsFromName(self, name, module=None, discovered=False):
- return nose.loader.TestLoader.loadTestsFromName(self, name, module=module, discovered=discovered)
-
- def loadTestsFromNames(self, names, module=None):
- return nose.loader.TestLoader.loadTestsFromNames(self, names, module=module)
-
- def setClient(self, client):
- self.testclient = client
-
- def setClientLog(self, clientlog):
- self.log = clientlog
-
- def _injectClients(self, test):
- testcaselogger = logging.getLogger("testclient.testcase.%s"%test.__class__.__name__)
- fh = logging.FileHandler(self.log)
- fh.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s"))
- testcaselogger.addHandler(fh)
- testcaselogger.setLevel(logging.DEBUG)
-
- setattr(test, "testClient", self.testclient)
- setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger))
- setattr(test.__class__, "clstestclient", self.testclient)
- if hasattr(test, "UserName"):
- self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType)
+from marvinPlugin import MarvinPlugin
+from nose.plugins.xunit import Xunit
+from nose.plugins.attrib import AttributeSelector
+from nose.plugins.multiprocess import MultiProcessTestRunner
class NoseTestExecuteEngine(object):
"""
@@ -111,12 +69,31 @@ class NoseTestExecuteEngine(object):
else:
raise EnvironmentError("Need to give either a test directory or a test file")
+ plug_mgr = nose.plugins.manager.PluginManager()
+ plug_mgr.addPlugin(self.test_picker)
+ plug_mgr.addPlugin(Xunit())
+ plug_mgr.addPlugin(AttributeSelector())
+ plug_mgr.addPlugin(MultiProcessTestRunner())
+ self.cfg = nose.config.Config()
+ self.cfg.plugins = plug_mgr
+
if format == "text":
self.runner = nose.core.TextTestRunner(stream=self.testResultLogFile, descriptions=1, verbosity=2, config=None)
else:
self.runner = xmlrunner.XMLTestRunner(output='xml-reports', verbose=True)
def runTests(self):
- #nose.core.TestProgram(argv=["--process-timeout=3600"], testRunner=self.runner, testLoader=self.loader)
- nose.core.TestProgram(argv=["--process-timeout=3600"], \
- testRunner=self.runner, suite=self.suite)
+ options = ["--process-timeout=3600", "--with-xunit", "-a tags=advanced", "--processes=5"] #TODO: Add support for giving nose args
+ #DEBUG
+# options = ["--process-timeout=3600", "--with-xunit", "--collect-only"]
+ #DEBUG
+# options = ["--process-timeout=3600"]
+ options.append("-w%s" %self.workingdir)
+
+ if self.workingdir is not None:
+ nose.core.TestProgram(argv=options, testRunner=self.runner,
+ config=self.cfg)
+ elif self.filename is not None:
+ tests = self.loader.loadTestsFromFile(self.filename)
+ nose.core.TestProgram(argv=options, testRunner=self.runner,
+ config=self.cfg)
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/0ab7a928/tools/marvin/marvin/cloudstackTestCase.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py
index a85eef7..4ec764c 100644
--- a/tools/marvin/marvin/cloudstackTestCase.py
+++ b/tools/marvin/marvin/cloudstackTestCase.py
@@ -48,7 +48,7 @@ class cloudstackTestCase(unittest.case.TestCase):
def __init__(self, args):
unittest.case.TestCase.__init__(self, args)
- self.testClient = cloudstackTestClient.cloudstackTestClient()
+# self.testClient = cloudstackTestClient.cloudstackTestClient()
@classmethod
def getClsTestClient(cls):