예제 #1
0
    def __init__(self):
        logger.info('Starting TestRail reporting.')

        # Set the Test_Rail URL, user name and password.
        self.test_rail_url = get_config_property('Test_rail', 'test_rail_url')
        self.client = api_client.APIClient(self.test_rail_url)
        self.client.user = get_config_property('Test_rail', 'username')
        self.client.password = get_config_property('Test_rail', 'password')
예제 #2
0
    def testsObj(self, appurl, api_key):
        apiclient = api_client.APIClient(appurl, api_key)

        ############### Executing readOnly True testcases ##############################
        tests["prerequisite"] = importlib.import_module(
            "prerequisite.prerequisites_readonly_true").prerequisite(apiclient)
        ##### Rules validate- account & credential
        tests["ruleValidate"] = importlib.import_module(
            "account-service-v2.rules-api.rule-validation").RuleValidation(
                apiclient, appurl)
        tests["ruleAPI"] = importlib.import_module(
            "account-service-v2.rules-api.rules-api").RulesAPI(apiclient)
        ##v2 accounts
        tests["amazonv2"] = importlib.import_module(
            "account-service-v2.facet-provider.amazon.amazonv2_readonly_true"
        ).AmazonTest(apiclient)
        tests["azurev2"] = importlib.import_module(
            "account-service-v2.facet-provider.azure.azurev2_readonly_true"
        ).AzureTest(apiclient)
        tests["googlev2"] = importlib.import_module(
            "account-service-v2.facet-provider.google.googlev2_readonly_true"
        ).GoogleTest(apiclient)
        tests["ibmv2"] = importlib.import_module(
            "account-service-v2.facet-provider.ibm.ibmv2_readonly_true"
        ).IbmTest(apiclient)
        tests["icdv2"] = importlib.import_module(
            "account-service-v2.facet-provider.icd.icdv2_readonly_true"
        ).IcdTest(apiclient)
        tests["snowv2"] = importlib.import_module(
            "account-service-v2.facet-provider.snow.snowv2_readonly_true"
        ).SnowTest(apiclient)
        tests["vrav2"] = importlib.import_module(
            "account-service-v2.facet-provider.vra.vrav2_readonly_true"
        ).VraTest(apiclient)

        # # Feature Tests
        tests["accountAdvanceSearch"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-advance-search.account-advance-search"
        ).AccountAdvanceSearch(apiclient)
        tests["accountCredential"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-credential.account-credential"
        ).AccountCredential(apiclient)
        tests["accountFilter"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-filter.account-filter"
        ).AccountFilter(apiclient)
        tests["accountGet"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-get.account-get"
        ).AccountGet(apiclient)
        tests["accountPagination"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-pagination.account-pagination"
        ).AccountPagination(apiclient)
        tests["accountPurpose"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose"
        ).AccountPurpose(apiclient)
        tests["accountSearch"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-search.account-search"
        ).AccountSearch(apiclient)
        tests["accountSort"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-sort.account-sort"
        ).AccountSort(apiclient)
        tests["accountTestConnection"] = importlib.import_module(
            "account-service-v2.scenario-ui.test-connection.test-connection_readonly_true"
        ).AccountTestConnection(apiclient)
        tests["purposeFilter"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose-filter"
        ).AccountPurpose(apiclient)

        # Currency
        tests["currencyConversion"] = importlib.import_module(
            "Currency.currency").Currency(apiclient)
        # #### Vault
        tests["vaultOnboarding"] = importlib.import_module(
            "account-service-v2.scenario-onboarding.external-vault-onboarding.external-vault-onboarding"
        ).ExternalVaultOnboarding(apiclient)
        #Audit

        tests['AuditLogUI'] = importlib.import_module(
            "auditlog.auditlog-ui.auditlog-ui").AuditLogUI(apiclient)
        tests['auditlogAdvanceSearch'] = importlib.import_module(
            "auditlog.auditlog-advance-search.auditlog-advance-search"
        ).AuditlogAdvanceSearch(apiclient)
        tests['AuditLogArchivePolicy'] = importlib.import_module(
            "auditlog.auditlog-archive-policy.auditlog-archive-policy"
        ).AuditLogArchivePolicy(apiclient)

        tests['AuditLogArchive'] = importlib.import_module(
            "auditlog.auditlog-archive.auditlog-archive").AuditLogArchive(
                apiclient)

        tests['AuditLogDownload'] = importlib.import_module(
            "auditlog.auditlog-download.auditlog-download").AuditLogDownload(
                apiclient)

        tests['latest_codeChanges'] = importlib.import_module(
            "latestApiChanges.latestcodechanges_readonly_true"
        ).lastetCodeChanges(apiclient)

        tests['validate_result'] = importlib.import_module(
            "account-service-v2.validation-results.validation-result-post"
        ).ValidationResult(apiclient)
        # store credential validation result
        tests['ValidationResultTest'] = importlib.import_module(
            "account-service-v2.rules-api.credential-val-result.validation-result"
        ).ValidationResultTest(apiclient)
        tests['ValidationResultGetTest'] = importlib.import_module(
            "account-service-v2.validation-result-api.validation-result-get"
        ).ValidationResultGetTest(apiclient)
        ################## ------------- Executing readOnly False testcases ------------- ##############################
        tests["prerequisite_readonlyFalse"] = importlib.import_module(
            "prerequisite.prerequisites").prerequisite(apiclient)
        ##v2 accounts
        tests["amazonv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.amazon.amazonv2").AmazonTest(
                apiclient)
        tests["azurev2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.azure.azurev2").AzureTest(
                apiclient)
        tests["googlev2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.google.googlev2").GoogleTest(
                apiclient)
        tests["ibmv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.ibm.ibmv2").IbmTest(apiclient)
        tests["icdv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.icd.icdv2").IcdTest(apiclient)
        tests["snowv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.snow.snowv2").SnowTest(
                apiclient)
        tests["vrav2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.vra.vrav2").VraTest(apiclient)

        # Feature Tests
        tests["accountAdvanceSearch_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-advance-search.account-advance-search"
        ).AccountAdvanceSearch(apiclient)
        tests["accountCredential_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-credential.account-credential"
        ).AccountCredential(apiclient)
        tests["accountFilter_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-filter.account-filter"
        ).AccountFilter(apiclient)
        tests["accountGet_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-get.account-get"
        ).AccountGet(apiclient)
        tests["accountPagination_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-pagination.account-pagination"
        ).AccountPagination(apiclient)
        tests["accountPurpose_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose"
        ).AccountPurpose(apiclient)
        tests["accountSearch_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-search.account-search"
        ).AccountSearch(apiclient)
        tests["accountSort_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-sort.account-sort"
        ).AccountSort(apiclient)
        tests["accountTestConnection_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.test-connection.test-connection"
        ).AccountTestConnection(apiclient)
        tests["purposeFilter_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose-filter"
        ).AccountPurpose(apiclient)

        tests['auditlogAdvanceSearch_readonlyFalse'] = importlib.import_module(
            "auditlog.auditlog-advance-search.auditlog-advance-search"
        ).AuditlogAdvanceSearch(apiclient)
        tests['AuditLogUI_readonlyFalse'] = importlib.import_module(
            "auditlog.auditlog-ui.auditlog-ui").AuditLogUI(apiclient)
        tests['AuditLogDownload_readonlyFalse'] = importlib.import_module(
            "auditlog.auditlog-download.auditlog-download").AuditLogDownload(
                apiclient)
        #### Vault
        tests["vaultOnboarding_readonlyFalse"] = importlib.import_module(
            "account-service-v2.scenario-onboarding.external-vault-onboarding.external-vault-onboarding"
        ).ExternalVaultOnboarding(apiclient)
        tests['latest_codeChanges_readonlyFalse'] = importlib.import_module(
            "latestApiChanges.latestcodechanges").lastetCodeChanges(apiclient)
        tests['system_user'] = importlib.import_module(
            "systemuser.systemuser").systemuser(apiclient)

        ##E2E Test cases
        # tests["vrav2"] = importlib.import_module("account-service-v2.scenario-integration.inventory-integration.vrae2e").VRA_Tests(apiclient)
        # tests["amazone2e"] = importlib.import_module("account-service-v2.scenario-integration.inventory-integration.amazone2e").Amazon_Tests(apiclient)
        # tests["softlayere2e"] = importlib.import_module("account-service-v2.scenario-integration.inventory-integration.softlayere2e").Softlayer_Tests(apiclient)
        # tests["azuree2e"] = importlib.import_module("account-service-v2.scenario-integration.inventory-integration.azuree2e").AZURE_Tests(apiclient)

        return tests
