def test_11_startWorkflow(self): rootLogger.info("start workflow without wait") res = startWorkflow(self.domain.name, self.dis_name, self.application, self.workflow_name) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) rootLogger.warning(res.stderr)
def test_40_listActiveWorkflowInstances(self): res = listActiveWorkflowInstances(self.domain.name, self.dis_name) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) activeWkfInst = res.stdout for wkfInst in activeWkfInst: rootLogger.info(wkfInst)
def test_1_listMappings(self): res = listMappings(DomainName=self.domain.name, ServiceName=self.DIS_SERVICE, Application=self.APPLICATION) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) return res.stdout
def test_2_startApplication(self): # res = startApplication( =self.domain.name, servicename=self.dis_name, # application=self.application) res = startApplication(ServiceName=self.dis_name, Application=self.application, DomainName=self.domain.name) rootLogger.info(res)
def test_10_startWorkflow(self): self.skipTest("it will last a long time") rootLogger.info("start workflow with wait") res = startWorkflow(self.domain.name, self.dis_name, self.application, self.workflow_name, True) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) rootLogger.warning(res.stderr)
def test_4_get_envs(self): # self.skipTest("test it later") all_envs = self.infa_env.get_envs(self.current_node.id) debugLogger.info("the db is {0} \n".format(all_envs)) debugLogger.info("existing is {0}".format(self.now_all_envs)) self.assertEqual(len(all_envs), len(self.now_all_envs), "the number of envs is not equaled")
def test_3_getMappingStatus(self): mapping_status = self.test_2_runMapping() if mapping_status is not None: res = getMappingStatus(DomainName=self.domain.name, ServiceName=mapping_status.ServiceName, JobId=mapping_status.JobId) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr)
def test_showLicense(self): licensesResult = listLicenses() if licensesResult.retcode == 0: licenses = licensesResult.stdout rootLogger.info(licenses) for license in licenses: licenseInfo = showLicense(LicenseName=license.Name) rootLogger.info(licenseInfo)
def test_backupContents(self): servicesResult = listServices(ServiceType=servicetype_namedtuple.Model_Repository_Service) self.assertEqual(servicesResult.retcode, 0, servicesResult.stderr) services = servicesResult.stdout for service in services: outputfilename = datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%s") res = backupContents(ServiceName=service, OutputFileName=outputfilename) rootLogger.info(res)
def test_resetPassword(self): username = "******" password = "******" res = resetPassword(ResetUserName=username, ResetUserPassword=password) self.assertEqual(res.retcode, 0, res.stderr) username = "******" res = resetPassword(ResetUserName=username, ResetUserPassword=password) self.assertNotEqual(res.retcode, 0, res.stderr) rootLogger.info(res)
def test_4_getRequestLog(self): mapping_info = self.test_2_runMapping() if mapping_info is not None: logFileName = "/tmp/{0}.log".format(mapping_info.JobId) res = getRequestLog(DomainName=self.domain.name, ServiceName=mapping_info.ServiceName, RequestId=mapping_info.JobId, FileName=logFileName) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr)
def test_listGroupsForUser(self): usersResult = listAllUsers() self.assertEqual(usersResult.retcode, 0, usersResult.stderr) users = usersResult.stdout for user in users: # type: dict groupsForUser = listGroupsForUser( ExistingUserName=user.get("userName"), ExistingUserSecurityDomain=user.get("securityDomain")) rootLogger.info(groupsForUser)
def test_1_listApplications(self): res = listApplications(domainname=self.domain.name, servicename=self.dis_name) rootLogger.info(res) rootLogger.warning(res.stderr) self.applications = res.stdout self.assertEqual( res.retcode, 0, "the listApplications command executed with failure: {0}".format( res.stderr))
def test_ping(self): services = listServices( DomainName=self.domain.name, ServiceType=servicetype_namedtuple.Data_Integration_Service) self.assertEqual(services.retcode, 0, services.stderr) if services.retcode == 0: stdout = services.stdout for s in stdout: res = ping(ServiceName=s, DomainName=self.domain.name) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr)
def test_3_listApplicationObjects(self): res = listApplicationObjects(self.dis_name, self.application, domainname=self.domain.name, listobjecttype=True) rootLogger.info(res) objects = res.stdout if isinstance(objects, list): for obj in objects: rootLogger.info(obj)
def test_listNodeResources(self): nodeResult = listNodes() self.assertEqual(nodeResult.retcode, 0, nodeResult.stderr) nodes = nodeResult.stdout for node in nodes: rootLogger.info("######################\t{0}".format(node)) res = listNodeResources(NodeName=node) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) print() pprint(res.stdout)
def test_listConnectionOptions(self): allConnectionsResult = listConnections() if allConnectionsResult.retcode == 0: allConnections = allConnectionsResult.stdout # type: dict for k, v in allConnections.items(): if len(v) > 0: print(v) for conn in v: res = listConnectionOptions( ConnectionName=conn.get("name")) rootLogger.info(res) pprint(res.stdout)
def test_listServices(self): res = listServices( DomainName=self.domain.name, ServiceType=servicetype_namedtuple.Model_Repository_Service) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) res = listServices(DomainName=self.domain.name) rootLogger.info(res) return res.stdout
def test_5_backupApplication(self): stopA = stopApplication(ServiceName=self.dis_name, Application=self.application) self.assertEqual(stopA.retcode, 0, stopA.stderr) res = backupApplication(ServiceName=self.dis_name, Application=self.application, FileName="{0}.xml".format(self.application)) self.assertEqual(res.retcode, 0, res.stderr) startA = startApplication(ServiceName=self.dis_name, Application=self.application) self.assertEqual(startA.retcode, 0, startA.stderr) rootLogger.info(res.stdout)
def test_listUserPermissions(self): usersResult = listAllUsers() self.assertEqual(usersResult.retcode, 0, usersResult.stderr) for userDict in usersResult.stdout: # type: dict userPermissionsResult = listUserPermissions( ExistingUserName=userDict.get("userName"), ExistingUserSecurityDomain=userDict.get("securityDomain")) rootLogger.info(userPermissionsResult) self.assertEqual(userPermissionsResult.retcode, 0, userPermissionsResult.stderr) pprint(userPermissionsResult.stdout) self.assertTrue( isinstance(userPermissionsResult.stdout, dict), "The result of listUserPermissions shoudl be dict ")
def test_enableService(self): servicesResult = listServices( ServiceType=servicetype_namedtuple.PowerCenter_Integration_Service) self.assertEqual(servicesResult.retcode, 0, servicesResult.stderr) for service in servicesResult.stdout: # type: str statusResult = getServiceStatus(ServiceName=service) rootLogger.info(statusResult) self.assertEqual(statusResult.retcode, 0, statusResult.stderr) if not statusResult.stdout: res = enableService(ServiceName=service) else: res = disableService(ServiceName=service) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr)
def test_listMappingParams(self): mappingsResult = listMappings(ServiceName=self.DIS_SERVICE, Application=self.APPLICATION) self.assertEqual(mappingsResult.retcode, 0, mappingsResult.stdout) if len(mappingsResult.stdout) < 0: self.fail("There's no mapping under the application {0}".format( self.APPLICATION)) for mapping in mappingsResult.stdout: res = listMappingParams(ServiceName=self.DIS_SERVICE, Application=self.APPLICATION, Mapping=mapping) # self.assertEqual(res.retcode, 0, res.stdout) rootLogger.info("###### {0}".format(res)) print("###" * 20) print() pprint(res.stdout) print("###" * 20) print(res.stdout)
def test_2_runMapping(self): mappingsResult = listMappings(DomainName=self.domain.name, ServiceName=self.DIS_SERVICE, Application=self.APPLICATION) self.assertEqual(mappingsResult.retcode, 0, mappingsResult.stderr) mappings = mappingsResult.stdout if mappings is not None and len(mappings) != 0: res = runMapping(DomainName=self.domain.name, ServiceName=self.DIS_SERVICE, Application=self.APPLICATION, Mapping=mappings[0]) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) return res.stdout else: rootLogger.warning("no mapping in the application {0}".format( self.APPLICATION)) self.fail("no mapping in the application {0}".format( self.APPLICATION))
def test_4_stopBlazeService(self): servicesResult = listServices( ServiceType=servicetype_namedtuple.Data_Integration_Service) self.assertEqual(servicesResult.retcode, 0, servicesResult.stderr) connectionsResult = listConnections( ConnectionType=connectiontype_namedtupe.HADOOP) self.assertEqual(connectionsResult.retcode, 0, connectionsResult.stderr) services = servicesResult.stdout connections = connectionsResult.stdout.get( connectiontype_namedtupe.HADOOP) rootLogger.info("########## {0}".format(connections)) for service in services: for connDict in connections: # type: dict k, v = connDict.popitem() res = stopBlazeService(ServiceName=service, HadoopConnection=v) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr)
def test_10_backup_domain(self): res = backupDomain(domainname=self.domain.name, databasetype=self.domain.db_type, databaseaddress="{0}:{1}".format(self.domain.db_host.rstrip(), self.domain.db_port), databaseusername=self.domain.db_username, databaseservicename=self.domain.db_service_name, backupfile=None, force=False, tablespace=self.domain.db_tablespace, schemaname=self.domain.db_schema, databasetlsenabled=self.domain.db_tls_enabled, databasetruststorepassword=self.domain.db_truststorepassword, trustedconnection=self.domain.db_trustedconnection, encryptionkeylocation=self.node.sc_secretkeysdirectory, databasetruststorelocation=self.domain.db_truststore_location ) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stdout) # a.nodes
def __test_ping_post(self, args = {"ServiceName": "_adminconsole"}): res = post(self.URL + "ping", data=args) rootLogger.info(res) rootLogger.info(res.content) self.__test_server_is_running(res) if args.get("RT"): content = InfaCliResponse() content.ParseFromString(res.content) rootLogger.info("protobuf {0}".format(content)) self.__test_api_ret_status(content.retcode, failureMsg=content.stdout) else: content = json.loads(res.content.decode()) # type: dict rootLogger.info(content.get("retcode")) self.__test_api_ret_status(content.get("retcode"), failureMsg=content.get("stdout"))
def test_listUserPrivileges(self): servicesResult = listServices( ServiceType=servicetype_namedtuple.PowerCenter_Repository_Service) usersResult = listAllUsers() self.assertEqual(servicesResult.retcode, 0, servicesResult.stderr) self.assertEqual(usersResult.retcode, 0, usersResult.stderr) servicesList = servicesResult.stdout usersList = usersResult.stdout # type: dict for service in servicesList: serviceStatus = getServiceStatus(ServiceName=service) self.assertEqual(serviceStatus.retcode, 0, serviceStatus.stderr) if serviceStatus.stdout: for user in usersList: res = listUserPrivileges( ServiceName=service, ExistingUserName=user.get("userName"), ExistingUserSecurityDomain=user.get("securityDomain")) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) print() pprint(res.stdout)
def test_50_listWorkflowParams(self): servicesResult = listServices( ServiceType=servicetype_namedtuple.Data_Integration_Service) self.assertEqual(servicesResult.retcode, 0, servicesResult.stderr) services = servicesResult.stdout for service in services: applicationsResult = listApplications(servicename=service) self.assertEqual(applicationsResult.retcode, 0, applicationsResult.stderr) applications = applicationsResult.stdout for application in applications: wkfResults = listWorkflows(DomainName=self.domain.name, ServiceName=service, Application=application) self.assertEqual(wkfResults.retcode, 0, wkfResults.stderr) wkfs = wkfResults.stdout for wkf in wkfs: res = listWorkflowParams(ServiceName=service, Application=application, Workflow=wkf) self.assertEqual(res.retcode, 0, res.stderr) rootLogger.info(res) print() pprint(res.stdout)
def setUp(self): # super().setUp() # _drop_inner_db() # _init_inner_db() debugLogger.info("before- the envs is {0}".format(self.mul_envs)) self.now_all_envs = copy.deepcopy(self.mul_envs) for name, value in self.env.items(): self.now_all_envs.setdefault(name, value) debugLogger.info("the now_all_envs is {0}".format(self.now_all_envs)) debugLogger.info("the envs is {0}".format(self.mul_envs)) debugLogger.info("") domain = Domain() self.current_domain = domain.get_domain() node = Node() self.current_node = node.get_current_node() # type: Node print("current node is {0}".format(self.current_node)) if not self.current_node.is_gateway: self.assertWarns( "the node {0} is not gateway, some operations are limited")
def test_purgeLog(self): BeforeDate = "2017/03/08" try: res = purgeLog(BeforeDate=BeforeDate) rootLogger.info(res) except Exception as e: rootLogger.exception(str(e)) BeforeDate = "2017-03-08" res = purgeLog(BeforeDate=BeforeDate) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr) BeforeDate = "04/08/2018" res = purgeLog(BeforeDate=BeforeDate) rootLogger.info(res) self.assertEqual(res.retcode, 0, res.stderr)