Пример #1
0
def test(server_node, client_node):
    print client_node, "->", server_node
    server_pod_name = "server-" + "-".join(server_node.split("."))
    PodBuilder(server_pod_name, namespace).add_container(
        name=server_pod_name + "-container",
        image=image,
        args=server_args,
        limits=glimit,
        requests=grequest,
        ports=[
            server_port
        ]).set_node(server_node).attache_service(server_service).deploy()
    # wait for server pod running
    wait_for_pod_state(namespace,
                       server_pod_name,
                       timeout=600,
                       expect_status=RUNNING)
    time.sleep(3)
    # get server pod ip
    server_pod_ip = get_pod_ip(namespace, server_pod_name)
    run_client(client_node, server_node, server_pod_ip)
    run_client(client_node, server_node, global_server_name)
    delete_pod(namespace, server_pod_name)
    wait_for_pod_state(namespace,
                       server_pod_name,
                       timeout=240,
                       expect_status=NOT_FOUND)
Пример #2
0
def run_server(server_node):
    server_pod_name = "server-" + "-".join(server_node.split("."))
    PodBuilder(server_pod_name, namespace).add_container(
        name=server_pod_name + "-container",
        image=image,
        args=server_args,
        limits=glimit,
        requests=grequest,
        ports=[
            server_port
        ]).set_node(server_node).attache_service(server_service).deploy()
    try:
        # wait for server pod running
        wait_for_pod_state(namespace,
                           server_pod_name,
                           timeout=600,
                           expect_status=RUNNING)
        time.sleep(5)
        # get server pod ip
        server_pod_ip = get_pod_ip(namespace, server_pod_name)
        for node in nodes:
            run_client(node, server_node, server_pod_ip)
            run_client(node, server_node, global_server_name)
    except:
        pass
    finally:
        remove_pod(namespace, server_pod_name)
Пример #3
0
def run_server(server_node, client_nodes):
    server_pod_name = "server-" + "-".join(server_node.split("."))
    PodBuilder(server_pod_name, namespace).add_container(
        name=server_pod_name + "-container",
        image=image,
        args=server_args,
        limits=glimit,
        requests=grequest,
        ports=[server_port]).set_node(server_node).deploy()

    # wait for server pod running
    wait_for_pod_state(namespace,
                       server_pod_name,
                       timeout=600,
                       expect_status=RUNNING)
    time.sleep(10)
    # get server pod ip
    server_pod_ip = get_pod_ip(namespace, server_pod_name)
    client_count = 0
    for node in client_nodes:
        client_count += 1
        PodBuilder("iperf-client-%d" % client_count, namespace).add_container(
            name="iperf-client-container-%d" % client_count,
            image=image,
            args=client_args % server_pod_ip,
            limits=glimit,
            requests=grequest,
        ).set_node(node).deploy()
    for i in range(1, client_count + 1):
        wait_for_pod_state(namespace,
                           "iperf-client-%d" % i,
                           timeout=600,
                           expect_status=SUCCEEDED)
        logs = tail_pod_logs(namespace, "iperf-client-%d" % i,
                             lines=20).strip()
        print logs.split("\n")[-1]
Пример #4
0
def _get_pod_ip(pod):
    if pod in pod_ips:
        return pod_ips[pod]
    pod_ip = get_pod_ip(namespace, pod)
    pod_ips[pod] = pod_ip
    return pod_ip
Пример #5
0
def _get_pod_ip(pod):
    return get_pod_ip(namespace, pod)