예제 #3
0
    def testsObj(self, appurl, api_key):
        apiclient = api_client.APIClient(appurl, api_key)

        ################## Executing readOnly True testcases ##############################
        tests["prerequisite"] = importlib.import_module(
            "prerequisite.prerequisites_readonly_true").prerequisite(apiclient)
        ###### Rules validate- account & credential

        tests["amazonv2"] = importlib.import_module(
            "account-service-v2.facet-provider.amazon.amazonv2_readonly_true"
        ).AmazonTest(apiclient)
        tests["azurev2"] = importlib.import_module(
            "account-service-v2.facet-provider.azure.azurev2_readonly_true"
        ).AzureTest(apiclient)
        tests["googlev2"] = importlib.import_module(
            "account-service-v2.facet-provider.google.googlev2_readonly_true"
        ).GoogleTest(apiclient)
        tests["ibmv2"] = importlib.import_module(
            "account-service-v2.facet-provider.ibm.ibmv2_readonly_true"
        ).IbmTest(apiclient)
        tests["icdv2"] = importlib.import_module(
            "account-service-v2.facet-provider.icd.icdv2_readonly_true"
        ).IcdTest(apiclient)
        tests["snowv2"] = importlib.import_module(
            "account-service-v2.facet-provider.snow.snowv2_readonly_true"
        ).SnowTest(apiclient)
        tests["vrav2"] = importlib.import_module(
            "account-service-v2.facet-provider.vra.vrav2_readonly_true"
        ).VraTest(apiclient)

        # # Feature Tests
        tests["accountAdvanceSearch"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-advance-search.account-advance-search"
        ).AccountAdvanceSearch(apiclient)
        tests["accountFilter"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-filter.account-filter"
        ).AccountFilter(apiclient)
        tests["accountGet"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-get.account-get"
        ).AccountGet(apiclient)
        tests["accountPagination"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-pagination.account-pagination"
        ).AccountPagination(apiclient)
        tests["accountPurpose"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose"
        ).AccountPurpose(apiclient)
        tests["accountSearch"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-search.account-search"
        ).AccountSearch(apiclient)
        tests["accountSort"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-sort.account-sort"
        ).AccountSort(apiclient)
        tests["accountTestConnection"] = importlib.import_module(
            "account-service-v2.scenario-ui.test-connection.test-connection_readonly_true"
        ).AccountTestConnection(apiclient)
        tests["purposeFilter"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose-filter"
        ).AccountPurpose(apiclient)

        #Audit
        tests['auditlogAdvanceSearch'] = importlib.import_module(
            "auditlog.auditlog-advance-search.auditlog-advance-search"
        ).AuditlogAdvanceSearch(apiclient)

        tests['AuditLogDownload'] = importlib.import_module(
            "auditlog.auditlog-download.auditlog-download").AuditLogDownload(
                apiclient)

        tests['AuditLogUI'] = importlib.import_module(
            "auditlog.auditlog-ui.auditlog-ui").AuditLogUI(apiclient)

        ################ ------------- Executing readOnly False testcases ------------- ##############################
        tests["prerequisite_readonlyFalse"] = importlib.import_module(
            "prerequisite.prerequisites").prerequisite(apiclient)
        #v2 accounts
        tests["amazonv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.amazon.amazonv2").AmazonTest(
                apiclient)
        tests["azurev2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.azure.azurev2").AzureTest(
                apiclient)
        tests["googlev2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.google.googlev2").GoogleTest(
                apiclient)
        tests["ibmv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.ibm.ibmv2").IbmTest(apiclient)
        tests["icdv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.icd.icdv2").IcdTest(apiclient)
        tests["snowv2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.snow.snowv2").SnowTest(
                apiclient)
        tests["vrav2_readonlyFalse"] = importlib.import_module(
            "account-service-v2.facet-provider.vra.vrav2").VraTest(apiclient)

        return tests
