def __init__(self): self.__identifier = None self.__testClient = None self.__logFolderPath = None self.__parsedConfig = None ''' Contains Config File ''' self.__configFile = None ''' Signifies the Zone against which all tests will be Run ''' self.__zoneForTests = None ''' Signifies the flag whether to deploy the New DC or Not ''' self.__deployDcFlag = None self.conf = None self.__resultStream = stdout self.__testRunner = None self.__testResult = SUCCESS self.__startTime = None self.__testName = None self.__tcRunLogger = MarvinLog('marvin').getLogger() self.__testModName = '' self.__hypervisorType = None Plugin.__init__(self)
def setUpClass(cls): cls.logger = MarvinLog('test').getLogger() test_client = super(TestVpcVpn, cls).getClsTestClient() cls.apiclient = test_client.getApiClient() cls.services = Services().services cls.zone = get_zone(cls.apiclient, test_client.getZoneForTests()) cls.domain = get_domain(cls.apiclient) cls.compute_offering = ServiceOffering.create( cls.apiclient, cls.services["compute_offering"]) cls.account = Account.create(cls.apiclient, services=cls.services["account"]) cls.logger.debug("Successfully created account: %s, id: %s" % (cls.account.name, cls.account.id)) cls.hypervisor = test_client.getHypervisorInfo() cls._cleanup = [cls.account, cls.compute_offering] cls.template = get_template(cls.apiclient, cls.zone.id) cls.logger.debug("Retrieving default Network offering for VPCs") cls.network_offerings = NetworkOffering.list( cls.apiclient, name="DefaultIsolatedNetworkOfferingForVpcNetworks") if cls.network_offerings is None or len(cls.network_offerings) <= 0: raise Exception("No VPC based network offering") return
def __initLogging(self): ''' @Name : __initLogging @Desc : 1. Initializes the logging for marvin and so provides various log features for automation run. 2. Initializes all logs to be available under given Folder Path,where all test run logs are available for a given run. 3. All logging like exception log,results, run info etc for a given test run are available under a given timestamped folder @Output : SUCCESS or FAILED ''' try: log_obj = MarvinLog("CSLog") if log_obj: ret = log_obj.\ createLogs(self.__testModName, self.__parsedConfig.logger, self.__userLogFolderPath) if ret != FAILED: self.__logFolderPath = log_obj.getLogFolderPath() self.__tcRunLogger = log_obj.getLogger() print "\n=== Marvin Init Logging Successful===" return SUCCESS return FAILED except Exception as e: print "\n Exception Occurred Under __initLogging " \ ":%s" % GetDetailExceptionInfo(e) return FAILED
def setUp(self): self.logger = MarvinLog('test').getLogger() self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.cleanup = [] self.services = self.testClient.getParsedTestDataConfig() self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.services["sleep"] = 2 self.services["timeout"] = 240 # Default value is 120 seconds. That's just too much. self.services["configurableData"]["systemVmDelay"] = 60 return
def __initLogging(self): try: ''' @Desc : 1. Initializes the logging for marvin and so provides various log features for automation run. 2. Initializes all logs to be available under given Folder Path,where all test run logs are available for a given run. 3. All logging like exception log,results, run info etc for a given test run are available under a given timestamped folder ''' temp_path = "".join(str(time.time()).split(".")) if self.__logFolderPath is None: log_config = self.__parsedConfig.logger if log_config is not None: if log_config.LogFolderPath is not None: self.logFolderPath = log_config.LogFolderPath + '/' \ + temp_path else: self.logFolderPath = temp_path else: self.logFolderPath = temp_path else: self.logFolderPath = self.__logFolderPath + '/' + temp_path if os.path.exists(self.logFolderPath): self.logFolderPath += ''.join( random.choice(string.ascii_uppercase + string.digits for x in range(3))) os.makedirs(self.logFolderPath) ''' Log File Paths ''' tc_failed_exceptionlog = self.logFolderPath + "/failed_" \ "plus_" \ "exceptions.txt" tc_run_log = self.logFolderPath + "/runinfo.txt" self.__tcRunDebugFile = open(self.logFolderPath + "/results.txt", "w") log_obj = MarvinLog("CSLog") self.__tcRunLogger = log_obj.setLogHandler(tc_run_log) log_obj.setLogHandler(tc_failed_exceptionlog, log_level=logging.FATAL) return SUCCESS except Exception, e: print "\n Exception Occurred Under __initLogging :%s" % str(e) return None
def __init__(self, config_file, deploy_dc_flag=False, test_mod_name="deploydc", zone=None, hypervisor_type=None): self.__configFile = config_file self.__deployFlag = deploy_dc_flag self.__tcRunLogger = MarvinLog('marvin').getLogger() self.__tcRunLogger.info("=== Marvin Init Logging Successful ===") self.__testModName = test_mod_name self.__testClient = None self.__tcResultFile = None self.__testDataFilePath = None self.__zoneForTests = zone self.__parsedConfig = None self.__hypervisorType = hypervisor_type
where the json config file generated") (options, args) = parser.parse_args() if options.input is None: print "\n==== For cleaning: Please Specify a " \ "Valid Input Configuration File ====" exit(1) if (options.input) and not (os.path.isfile(options.input)): print "\n=== Invalid Input Config File Path, Please Check ===" exit(1) from marvin.marvinLog import MarvinLog from marvin.cloudstackTestClient import CSTestClient log_obj = MarvinLog("CSLogClean") cfg = configGenerator.getSetupConfig(options.input) log = cfg.logger ret = log_obj.createLogs("Clean_Infra", log) if ret != FAILED: log_folder_path = log_obj.getLogFolderPath() tc_run_logger = log_obj.getLogger() else: print "\n=== Log Creation Failed. Please Check ===" exit(1) obj_tc_client = CSTestClient(cfg.mgtSvr[0], cfg.dbSvr, logger=tc_run_logger) if obj_tc_client and obj_tc_client.createTestClient() == FAILED: print "\n=== TestClient Creation Failed ===" exit(1)
''' if options.input is None and options.remove is None: print "\n==== For DeployDataCenter: Please Specify a " \ "Valid Input Configuration File====" print "\n==== For DeleteDataCenters: Please Specify a " \ "Valid Input Configuration File and DC Settings====" exit(1) ''' Imports the Modules Required ''' from marvin.marvinLog import MarvinLog from marvin.cloudstackTestClient import CSTestClient ''' Step1: Create the Logger ''' log_obj = MarvinLog("CSLog") cfg = configGenerator.getSetupConfig(options.input) log = cfg.logger ret = log_obj.createLogs("DeployDataCenter", log) if ret != FAILED: log_folder_path = log_obj.getLogFolderPath() tc_run_logger = log_obj.getLogger() else: print "\n===Log Creation Failed. Please Check===" exit(1) ''' Step2 : Create Test Client ''' obj_tc_client = CSTestClient(cfg.mgtSvr[0], cfg.dbSvr,
"Valid Input Configuration File ====" exit(1) if (options.upload_iso is None) and (options.upload_tmpl is None): print "\n==== For uploading file: Please Specify a " \ "HTTP path for file ====" exit(1) if (options.input) and not (os.path.isfile(options.input)): print "\n=== Invalid Input Config File Path, Please Check ===" exit(1) from marvin.marvinLog import MarvinLog from marvin.cloudstackTestClient import CSTestClient log_obj = MarvinLog("CSLogTemplates") cfg = configGenerator.getSetupConfig(options.input) log = cfg.logger ret = log_obj.createLogs("UploadTemplates", log) if ret != FAILED: log_folder_path = log_obj.getLogFolderPath() tc_run_logger = log_obj.getLogger() else: print "\n=== Log Creation Failed. Please Check ===" exit(1) obj_tc_client = CSTestClient(cfg.mgtSvr[0], cfg.dbSvr, logger=tc_run_logger) if obj_tc_client and obj_tc_client.createTestClient() == FAILED: print "\n=== TestClient Creation Failed ==="
def test_create_marvin_log_with_name(self): name = 'test-log' marvin_log = MarvinLog(name) self.assertIsNotNone(marvin_log) self.assertEquals(name, marvin_log.getLogger().name)
def test_create_marvin_log_with_default_name(self): marvin_log = MarvinLog() self.assertIsNotNone(marvin_log) self.assertEquals('marvin.marvinLog', marvin_log.getLogger().name)