Esempio n. 1
0
def test_scs_app():
    results = {}
    results['fortune_ui.health'] = False
    results['fortune_svc.health'] = False
    results['fortune_ui.random'] = False
    try:
        print(
            "Checking the health of Spring Cloud Services bound to fortune-teller app..."
        )

        _, ui_routes = utils.get_app_routes(fortune_ui_app)
        ui_health_url = "https://{}/health".format(ui_routes[0].strip())
        ui_random_url = "https://{}/random".format(ui_routes[0].strip())

        _, svc_routes = utils.get_app_routes(fortune_svc_app)
        svc_health_url = "https://{}/health".format(svc_routes[0].strip())

        print(ui_health_url)
        resp = requests.get(ui_health_url)
        results['fortune_ui.health'] = (resp.status_code == 200)
        print("status: {},\ncontent: {}\n".format(resp.status_code,
                                                  resp.content))

        print(svc_health_url)
        resp = requests.get(svc_health_url)
        results['fortune_svc.health'] = (resp.status_code == 200)
        print("status: {},\ncontent: {}\n".format(resp.status_code,
                                                  resp.content))

        print(ui_random_url)
        resp = requests.get(ui_random_url)
        results['fortune_ui.random'] = (resp.status_code == 200)
        print("status: {},\ncontent: {}\n".format(resp.status_code,
                                                  resp.content))

        print("Stoping fortune-service app...")
        common_tests.stop_app(fortune_svc_app)

        print(ui_random_url)
        resp = requests.get(ui_random_url)
        results['fortune_ui.random'] = results['fortune_ui.random'] and (
            resp.status_code == 200)
        print("status: {},\ncontent: {}\n".format(resp.status_code,
                                                  resp.content))

        print("Starting fortune-service app...")
        if not common_tests.start_app(fortune_svc_app):
            results['fortune_svc.get_app_logs'] = common_tests.get_app_logs(
                fortune_svc_app)

        print(ui_random_url)
        resp = requests.get(ui_random_url)
        results['fortune_ui.random'] = results['fortune_ui.random'] and (
            resp.status_code == 200)
        print("status: {},\ncontent: {}\n".format(resp.status_code,
                                                  resp.content))

    except Exception as e:
        print(str(e))
    return results
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
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
Esempio n. 4
0
def main():
    result = True
    results = {}
    print("Starting RabbitMQ 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(
                rabbimq_service_name)
        if not results['list_marketplace_service']:
            raise Exception('list_marketplace_service failed')

        results['create_service'] = common_tests.create_service(
            rabbimq_service_name, rabbitmq_service_plan,
            rabbitmq_service_instance)
        if not results['create_service']:
            raise Exception('create_service failed')

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

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

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

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

        test_app_result = test_rabbitmq_app()

        results['test_app_write'] = test_app_result['write']
        if not results['test_app_write']:
            raise Exception('test_app_write failed')

        results['test_app_read'] = test_app_result['read']
        if not results['test_app_read']:
            raise Exception('test_app_read failed')

    except Exception as e:
        print(str(e))
        result = False
    finally:
        try:
            results['unbind_service'] = common_tests.unbind_service(
                rabbitmq_sample_app, rabbitmq_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(
                rabbitmq_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(
                rabbitmq_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 RabbitMQ 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('rabbitmq', results)
    return not result
Esempio n. 5
0
def main():
    result = True
    results = {}
    print("Starting SCS 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')

        config_server_config = {
            "git": {
                "uri": scs_sample_app_uri,
                "privateKey": scs_sample_app_key,
                "searchPaths": "sample_apps/scs-sample-app/configuration"
            }
        }
        results['config_server.create_service'] = common_tests.create_service(
            config_server_service_name, config_server_service_plan,
            config_server_service_instance, config_server_config)
        if not results['config_server.create_service']:
            raise Exception('create_service failed for config_server')

        results[
            'service_registry.create_service'] = common_tests.create_service(
                service_registry_service_name, service_registry_service_plan,
                service_registry_service_instance)
        if not results['service_registry.create_service']:
            raise Exception('create_service failed for service_registry')

        results[
            'circuit_breaker.create_service'] = common_tests.create_service(
                circuit_breaker_service_name, circuit_breaker_service_plan,
                circuit_breaker_service_instance)
        if not results['circuit_breaker.create_service']:
            raise Exception('create_service failed for circuit_breaker')

        results['mysql.create_service'] = common_tests.create_service(
            mysql_service_name, mysql_service_plan, mysql_service_instance)
        if not results['mysql.create_service']:
            raise Exception('create_service failed for mysql')

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

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

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

        params = "{} -f {} --no-start".format(fortune_ui_app,
                                              fortune_ui_app_path)
        results['fortune_ui.push_app'] = common_tests.push_app(params)
        if not results['fortune_ui.push_app']:
            raise Exception('push_app failed for fortune_ui_app')

        params = "{} -f {} --no-start".format(fortune_svc_app,
                                              fortune_svc_app_path)
        results['fortune_svc.push_app'] = common_tests.push_app(params)
        if not results['fortune_svc.push_app']:
            raise Exception('push_app failed for fortune_svc_app')

        results[
            'config_server.fortune_ui.bind_service'] = common_tests.bind_service(
                fortune_ui_app, config_server_service_instance)
        if not results['config_server.fortune_ui.bind_service']:
            raise Exception(
                'bind_service failed for config_server - fortune_ui_app')

        results[
            'service_registry.fortune_ui.bind_service'] = common_tests.bind_service(
                fortune_ui_app, service_registry_service_instance)
        if not results['service_registry.fortune_ui.bind_service']:
            raise Exception(
                'bind_service failed for service_registry - fortune_ui_app')

        results[
            'circuit_breaker.fortune_ui.bind_service'] = common_tests.bind_service(
                fortune_ui_app, circuit_breaker_service_instance)
        if not results['circuit_breaker.fortune_ui.bind_service']:
            raise Exception(
                'bind_service failed for circuit_breaker - fortune_ui_app')

        results[
            'config_server.fortune_svc.bind_service'] = common_tests.bind_service(
                fortune_svc_app, config_server_service_instance)
        if not results['config_server.fortune_svc.bind_service']:
            raise Exception(
                'bind_service failed for config_server - fortune_svc_app')

        results[
            'service_registry.fortune_svc.bind_service'] = common_tests.bind_service(
                fortune_svc_app, service_registry_service_instance)
        if not results['service_registry.fortune_svc.bind_service']:
            raise Exception(
                'bind_service failed for service_registry - fortune_svc_app')

        results[
            'circuit_breaker.fortune_svc.bind_service'] = common_tests.bind_service(
                fortune_svc_app, circuit_breaker_service_instance)
        if not results['circuit_breaker.fortune_svc.bind_service']:
            raise Exception(
                'bind_service failed for circuit_breaker - fortune_svc_app')

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

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

        results.update(test_scs_app())
        if not results['fortune_ui.health']:
            raise Exception('health-check failed for fortune_ui_app')
        if not results['fortune_ui.random']:
            raise Exception('config-check failed for fortune_ui_app')
        if not results['fortune_svc.health']:
            raise Exception('health-check failed for fortune_svc_app')

    except Exception as e:
        print(str(e))
        result = False
    finally:
        try:
            results[
                'config_server.fortune_ui.unbind_service'] = common_tests.unbind_service(
                    fortune_ui_app, config_server_service_instance)
            if not results['config_server.fortune_ui.unbind_service']:
                print(
                    'unbind_service failed for config_server - fortune_ui_app')
        except Exception as e:
            print(str(e))
            result = False

        try:
            results[
                'service_registry.fortune_ui.unbind_service'] = common_tests.unbind_service(
                    fortune_ui_app, service_registry_service_instance)
            if not results['service_registry.fortune_ui.unbind_service']:
                print(
                    'unbind_service failed for service_registry - fortune_ui_app'
                )
        except Exception as e:
            print(str(e))
            result = False

        try:
            results[
                'circuit_breaker.fortune_ui.unbind_service'] = common_tests.unbind_service(
                    fortune_ui_app, circuit_breaker_service_instance)
            if not results['circuit_breaker.fortune_ui.unbind_service']:
                print(
                    'unbind_service failed for circuit_breaker - fortune_ui_app'
                )
        except Exception as e:
            print(str(e))
            result = False

        try:
            results[
                'config_server.fortune_svc.unbind_service'] = common_tests.unbind_service(
                    fortune_svc_app, config_server_service_instance)
            if not results['config_server.fortune_svc.unbind_service']:
                print(
                    'unbind_service failed for config_server - fortune_svc_app'
                )
        except Exception as e:
            print(str(e))
            result = False

        try:
            results[
                'service_registry.fortune_svc.unbind_service'] = common_tests.unbind_service(
                    fortune_svc_app, service_registry_service_instance)
            if not results['service_registry.fortune_svc.unbind_service']:
                print(
                    'unbind_service failed for service_registry - fortune_svc_app'
                )
        except Exception as e:
            print(str(e))
            result = False

        try:
            results[
                'circuit_breaker.fortune_svc.unbind_service'] = common_tests.unbind_service(
                    fortune_svc_app, circuit_breaker_service_instance)
            if not results['circuit_breaker.fortune_svc.unbind_service']:
                print(
                    'unbind_service failed for circuit_breaker - fortune_svc_app'
                )
        except Exception as e:
            print(str(e))
            result = False

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

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

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

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

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

        try:
            results[
                'circuit_breaker.delete_service'] = common_tests.delete_service(
                    circuit_breaker_service_instance)
            if not results['circuit_breaker.delete_service']:
                print('delete_service failed for circuit_breaker')
        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 SCS 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('scs', results)
    return not result
Esempio n. 6
0
def main():
    result = True
    results = {}
    print("Starting PAS 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')

        manifest_path = os.path.join(pas_sample_app_path, 'manifest.yml')
        params = "{} -f {} -p {} --no-start".format(pas_sample_app,
                                                    manifest_path,
                                                    pas_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(pas_sample_app)
            raise Exception('push_app failed')

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

        num_instances = 5
        results['scale_up_app'] = common_tests.scale_app(
            pas_sample_app, num_instances)
        if not results['scale_up_app']:
            raise Exception('scale_up_app failed')

        print('Sleeping for 20 seconds to let all instances come up...')
        time.sleep(20)

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

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

        results['scale_down_app'] = common_tests.scale_app(pas_sample_app, 1)
        if not results['scale_down_app']:
            raise Exception('scale_down_app failed')

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

    except Exception as e:
        print(str(e))
        result = False
    finally:
        try:
            results['delete_app'] = common_tests.delete_app(pas_sample_app)
            if not results['delete_app']:
                print('delete_app 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 PAS 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('pas', results)
    return not result
Esempio n. 7
0
def test_shared_plan():
    shared_vm_results = {}
    result = True

    try:  # leave service instances between uses to minimize window where customers can snatch final shared redis instance
        shared_vm_results['delete_service'] = common_tests.delete_service(redis_service_instance_shared_vm)
        if not shared_vm_results['delete_service']:
            print('(nonfatal) delete_service failed for shared-vm plan')
    except Exception as e:
        print(str(e))

    try:
        shared_vm_results['create_service'] = common_tests.create_service(redis_service_name, redis_service_shared_plan, redis_service_instance_shared_vm)	
        if not shared_vm_results['create_service']:	
            raise Exception('create_service failed for shared-vm plan')	

        shared_vm_results['show_service_info'] = common_tests.show_service_info(redis_service_instance_shared_vm)	
        if not shared_vm_results['show_service_info']:	
            raise Exception('show_service_info failed for shared-vm plan')	

        shared_vm_results['create_service_key'] = common_tests.create_service_key(redis_service_instance_shared_vm, redis_service_key_shared_vm)	
        if not shared_vm_results['create_service_key']:	
            raise Exception('create_service_key failed for shared-vm plan')	

        shared_vm_results['show_service_key_info'], _ = common_tests.show_service_key_info(redis_service_instance_shared_vm, redis_service_key_shared_vm)	
        if not shared_vm_results['show_service_key_info']:	
            raise Exception('show_service_key_info failed for shared-vm plan')	

        manifest_path = os.path.join(redis_sample_app_path, 'manifest.yml')
        params = "{} -f{} -p {} --no-start".format(redis_sample_app, manifest_path, redis_sample_app_path)
        shared_vm_results['push_app'] = common_tests.push_app(params)
        if not shared_vm_results['push_app']:
            raise Exception('push_app failed for shared-vm plan')

        shared_vm_results['bind_service'] = common_tests.bind_service(redis_sample_app, redis_service_instance_shared_vm)	
        if not shared_vm_results['bind_service']:	
            raise Exception('bind_service failed for shared-vm plan')	

        shared_vm_results['start_app'] = common_tests.start_app(redis_sample_app)	
        if not shared_vm_results['start_app']:	
            shared_vm_results['get_app_logs'] = common_tests.get_app_logs(redis_sample_app)	
            raise Exception('start_app failed for shared-vm plan')	

        test_app_result = test_redis_app()	

        shared_vm_results['test_app_write'] = test_app_result['write']	
        if not shared_vm_results['test_app_write']:	
            raise Exception('test_app_write failed for shared-vm plan')

        shared_vm_results['test_app_read'] = test_app_result['read']	
        if not shared_vm_results['test_app_read']:	
            raise Exception('test_app_read failed for shared-vm plan')	
    except Exception as e:	
        print(str(e))
        result = False
    finally:	
        try:	
            shared_vm_results['unbind_service'] = common_tests.unbind_service(redis_sample_app, redis_service_instance_shared_vm)	
            if not shared_vm_results['unbind_service']:	
                print('unbind_service failed for shared-vm plan')	
        except Exception as e:
            print(str(e))
            result = False

        try:
            shared_vm_results['delete_service_key'] = common_tests.delete_service_key(redis_service_instance_shared_vm, redis_service_key_shared_vm)	
            if not shared_vm_results['delete_service_key']:	
                print('delete_service_key failed for shared-vm plan')	
        except Exception as e:
            print(str(e))
            result = False

        try:
            shared_vm_results['delete_app'] = common_tests.delete_app(redis_sample_app)	
            if not shared_vm_results['delete_app']:	
                print('delete_app failed for shared-vm plan')	
        except Exception as e:
            print(str(e))
            result = False

    return shared_vm_results, result	
Esempio n. 8
0
def test_dedicated_plan():	
    dedicated_vm_results = {}	
    result = True	
    try:	
        dedicated_vm_results['create_service'] = common_tests.create_service(redis_service_name, redis_service_dedicated_plan, redis_service_instance_dedicated_vm)
        if not dedicated_vm_results['create_service']:	
            raise Exception('create_service failed for dedicated-vm plan')	

        dedicated_vm_results['show_service_info'] = common_tests.show_service_info(redis_service_instance_dedicated_vm)	
        if not dedicated_vm_results['show_service_info']:	
            raise Exception('show_service_info failed for dedicated-vm plan')	

        dedicated_vm_results['create_service_key'] = common_tests.create_service_key(redis_service_instance_dedicated_vm, redis_service_key_dedicated_vm)	
        if not dedicated_vm_results['create_service_key']:	
            raise Exception('create_service_key failed for dedicated-vm plan')	

        dedicated_vm_results['show_service_key_info'], _ = common_tests.show_service_key_info(redis_service_instance_dedicated_vm, redis_service_key_dedicated_vm)	
        if not dedicated_vm_results['show_service_key_info']:
            raise Exception('show_service_key_info failed for dedicated-vm plan')

        manifest_path = os.path.join(redis_sample_app_path, 'manifest.yml')
        params = "{} -f {} -p {} --no-start".format(redis_sample_app, manifest_path, redis_sample_app_path)
        dedicated_vm_results['push_app'] = common_tests.push_app(params)	
        if not dedicated_vm_results['push_app']:	
            raise Exception('push_app failed for dedicated-vm plan')	

        dedicated_vm_results['bind_service'] = common_tests.bind_service(redis_sample_app, redis_service_instance_dedicated_vm)	
        if not dedicated_vm_results['bind_service']:	
            raise Exception('bind_service failed for dedicated-vm plan')	

        dedicated_vm_results['start_app'] = common_tests.start_app(redis_sample_app)	
        if not dedicated_vm_results['start_app']:	
            dedicated_vm_results['get_app_logs'] = common_tests.get_app_logs(redis_sample_app)	
            raise Exception('start_app failed for dedicated-vm plan')	

        test_app_result = test_redis_app()

        dedicated_vm_results['test_app_write'] = test_app_result['write']	
        if not dedicated_vm_results['test_app_write']:	
            raise Exception('test_app_write failed for dedicated-vm plan')
	
        dedicated_vm_results['test_app_read'] = test_app_result['read']	
        if not dedicated_vm_results['test_app_read']:	
            raise Exception('test_app_read failed for dedicated-vm plan')	
    except Exception as e:	
        print(str(e))	
        result = False	
    finally:	
        try:	
            dedicated_vm_results['unbind_service'] = common_tests.unbind_service(redis_sample_app, redis_service_instance_dedicated_vm)	
            if not dedicated_vm_results['unbind_service']:	
                print('unbind_service failed for dedicated-vm plan')	
        except Exception as e:
            print(str(e))
            result = False

        try:
            dedicated_vm_results['delete_service_key'] = common_tests.delete_service_key(redis_service_instance_dedicated_vm, redis_service_key_dedicated_vm)	
            if not dedicated_vm_results['delete_service_key']:	
                print('delete_service_key failed for dedicated-vm plan')	
        except Exception as e:
            print(str(e))
            result = False

        try:
            dedicated_vm_results['delete_app'] = common_tests.delete_app(redis_sample_app)	
            if not dedicated_vm_results['delete_app']:	
                print('delete_app failed for dedicated-vm plan')	
        except Exception as e:
            print(str(e))
            result = False

        try:
            dedicated_vm_results['delete_service'] = common_tests.delete_service(redis_service_instance_dedicated_vm)	
            if not dedicated_vm_results['delete_service']:	
                print('delete_service failed for dedicated-vm plan')	
        except Exception as e:	
            print(str(e))	
            result = False	

    return dedicated_vm_results, result