def main():
    result = True
    try:
        params = {}
        envs_dir = os.path.join(os.getcwd(), 'cf-smoke-tests', 'environments')
        global_params_file = os.path.join(envs_dir, 'global-pipeline-vars.yml')
        params = yaml.full_load(open(global_params_file, 'r'))
        dirs = os.listdir(envs_dir)
        for d in dirs:
            foundation_dir = os.path.join(envs_dir, d)
            if os.path.isdir(foundation_dir):
                params_file = os.path.join(foundation_dir, 'pipeline-vars.yml')
                params.update(yaml.full_load(open(params_file, 'r')))
                print("Deploying smoke-test-pipline for foundation {}".format(
                    params['FOUNDATION']))
                login_cmd = "fly --target ci-{} login --concourse-url {} -k --username {} --password {} --team-name {}".format(
                    params['FOUNDATION'], params['CONCOURSE_URL'],
                    params['CONCOURSE_USERNAME'],
                    os.environ['CONCOURSE_PASSWORD_FOR_{}'.format(
                        params['FOUNDATION'])], params['FOUNDATION'])
                if not utils.run_cmd(login_cmd, False):
                    print("Fly login failed for {}".format(
                        params['FOUNDATION']))
                    continue
                cmd = "fly --target ci-{} login --concourse-url {} -k --username {} --password {} --team-name {}".format(
                    params['FOUNDATION'], params['CONCOURSE_URL'],
                    params['CONCOURSE_USERNAME'], "[Redacted Password]",
                    params['FOUNDATION'])
                print(cmd)

                sync_cmd = "fly -t ci-{} sync".format(params['FOUNDATION'])
                if not utils.run_cmd(sync_cmd):
                    print("Fly sync failed for {}".format(
                        params['FOUNDATION']))
                    continue

                smoke_test_pipeline = os.path.join(os.getcwd(),
                                                   'cf-smoke-tests', 'ci',
                                                   'pipelines', 'pipeline.yml')
                set_pipeline_cmd = "fly --target ci-{} set-pipeline -c {} -p {} -l {} -l {} --non-interactive".format(
                    params['FOUNDATION'], smoke_test_pipeline,
                    params['PIPELINE_NAME'], global_params_file, params_file)
                if not utils.run_cmd(set_pipeline_cmd):
                    print("Fly set-pipeline failed for {}".format(
                        params['FOUNDATION']))
                    continue

                unpause_pipeline_cmd = "fly --target ci-{} unpause-pipeline -p {}".format(
                    params['FOUNDATION'], params['PIPELINE_NAME'])
                if not utils.run_cmd(unpause_pipeline_cmd):
                    print("Fly unpause-pipeline failed for {}".format(
                        params['FOUNDATION']))
                    continue
    except Exception as e:
        print(str(e))
        result = False

    return not result
示例#2
0
def gemfire_write_helper(gfsh_cli, connect_cmd, region, key, value):
    write_cmd = "\"put --region=/{} --key={} --value='{}'\"".format(
        region, key, value)
    cmd = "{} -e {} -e {}".format(gfsh_cli, connect_cmd, write_cmd)
    if not utils.run_cmd(cmd, False):
        return False
    return True
示例#3
0
def get_osx_platform_path():
    cmd = "xcodebuild -showsdks"
    (stdout, stderr) = utils.run_cmd(cmd)
    if stderr != "":
        print(stderr)
        sys.exit(1)

    match = re.search(r"(-sdk macosx\d+.\d+)", stdout, flags=re.MULTILINE)
    if not match:
        print("coundn't parse output of:\n", cmd, "\naborting!")
        sys.exit(1)

    sdkparam = match.group(0)
    cmd = "xcodebuild -version " + sdkparam + " Path"
    (sdkPath, stderr) = utils.run_cmd(cmd)
    if stderr != "":
        print(stderr)
        sys.exit(1)
    print("using sdk path:", sdkPath.rstrip())
    return sdkPath.rstrip()
示例#4
0
def extract_gemfire_tar():
    cmd = "tar -xzf {}-{}.tgz".format(gemfire_product, gemfire_product_version)
    if utils.run_cmd(cmd):
        os.environ['GEMFIRE_HOME'] = os.path.join(
            os.getcwd(), "{}-{}".format(gemfire_product,
                                        gemfire_product_version))
        if not os.listdir(os.environ['GEMFIRE_HOME']):
            return False
        os.environ['GFSH_CLI'] = os.path.join(os.environ['GEMFIRE_HOME'],
                                              'bin', 'gfsh')
        return True
    else:
        return False
