You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by se...@apache.org on 2013/06/20 18:58:11 UTC

git commit: updated refs/heads/master to cd221fc

Updated Branches:
  refs/heads/master fa5808080 -> cd221fc33


marvinPlugin.py cleansed


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cd221fc3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cd221fc3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cd221fc3

Branch: refs/heads/master
Commit: cd221fc33e755abdc7ecb2b31c98d6f2aa081560
Parents: fa58080
Author: Daan Hoogland <dh...@schubergphilis.com>
Authored: Thu Jun 20 16:47:04 2013 +0200
Committer: Sebastien Goasguen <ru...@gmail.com>
Committed: Thu Jun 20 12:57:58 2013 -0400

----------------------------------------------------------------------
 tools/marvin/marvin/marvinPlugin.py | 71 +++++++++++++++++++-------------
 1 file changed, 43 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd221fc3/tools/marvin/marvin/marvinPlugin.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py
index 846f735..5014a2c 100644
--- a/tools/marvin/marvin/marvinPlugin.py
+++ b/tools/marvin/marvin/marvinPlugin.py
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,34 +24,37 @@ from marvin import deployDataCenter
 from nose.plugins.base import Plugin
 from functools import partial
 
+
 def testCaseLogger(message, logger=None):
     if logger is not None:
         logger.debug(message)
-       
+
+
 class MarvinPlugin(Plugin):
     """
     Custom plugin for the cloudstackTestCases to be run using nose
     """
-    
+
     name = "marvin"
 
     def configure(self, options, config):
-        if hasattr(options,self.enableOpt):
+        if hasattr(options, self.enableOpt):
             if not getattr(options, self.enableOpt):
                 self.enabled = False
                 return
             else:
                 self.enabled = True
 
-        self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
+        self.logformat = logging.Formatter("%(asctime)s - %(levelname)s - " +
+                                           "%(name)s - %(message)s")
 
         if options.debug_log:
             self.logger = logging.getLogger("NoseTestExecuteEngine")
-            self.debug_stream = logging.FileHandler(options.debug_log) 
+            self.debug_stream = logging.FileHandler(options.debug_log)
             self.debug_stream.setFormatter(self.logformat)
             self.logger.addHandler(self.debug_stream)
             self.logger.setLevel(logging.DEBUG)
-            
+
         if options.result_log:
             ch = logging.StreamHandler()
             ch.setLevel(logging.ERROR)
@@ -60,17 +63,19 @@ class MarvinPlugin(Plugin):
             self.result_stream = open(options.result_log, "w")
         else:
             self.result_stream = sys.stdout
-    
-        deploy = deployDataCenter.deployDataCenters(options.config) 
+
+        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
         cfg.debugLog = self.debug_stream
-        
-        self.testrunner = nose.core.TextTestRunner(stream=self.result_stream, descriptions=True, verbosity=2, config=config)
+
+        self.testrunner = nose.core.TextTestRunner(stream=self.result_stream,
+                                                   descriptions=True,
+                                                   verbosity=2, config=config)
 
     def options(self, parser, env):
         """
@@ -79,34 +84,39 @@ class MarvinPlugin(Plugin):
         parser.add_option("--marvin-config", action="store",
                           default=env.get('MARVIN_CONFIG', './datacenter.cfg'),
                           dest="config",
-                          help="Marvin's configuration file where the datacenter information is specified [MARVIN_CONFIG]")
+                          help="Marvin's configuration file where the " +
+                               "datacenter information is specified " +
+                               "[MARVIN_CONFIG]")
         parser.add_option("--result-log", action="store",
                           default=env.get('RESULT_LOG', None),
                           dest="result_log",
-                          help="The path to the results file where test summary will be written to [RESULT_LOG]")
+                          help="The path to the results file where test " +
+                               "summary will be written to [RESULT_LOG]")
         parser.add_option("--client-log", action="store",
                           default=env.get('DEBUG_LOG', 'debug.log'),
                           dest="debug_log",
-                          help="The path to the testcase debug logs [DEBUG_LOG]")
-        parser.add_option("--load", action="store_true", default=False, dest="load",
+                          help="The path to the testcase debug logs " +
+                          "[DEBUG_LOG]")
+        parser.add_option("--load", action="store_true", default=False,
+                          dest="load",
                           help="Only load the deployment configuration given")
 
         Plugin.options(self, parser, env)
- 
+
     def __init__(self):
         Plugin.__init__(self)
-        
+
     def prepareTestRunner(self, runner):
         return self.testrunner
-    
+
     def wantClass(self, cls):
         if issubclass(cls, cloudstackTestCase):
             return True
         return None
-    
+
     def loadTestsFromTestCase(self, cls):
         self._injectClients(cls)
-        
+
     def setClient(self, client):
         if client is not None:
             self.testclient = client
@@ -116,15 +126,20 @@ class MarvinPlugin(Plugin):
             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"))
+        testcaselogger = logging.getLogger("testclient.testcase.%s" %
+                                           test.__name__)
+        self.debug_stream. \
+            setFormatter(logging.
+                         Formatter("%(asctime)s - %(levelname)s - %(name)s" +
+                                   " - %(message)s"))
         testcaselogger.addHandler(self.debug_stream)
         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, "user"): #when the class-level attr applied. all test runs as 'user'
-            self.testclient.createUserApiClient(test.UserName, test.DomainName, test.AcctType)
-            
+        if hasattr(test, "user"):
+            # when the class-level attr applied. all test runs as 'user'
+            self.testclient.createUserApiClient(test.UserName, test.DomainName,
+                                                test.AcctType)