Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D3E53CFAD for ; Mon, 30 Jul 2012 10:07:20 +0000 (UTC) Received: (qmail 25286 invoked by uid 500); 30 Jul 2012 10:07:20 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 25116 invoked by uid 500); 30 Jul 2012 10:07:20 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 24973 invoked by uid 99); 30 Jul 2012 10:07:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jul 2012 10:07:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 708061AF41; Mon, 30 Jul 2012 10:07:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tsp@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [4/16] git commit: Support added for attrib, multiprocess and Xunit coverage plugins Message-Id: <20120730100719.708061AF41@tyr.zones.apache.org> Date: Mon, 30 Jul 2012 10:07:19 +0000 (UTC) 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/master Commit: 0ab7a9289f52acc3f25f92984c9508684c1321fd Parents: 84b69e6 Author: Prasanna Santhanam Authored: Fri Jul 20 17:26:42 2012 +0530 Committer: Prasanna Santhanam 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):