def check_autoscaling_app_state(appname):
    if not common_tests.login(os.environ["SMOKE_USER"],
                              os.environ["SMOKE_PASSWORD"], "system",
                              "autoscaling"):
        return False
    cmd = "cf curl /v2/apps?q=name:{}".format(appname)
    status, out = utils.run_cmd(cmd, True, False, True)
    if status and json.loads(out)['total_results'] > 0:
        if json.loads(out)['resources'][0]['entity']['state'] == 'STARTED':
            return True
        else:
            print("Going to start the {} app...".format(appname))
            if not common_tests.start_app(appname):
                raise Exception(
                    'Attempt to start the {} app failed'.format(appname))
    elif status and json.loads(out)['total_results'] == 0:
        raise Exception('{} app was not found'.format(appname))
    else:
        return False
示例#6
0
def gemfire_create_regions():
    if 'GFSH_CLI' not in os.environ or \
        'GEMFIRE_URL' not in os.environ or \
        'GEMFIRE_USER' not in os.environ or \
        'GEMFIRE_PASSWORD' not in os.environ:
        return False

    print('>>> Creating regions in gemfire cluster using gfsh cli...')
    connect_cmd = "\"connect --use-http --url={} --user={} --password={}\"".format(
        os.environ['GEMFIRE_URL'], os.environ['GEMFIRE_USER'],
        os.environ['GEMFIRE_PASSWORD'])
    create_test_region_cmd = "\"create region --name=test --type=PARTITION_REDUNDANT --redundant-copies=1\""
    create_partitioned_region_cmd = "\"create region --name=partitioned --type=PARTITION_REDUNDANT --redundant-copies=1\""
    create_replicated_region_cmd = "\"create region --name=replicated --type=REPLICATE\""

    cmd = "{} -e {} -e {} -e {} -e {}".format(os.environ['GFSH_CLI'],
                                              connect_cmd,
                                              create_test_region_cmd,
                                              create_partitioned_region_cmd,
                                              create_replicated_region_cmd)
    return utils.run_cmd(cmd, False)
