Esempio n. 1
0
def test_kiali_circuit_breakers(kiali_client):
    environment_configmap = conftest.__get_environment_config__(conftest.ENV_FILE)
    bookinfo_namespace = environment_configmap.get('mesh_bookinfo_namespace')
    circuit_breaker_configmap = conftest.__get_environment_config__(conftest.CIRCUIT_BREAKER_FILE)

    cb_count = get_cb_count(kiali_client, bookinfo_namespace)
    add_command_text = "oc apply -n " + environment_configmap.get('mesh_bookinfo_namespace') + " -f " + os.path.abspath(os.path.realpath(conftest.CIRCUIT_BREAKER_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=environment_configmap.get('mesh_bookinfo_namespace'), params=PARAMS)
    assert graph is not None

    with timeout(seconds=60, error_message='Timed out waiting for Circuit Breaker to be Created'):
        while True:
            if get_cb_count(kiali_client, bookinfo_namespace) > cb_count:
                break

    time.sleep(1)

    delete_command_text = "oc delete destinationrule " + circuit_breaker_configmap['metadata']['name'] + " -n " +  environment_configmap.get('mesh_bookinfo_namespace')
    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 VirtualService to be Deleted'):
        while True:
            # Validate that JSON no longer has Virtual Service
            if get_cb_count(kiali_client, bookinfo_namespace) <= cb_count:
                break

            time.sleep(1)
Esempio n. 2
0
def test_kiali_circuit_breakers(kiali_client):
    environment_configmap = conftest.__get_environment_config__(conftest.ENV_FILE)
    circuit_breaker_configmap = conftest.__get_environment_config__(conftest.CIRCUIT_BREAKER_FILE)

    add_command_text = "oc apply -n " + environment_configmap.get('mesh_bookinfo_namespace') + " -f " + os.path.abspath(os.path.realpath(conftest.CIRCUIT_BREAKER_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=environment_configmap.get('mesh_bookinfo_namespace'), params=PARAMS)

    assert graph is not None

    nodes = kiali_client.graph_namespace(namespace=environment_configmap.get('mesh_bookinfo_namespace'), params=PARAMS)["elements"]['nodes']

    assert nodes is not None

    circuit_breaker = 0
    for node in nodes:
        if 'hasCB' in node["data"] and  node["data"]["hasCB"] == "true":
            circuit_breaker = circuit_breaker +1

    assert circuit_breaker is 1

    delete_command_text = "oc delete destinationpolicies " + circuit_breaker_configmap['metadata']['name'] + " -n " +  environment_configmap.get('mesh_bookinfo_namespace')

    delete_command_result = os.popen(delete_command_text).read()

    assert delete_command_result.__contains__("deleted")
def test_kiali_route_rules(kiali_client):
    environment_configmap = conftest.__get_environment_config__(conftest.ENV_FILE)
    route_rule_configmap = conftest.__get_environment_config__(conftest.ROUTE_RULE_FILE)

    add_command_text = "oc apply -n " + environment_configmap.get('mesh_bookinfo_namespace') + " -f " + os.path.abspath(os.path.realpath(conftest.ROUTE_RULE_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=environment_configmap.get('mesh_bookinfo_namespace'), params=PARAMS)

    assert graph is not None

    nodes = kiali_client.graph_namespace(namespace=environment_configmap.get('mesh_bookinfo_namespace'), params=PARAMS)["elements"]['nodes']

    assert nodes is not None

    #route_rule_count = get_route_rule_count(kiali_client, environment_configmap)

    assert get_route_rule_count(kiali_client, environment_configmap) > 0

    delete_command_text = "oc delete routerule " + route_rule_configmap['metadata']['name'] + " -n " +  environment_configmap.get('mesh_bookinfo_namespace')

    delete_command_result = os.popen(delete_command_text).read()

    assert delete_command_result.__contains__("deleted")

    time.sleep(10)

    # Validate that JSON no longer has Route Rules
    assert get_route_rule_count(kiali_client, environment_configmap) == 0
def test_service_graph_bookinfo_namespace_(kiali_client):
    environment_configmap = conftest.__get_environment_config__(
        conftest.ENV_FILE)
    bookinfo_namespace = environment_configmap.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
Esempio n. 5
0
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 test_kiali_virtual_service(kiali_client):
    environment_configmap = conftest.__get_environment_config__(
        conftest.ENV_FILE)
    bookinfo_namespace = environment_configmap.get('mesh_bookinfo_namespace')
    vs_count = get_vs_count(kiali_client, bookinfo_namespace)

    add_command_text = "oc apply -n " + bookinfo_namespace + " -f " + os.path.abspath(
        os.path.realpath(conftest.VIRTUAL_SERVICE_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=PARAMS)
    assert graph is not None

    nodes = kiali_client.graph_namespace(namespace=bookinfo_namespace,
                                         params=PARAMS)["elements"]['nodes']
    assert nodes is not None

    with timeout(
            seconds=30,
            error_message='Timed out waiting for VirtualService to be Created'
    ):
        while True:
            if get_vs_count(kiali_client, bookinfo_namespace) > vs_count:
                break

            time.sleep(1)

    delete_command_text = "oc delete -n {} -f {}".format(
        bookinfo_namespace, conftest.VIRTUAL_SERVICE_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 VirtualService to be Deleted'
    ):
        while True:
            # Validate that JSON no longer has Virtual Service
            if get_vs_count(kiali_client, bookinfo_namespace) <= vs_count:
                break

            time.sleep(1)