Beispiel #1
0
def test_service_metrics_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    service_metrics = kiali_client.service_metrics(
        namespace=bookinfo_namespace, service=SERVICE_TO_VALIDATE).get('dest')
    assert 'metrics' in service_metrics
Beispiel #2
0
def test_workload_list_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    workload_list = kiali_client.workload_list(namespace=bookinfo_namespace)
    assert workload_list != None
    for workload in workload_list.get('workloads'):
        assert workload.get('istioSidecar') == True
Beispiel #3
0
def test_service_list_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    assert kiali_client.service_list(namespace=bookinfo_namespace).get(
        'namespace').get('name') == bookinfo_namespace
    assert (len(
        kiali_client.service_list(namespace=bookinfo_namespace).get('services')
    ) == BOOKINFO_EXPECTED_SERVICES), "Unexpected number of services"
Beispiel #4
0
def test_service_validations_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    assert kiali_client.service_validations(
        namespace=bookinfo_namespace, service=SERVICE_TO_VALIDATE) != None
    assert len(
        kiali_client.service_validations(
            namespace=bookinfo_namespace,
            service=SERVICE_TO_VALIDATE).get('pod')) > 0
Beispiel #5
0
def test_application_list_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    app_list = kiali_client.app_list(namespace=bookinfo_namespace)
    assert app_list != None
    for app in app_list.get('applications'):
        assert app.get('istioSidecar') == True

    assert app_list.get('namespace').get('name') == bookinfo_namespace
Beispiel #6
0
def test_service_health_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    service_health = kiali_client.service_health(namespace=bookinfo_namespace,
                                                 service=SERVICE_TO_VALIDATE)
    assert service_health != None
    envoy = service_health.get('envoy')
    assert envoy != None
    assert 'inbound' in envoy
    assert 'outbound' in envoy
Beispiel #7
0
def test_service_detail_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    for service in kiali_client.service_list(
            namespace=bookinfo_namespace).get('services'):
        service_details = kiali_client.service_details(
            namespace=bookinfo_namespace, service=service.get('name'))
        assert service_details != None
        assert service_details.get('istioSidecar') == True
        assert 'workloads' in service_details
        assert 'service' in service_details
Beispiel #8
0
def test_application_details_endpoint(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    app_details = kiali_client.app_details(namespace=bookinfo_namespace,
                                           app=APPLICATION_TO_VALIDATE)

    assert app_details != None
    assert app_details.get('namespace').get('name') == bookinfo_namespace
    assert 'workloads' in app_details and (len(app_details.get('workloads')) >
                                           0)
    assert app_details.get('workloads')[0].get('istioSidecar') == True
Beispiel #9
0
def test_service_graph_bookinfo_namespace_(kiali_client):
    bookinfo_namespace = conftest.__get_environment_config__(
        conftest.ENV_FILE).get('mesh_bookinfo_namespace')

    # Validate Node count
    nodes = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                         params=PARAMS)["elements"]['nodes']
    #print ("Node count: {}".format(len(nodes)))
    assert len(nodes) >= BOOKINFO_EXPECTED_NODES

    # validate edge count
    edges = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                         params=PARAMS)["elements"]['edges']
    #print ("Edge count: {}".format(len(edges)))
    assert len(edges) >= BOOKINFO_EXPECTED_EDGES
def do_test(kiali_client, graph_params, yaml_file, badge):
    environment_configmap = conftest.__get_environment_config__(
        conftest.ENV_FILE)
    bookinfo_namespace = environment_configmap.get('mesh_bookinfo_namespace')

    appType = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                           params=graph_params)['graphType']
    assert appType == graph_params.get('graphType')

    count = get_badge_count(kiali_client, bookinfo_namespace, graph_params,
                            badge)

    add_command_text = "oc apply -n " + bookinfo_namespace + " -f " + os.path.abspath(
        os.path.realpath(yaml_file))
    add_command_result = os.popen(add_command_text).read()
    assert add_command_result.__contains__(
        "created") or add_command_result.__contains__("configured")

    graph = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                         params=graph_params)
    assert graph is not None

    with timeout(seconds=60, error_message='Timed out waiting for Create'):
        while True:
            new_count = get_badge_count(kiali_client, bookinfo_namespace,
                                        graph_params, badge)
            if new_count != 0 and new_count >= count:
                break

            time.sleep(1)

    delete_command_text = "oc delete -n " + bookinfo_namespace + " -f " + os.path.abspath(
        os.path.realpath(yaml_file))
    delete_command_result = os.popen(delete_command_text).read()
    assert delete_command_result.__contains__("deleted")

    with timeout(seconds=30, error_message='Timed out waiting for Delete'):
        while True:
            # Validate that JSON no longer has Virtual Service
            if get_badge_count(kiali_client, bookinfo_namespace, graph_params,
                               badge) <= count:
                break

            time.sleep(1)

    return True
def do_auth_strategy_test(auth_type):
    config = conftest.__get_environment_config__(conftest.ENV_FILE)
    swagger = config.get('kiali_swagger_address')
    hostname = config.get('kiali_hostname')

    if AUTH_NOAUTH in auth_type:
        kiali_client = KialiClient(hostname=hostname,
                                   auth_type=AUTH_NOAUTH,
                                   verify=False,
                                   swagger_address=swagger)
        response = kiali_client.request(method_name='namespaceList',
                                        path=None,
                                        params=None)

        # Make API call - expected to pass with no authentication
        assert response.status_code == 200, "Unexpected status code \'response.status_code\'"
    else:
        assert False, "To Do"

    return True
def do_test(kiali_client, graph_params, yaml_file, badge):
    environment_configmap = conftest.__get_environment_config__(
        conftest.ENV_FILE)
    bookinfo_namespace = bookinfo_namespace = conftest.get_bookinfo_namespace()

    appType = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                           params=graph_params)['graphType']
    assert appType == graph_params.get('graphType')

    count = get_badge_count(kiali_client, bookinfo_namespace, graph_params,
                            badge)

    try:
        assert command_exec.oc_apply(yaml_file, bookinfo_namespace) == True

        graph = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                             params=graph_params)
        assert graph is not None

        with timeout(seconds=30, error_message='Timed out waiting for Create'):
            while True:
                new_count = get_badge_count(kiali_client, bookinfo_namespace,
                                            graph_params, badge)
                if new_count != 0 and new_count >= count:
                    break

                time.sleep(1)

    finally:
        assert command_exec.oc_delete(yaml_file, bookinfo_namespace) == True

        with timeout(seconds=30, error_message='Timed out waiting for Delete'):
            while True:
                # Validate that JSON no longer has Virtual Service
                if get_badge_count(kiali_client, bookinfo_namespace,
                                   graph_params, badge) <= count:
                    break

                time.sleep(1)

    return True
Beispiel #13
0
def get_bookinfo_namespace():
    return conftest.__get_environment_config__(conftest.ENV_FILE).get('mesh_bookinfo_namespace')