def main():
    result = True
    results = {}
    print("Starting AUTO-SCALING smoke-test...")
    start = time.time()
    try:
        os.environ['CF_DIAL_TIMEOUT'] = "30"
        print(os.environ['CF_DIAL_TIMEOUT'])

        results['autoscale_state'] = check_autoscaling_app_state('autoscale')
        if not results['autoscale_state']:
            raise Exception('autoscale app is down')

        results['autoscale_api_state'] = check_autoscaling_app_state(
            'autoscale-api')
        if not results['autoscale_api_state']:
            raise Exception('autoscale-api app is down')

        results['set_api'] = common_tests.set_api()
        if not results['set_api']:
            raise Exception('set_api failed')

        results['authenticate'] = common_tests.authenticate()
        if not results['authenticate']:
            raise Exception('authenticate failed')

        results['set_target'] = common_tests.set_target()
        if not results['set_target']:
            raise Exception('set_target failed')

        results['pivnet_login'] = common_tests.pivnet_login()
        if not results['pivnet_login']:
            raise Exception('pivnet_login failed')

        results[
            'pivnet_get_product_id'], product_id = common_tests.pivnet_get_product_id(
                autoscaler_product, autoscaler_product_version, 'linux64')
        if not results['pivnet_get_product_id']:
            raise Exception('pivnet_get_product_id failed')

        results['pivnet_accept_eula'] = common_tests.pivnet_accept_eula(
            autoscaler_product, autoscaler_product_version)
        if not results['pivnet_accept_eula']:
            raise Exception('pivnet_accept_eula failed')

        results[
            'pivnet_download_product_files'] = common_tests.pivnet_download_product_files(
                autoscaler_product, autoscaler_product_version, product_id)
        if not results['pivnet_download_product_files']:
            raise Exception('pivnet_download_product_files failed')

        results['pivnet_logout'] = common_tests.pivnet_logout()
        if not results['pivnet_logout']:
            raise Exception('pivnet_logout failed')

        results['install_autoscaler_plugin'] = utils.run_cmd(
            "cf install-plugin -f {}".format(
                os.path.join(os.getcwd(),
                             glob.glob('autoscaler-for-pcf-*')[0])))
        if not results['install_autoscaler_plugin']:
            raise Exception('install_autoscaler_plugin failed')

        results['create_service'] = common_tests.create_service(
            autoscaler_service_name, autoscaler_service_plan,
            autoscaler_service_instance)
        if not results['create_service']:
            raise Exception('create_service failed')

        manifest_path = os.path.join(autoscaler_sample_app_path,
                                     'manifest.yml')
        params = "{} -f {} -p {} --no-start".format(
            autoscaler_sample_app, manifest_path, autoscaler_sample_app_path)
        results['push_app'] = common_tests.push_app(params)
        if not results['push_app']:
            results['get_app_logs'] = common_tests.get_app_logs(
                autoscaler_sample_app)
            raise Exception('push_app failed')

        results['bind_service'] = common_tests.bind_service(
            autoscaler_sample_app, autoscaler_service_instance)
        if not results['bind_service']:
            raise Exception('bind_service failed')

        results['start_app'] = common_tests.start_app(autoscaler_sample_app)
        if not results['start_app']:
            results['get_app_logs'] = common_tests.get_app_logs(
                autoscaler_sample_app)
            raise Exception('start_app failed')

        min_instances = 3
        max_instances = 5
        results['update_autoscaling_limits'] = utils.run_cmd(
            "cf update-autoscaling-limits {} {} {}".format(
                autoscaler_sample_app, min_instances, max_instances))
        if not results['update_autoscaling_limits']:
            raise Exception('update_autoscaling_limits failed')

        results['enable_autoscaling'] = utils.run_cmd(
            "cf enable-autoscaling {}".format(autoscaler_sample_app))
        if not results['enable_autoscaling']:
            raise Exception('enable_autoscaling failed')

        results['autoscaling_apps'] = utils.run_cmd("cf autoscaling-apps")
        if not results['autoscaling_apps']:
            raise Exception('autoscaling_apps failed')

        results['autoscaling_rules'] = utils.run_cmd(
            "cf autoscaling-rules {}".format(autoscaler_sample_app))
        if not results['autoscaling_rules']:
            raise Exception('autoscaling_rules failed')

        results['create_rule_http_throughput'] = utils.run_cmd(
            "cf create-autoscaling-rule {} http_throughput 10 50".format(
                autoscaler_sample_app))
        if not results['create_rule_http_throughput']:
            raise Exception('create_rule_http_throughput failed')

        results['create_rule_http_latency'] = utils.run_cmd(
            "cf create-autoscaling-rule {} http_latency 10 20 -s avg_99th".
            format(autoscaler_sample_app))
        if not results['create_rule_http_latency']:
            raise Exception('create_rule_http_latency failed')

        results['create_rule_cpu'] = utils.run_cmd(
            "cf create-autoscaling-rule {} cpu 10 60".format(
                autoscaler_sample_app))
        if not results['create_rule_cpu']:
            raise Exception('create_rule_cpu failed')

        results['create_rule_memory'] = utils.run_cmd(
            "cf create-autoscaling-rule {} memory 20 80".format(
                autoscaler_sample_app))
        if not results['create_rule_memory']:
            raise Exception('create_rule_memory failed')

        results['autoscaling_rules'] = utils.run_cmd(
            "cf autoscaling-rules {}".format(autoscaler_sample_app))
        if not results['autoscaling_rules']:
            raise Exception('autoscaling_rules failed')

        generate_http_traffic()

        results['autoscaling_events'] = utils.run_cmd(
            "cf autoscaling-events {}".format(autoscaler_sample_app))
        if not results['autoscaling_events']:
            raise Exception('autoscaling_events failed')

    except Exception as e:
        print(str(e))
        result = False
    finally:
        try:
            results['delete_autoscaling_rules'] = utils.run_cmd(
                "cf delete-autoscaling-rules -f {}".format(
                    autoscaler_sample_app))
            if not results['delete_autoscaling_rules']:
                print('delete_autoscaling_rules failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['disable_autoscaling'] = utils.run_cmd(
                'cf disable-autoscaling {}'.format(autoscaler_sample_app))
            if not results['disable_autoscaling']:
                print('disable_autoscaling failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['unbind_service'] = common_tests.unbind_service(
                autoscaler_sample_app, autoscaler_service_instance)
            if not results['unbind_service']:
                print('unbind_service failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['delete_app'] = common_tests.delete_app(
                autoscaler_sample_app)
            if not results['delete_app']:
                print('delete_app failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['delete_service'] = common_tests.delete_service(
                autoscaler_service_instance)
            if not results['delete_service']:
                print('delete_service failed')
        except Exception as e:
            print(str(e))
            result = False

    if result and not all(value == True for value in results.values()):
        result = False
    print("Finished AUTO-SCALING smoke-test...")
    print(json.dumps(results, indent=1))
    print("Overall result: {}".format("Passed" if result else "Failed"))
    end = time.time()
    minutes_taken = (end - start) / 60
    print("Total time taken: {} minutes".format(minutes_taken))
    results['overall_result'] = result
    results['minutes_taken'] = minutes_taken
    report_results.send_metric_to_influxdb('auto-scaler', results)
    return not result