예제 #4
0
def run_api_tests():
    logger = logging.getLogger("Test Run")
    logger.setLevel(logging.INFO)
    handler = TimedRotatingFileHandler("test_run.log",
                                       when="m",
                                       interval=10,
                                       backupCount=2)
    logger.addHandler(handler)
    #logging.basicConfig(filename='test.log', level=logging.INFO)
    logger.info("-----------------------------------------------")
    logger.info("Test started: " + datetime.now().strftime('%Y-%m-%d-%H%M%S'))
    start_time = time.time()
    botclient = api_client.BotClient()

    if len(sys.argv) != 3:
        print("Error : Required arguments missing!!")
        print("Usage : python auto_run.py <env> <build_version>")
        print("ex : python auto_run.py qademo6 master_1945")
        exit(1)

    if (sys.argv[1] == 'myminikube.info'):
        appurl = "https://" + sys.argv[1] + ":30091/"
    elif (sys.argv[1] == 'automation-core-b'):
        appurl = "https://" + sys.argv[1] + "-api.multicloud-ibm.com/"
    else:
        appurl = "https://" + sys.argv[1] + "-api.gravitant.net/"

    if (sys.argv[1] == 'cb-qa-corex'):
        api_key = config.get('params', 'cbqacorexapikey')
    elif (sys.argv[1] == 'myminikube.info'):
        api_key = config.get('params', 'minikubeapikey')
    elif (sys.argv[1] == 'store-cicd-v2'):
        api_key = config.get('params', 'store_cicd_apikey')
    elif (sys.argv[1] == 'automation-core-b'):
        api_key = config.get('params', 'mtapikey')
    elif (sys.argv[1].find('cam-icp-api') != -1):
        appurl = sys.argv[1]
        api_key = config.get('params', 'apikey')
    elif (sys.argv[1] == 'cb-qa-core-premaster'):
        api_key = config.get('params', 'premaster_apikey')
    else:
        api_key = config.get('params', 'apikey')

    print("API key :" + api_key)
    print("URL :" + appurl)

    # decoding the apikey
    # api_key=utils.decodeCredential(api_key)
    print("API key decode:" + api_key)
    build_version = sys.argv[2]
    #tname = sys.argv[4]
    test_obj = config.get('params', 'test_object_name_in_suite')
    tname = config.get('params', 'test_case')
    testcase = tname.split(",")
    apiclient = api_client.APIClient(appurl, api_key)
    print("Host Name :" + sys.argv[1])
    print("API key:" + api_key)
    print("Build Version :" + build_version)
    print("URL :" + appurl)
    func_stat = {}
    #func_stat.update(utils.run_test_cases(api_tests.APITest(apiclient)))
    testSuite = TestSuite()
    testSuitenew = StoreCicdTestSuite()
    testSuiteMT = MultiTenancy()

    if (sys.argv[1] == 'cb-qa-corex' or sys.argv[1] == 'myminikube.info'
            or sys.argv[1] == 'cb-qa-core-latest-release'
            or sys.argv[1] == 'cb-qa-core-premaster'):
        test = testSuite.testsObj(appurl, api_key)
    elif (sys.argv[1] == 'automation-core-b'):
        test = testSuiteMT.testsObj(appurl, api_key)
    else:
        test = testSuitenew.testsObj(appurl, api_key)

    if tname == 'all':
        for t in test:
            func_stat.update(utils.run_test_cases(test[t]))
    else:
        for c in testcase:
            try:
                #testname = getattr(api_tests.APITest(apiclient), t)
                testname = getattr(test[test_obj], c)
                func_stat.update(utils.run_test_cases(testname()))
            except AttributeError:
                print("Test case not present.")

    execution_time = "*Total Time Taken for Execution : %s seconds *" % (
        time.time() - start_time)
    run_test = config.get('params', 'post_to_bot')
    text = "*APIs validation Result:*\n"
    if run_test == 'true':
        botclient.post_auto_stat(func_stat, slack_channel, text, appurl,
                                 build_version, execution_time)
    else:
        logger.info("Skipping posting the result to Slack!")
    logger.info("------------End of Tests------------")
    utils.get_error_logs_test_run()
    def testsObj(self, appurl, api_key):
        apiclient = api_client.APIClient(appurl, api_key)

        ################## Executing readOnly True testcases ##############################
        tests["prerequisite_readonly_true"] = importlib.import_module(
            "prerequisite.prerequisites_readonly_true").prerequisite(apiclient)
        ###v2 accounts
        tests["amazonv2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.amazon.amazonv2_readonly_true"
        ).AmazonTest(apiclient)
        tests["azurev2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.azure.azurev2_readonly_true"
        ).AzureTest(apiclient)
        tests["googlev2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.google.googlev2_readonly_true"
        ).GoogleTest(apiclient)
        tests["ibmv2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.ibm.ibmv2_readonly_true"
        ).IbmTest(apiclient)
        tests["icdv2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.icd.icdv2_readonly_true"
        ).IcdTest(apiclient)
        tests["snowv2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.snow.snowv2_readonly_true"
        ).SnowTest(apiclient)
        tests["vrav2_readonly_true"] = importlib.import_module(
            "account-service-v2.facet-provider.vra.vrav2_readonly_true"
        ).VraTest(apiclient)

        # Feature Tests
        tests["accountGet_readonly_true"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-get.account-get"
        ).AccountGet(apiclient)
        tests["accountPurpose_readonly_true"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose"
        ).AccountPurpose(apiclient)
        tests["purposeFilter_readonly_true"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose-filter"
        ).AccountPurpose(apiclient)

        # Currency
        tests["currencyConversion_readonly_true"] = importlib.import_module(
            "Currency.currency").Currency(apiclient)
        #### Vault
        tests["vaultOnboarding_readonly_true"] = importlib.import_module(
            "account-service-v2.scenario-onboarding.external-vault-onboarding.external-vault-onboarding"
        ).ExternalVaultOnboarding(apiclient)
        #Audit
        tests['AuditLogArchivePolicy_readonly_true'] = importlib.import_module(
            "auditlog.auditlog-archive-policy.auditlog-archive-policy"
        ).AuditLogArchivePolicy(apiclient)

        # # ################### ------------- Executing readOnly False testcases ------------- ##############################
        #
        tests["prerequisite"] = importlib.import_module(
            "prerequisite.prerequisites").prerequisite(apiclient)
        #v2 accounts
        tests["amazonv2"] = importlib.import_module(
            "account-service-v2.facet-provider.amazon.amazonv2").AmazonTest(
                apiclient)
        tests["azurev2"] = importlib.import_module(
            "account-service-v2.facet-provider.azure.azurev2").AzureTest(
                apiclient)
        tests["googlev2"] = importlib.import_module(
            "account-service-v2.facet-provider.google.googlev2").GoogleTest(
                apiclient)
        tests["ibmv2"] = importlib.import_module(
            "account-service-v2.facet-provider.ibm.ibmv2").IbmTest(apiclient)
        tests["icdv2"] = importlib.import_module(
            "account-service-v2.facet-provider.icd.icdv2").IcdTest(apiclient)
        tests["snowv2"] = importlib.import_module(
            "account-service-v2.facet-provider.snow.snowv2").SnowTest(
                apiclient)
        tests["vrav2"] = importlib.import_module(
            "account-service-v2.facet-provider.vra.vrav2").VraTest(apiclient)

        # Feature Tests
        # tests["accountCredential"] = importlib.import_module("account-service-v2.scenario-ui.account-credential.account-credential_cicdV2").AccountCredential(apiclient)
        tests["accountGet"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-get.account-get"
        ).AccountGet(apiclient)
        tests["accountPurpose"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose"
        ).AccountPurpose(apiclient)
        tests["purposeFilter"] = importlib.import_module(
            "account-service-v2.scenario-ui.account-purpose.account-purpose-filter"
        ).AccountPurpose(apiclient)

        ## Currency
        tests["currencyConversion"] = importlib.import_module(
            "Currency.currency").Currency(apiclient)
        #### Vault
        tests["vaultOnboarding"] = importlib.import_module(
            "account-service-v2.scenario-onboarding.external-vault-onboarding.external-vault-onboarding"
        ).ExternalVaultOnboarding(apiclient)
        #Audit
        tests['AuditLogArchivePolicy'] = importlib.import_module(
            "auditlog.auditlog-archive-policy.auditlog-archive-policy"
        ).AuditLogArchivePolicy(apiclient)

        return tests