示例#8
0
# PxPhysicsWithExtensions     #
###############################

print("PxPhysicsWithExtensions:")

srcPath = "PxPhysicsWithExtensionsAPI.h"
metaDataDir = os.path.join(sdkRoot, os.path.normpath("source/physxmetadata"))

targetDir = setup_targetdir(metaDataDir, args.test)

cmd = " ".join([
    "", clangExe, commonFlags, "", platformFlags, includes, srcPath, "-o",
    '"' + targetDir + '"'
])
print(cmd, file=debugFile)
(stdout, stderr) = utils.run_cmd(cmd)
if (stderr != "" or stdout != ""):
    print(stderr, "\n", stdout)
print("wrote meta data files in", targetDir)

test_targetdir(targetDir, metaDataDir, args.test)

###############################
# PxVehicleExtension          #
###############################

print("PxVehicleExtension:")

srcPath = "PxVehicleExtensionAPI.h"
metaDataDir = os.path.join(
    sdkRoot, os.path.normpath("source/physxvehicle/src/physxmetadata"))
示例#9
0
def main():
    result = True
    results = {}
    print("Starting PCC smoke-test...")
    start = time.time()
    try:
        results['set_api'] = common_tests.set_api()
        if not results['set_api']:
            raise Exception('set_api failed')

        results['authenticate'] = common_tests.authenticate()
        if not results['authenticate']:
            raise Exception('authenticate failed')

        results['set_target'] = common_tests.set_target()
        if not results['set_target']:
            raise Exception('set_target failed')

        results[
            'list_marketplace_service'] = common_tests.list_marketplace_service(
                pcc_service_name)
        if not results['list_marketplace_service']:
            raise Exception('list_marketplace_service failed')

        results['create_service'] = common_tests.create_service(
            pcc_service_name, pcc_service_plan, pcc_service_instance)
        if not results['create_service']:
            raise Exception('create_service failed')

        results['show_service_info'] = common_tests.show_service_info(
            pcc_service_instance)
        if not results['show_service_info']:
            raise Exception('show_service_info failed')

        results['create_service_key'] = common_tests.create_service_key(
            pcc_service_instance, pcc_service_key)
        if not results['create_service_key']:
            raise Exception('create_service_key failed')

        results[
            'show_service_key_info'], service_key = common_tests.show_service_key_info(
                pcc_service_instance, pcc_service_key)
        if not results['show_service_key_info']:
            raise Exception('show_service_key_info failed')
        else:
            os.environ['GEMFIRE_URL'] = str(service_key['urls']['gfsh'])
            for user in service_key['users']:
                if user['username'].startswith('cluster_operator'):
                    os.environ['GEMFIRE_USER'] = str(user["username"])
                    os.environ['GEMFIRE_PASSWORD'] = str(user["password"])
                    break

        results['pivnet_login'] = common_tests.pivnet_login()
        if not results['pivnet_login']:
            raise Exception('pivnet_login failed')

        results[
            'pivnet_get_product_id'], product_id = common_tests.pivnet_get_product_id(
                gemfire_product, gemfire_product_version, 'Tar')
        if not results['pivnet_get_product_id']:
            raise Exception('pivnet_get_product_id failed')

        results['pivnet_accept_eula'] = common_tests.pivnet_accept_eula(
            gemfire_product, gemfire_product_version)
        if not results['pivnet_accept_eula']:
            raise Exception('pivnet_accept_eula failed')

        results[
            'pivnet_download_product_files'] = common_tests.pivnet_download_product_files(
                gemfire_product, gemfire_product_version, product_id)
        if not results['pivnet_download_product_files']:
            raise Exception('pivnet_download_product_files failed')

        results['pivnet_logout'] = common_tests.pivnet_logout()
        if not results['pivnet_logout']:
            raise Exception('pivnet_logout failed')

        results['extract_gemfire_tar'] = extract_gemfire_tar()
        if not results['extract_gemfire_tar']:
            raise Exception('extract_gemfire_tar failed')

        results['gemfire_create_regions'] = gemfire_create_regions()
        if not results['gemfire_create_regions']:
            raise Exception('gemfire_create_regions failed')

        results['gemfire_write'] = gemfire_write()
        if not results['gemfire_write']:
            raise Exception('gemfire_write failed')

        print(">>> Updating the sample-app manifest...")
        cmd = "cd {} && sed -i -e \'s/service0/{}/g\' manifest.yml".format(
            pcc_sample_app_path, pcc_service_instance)
        utils.run_cmd(cmd)

        print(
            ">>> Updating username, password and gemfire-version in sample-app config..."
        )
        cmd = "cd {} && \
               sed -i -e \'s/SAMPLE_USERNAME/{}/g\' gradle.properties && \
               sed -i -e \'s/SAMPLE_PASSWORD/{}/g\' gradle.properties && \
               sed -i -e \'s/9.0.2/{}/g\' build.gradle".format(
            pcc_sample_app_path, os.environ['SMOKE_USER'],
            os.environ['SMOKE_PASSWORD'].replace("&", "\&"),
            gemfire_product_version)
        utils.run_cmd(cmd, False, False)

        print(">>> Building the sample-app...")
        cmd = "cd {} && ./gradlew clean build".format(pcc_sample_app_path)
        utils.run_cmd(cmd)

        manifest_path = os.path.join(pcc_sample_app_path, 'manifest.yml')
        params = "{} -f {} -p {} --no-start".format(pcc_sample_app,
                                                    manifest_path,
                                                    pcc_sample_app_path)
        results['push_app'] = common_tests.push_app(params)
        if not results['push_app']:
            results['get_app_logs'] = common_tests.get_app_logs(pcc_sample_app)
            raise Exception('push_app failed')

        results['bind_service'] = common_tests.bind_service(
            pcc_sample_app, pcc_service_instance)
        if not results['bind_service']:
            raise Exception('bind_service failed')

        results['gemfire_read'] = gemfire_read()
        if not results['gemfire_read']:
            raise Exception('gemfire_read failed')

    except Exception as e:
        print(str(e))
        result = False
    finally:
        try:
            results['unbind_service'] = common_tests.unbind_service(
                pcc_sample_app, pcc_service_instance)
            if not results['unbind_service']:
                print('unbind_service failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['delete_service_key'] = common_tests.delete_service_key(
                pcc_service_instance, pcc_service_key)
            if not results['delete_service_key']:
                print('delete_service_key failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['delete_app'] = common_tests.delete_app(pcc_sample_app)
            if not results['delete_app']:
                print('delete_app failed')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results['delete_service'] = common_tests.delete_service(
                pcc_service_instance)
            if not results['delete_service']:
                print('delete_service failed')
        except Exception as e:
            print(str(e))
            result = False

    if result and not all(value == True for value in results.values()):
        result = False
    print("Finished PCC smoke-test...")
    print(json.dumps(results, indent=1))
    print("Overall result: {}".format("Passed" if result else "Failed"))
    end = time.time()
    minutes_taken = (end - start) / 60
    print("Total time taken: {} minutes".format(minutes_taken))
    results['overall_result'] = result
    results['minutes_taken'] = minutes_taken
    report_results.send_metric_to_influxdb('pcc', results)
    return not result
示例#10
0
def gemfire_read_helper(gfsh_cli, connect_cmd, region):
    desc_cmd = "\"describe region --name={}\"".format(region)
    read_cmd = "\"query --query='select * from /{}'\"".format(region)
    cmd = "{} -e {} -e {} -e {}".format(gfsh_cli, connect_cmd, desc_cmd,
                                        read_cmd)
    return utils.run_cmd(cmd, False)