Ejemplo n.º 1
0
def Trigger(tc):
    if tc.skip: return api.types.status.SUCCESS

    tc.serverCmds = []
    tc.clientCmds = []
    tc.cmd_descr = []

    if not api.IsSimulation():
        serverReq = api.Trigger_CreateAllParallelCommandsRequest()
        clientReq = api.Trigger_CreateAllParallelCommandsRequest()
    else:
        serverReq = api.Trigger_CreateExecuteCommandsRequest(serial = False)
        clientReq = api.Trigger_CreateExecuteCommandsRequest(serial = False)

    for idx, pairs in enumerate(tc.workload_pairs):
        client = pairs[0]
        server = pairs[1]

        cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                       (server.workload_name, server.ip_address, client.workload_name, client.ip_address)
        tc.cmd_descr.append(cmd_descr)
        num_sessions = int(getattr(tc.args, "num_sessions", 1))
        api.Logger.info("Starting Iperf test from %s num-sessions %d" % (cmd_descr, num_sessions))

        if tc.iterators.proto == 'udp':
            port = api.AllocateTcpPort()
            serverCmd = iperf.ServerCmd(port)
            clientCmd = iperf.ClientCmd(server.ip_address, port, proto='udp', jsonOut=True, num_of_streams = num_sessions)
        else:
            port = api.AllocateUdpPort()
            serverCmd = iperf.ServerCmd(port)
            clientCmd = iperf.ClientCmd(server.ip_address, port, jsonOut=True,  num_of_streams = num_sessions)

        tc.serverCmds.append(serverCmd)
        tc.clientCmds.append(clientCmd)

        api.Trigger_AddCommand(serverReq, server.node_name, server.workload_name,
                               serverCmd, background = True)

        api.Trigger_AddCommand(clientReq, client.node_name, client.workload_name,
                               clientCmd)

    server_resp = api.Trigger(serverReq)
    #Sleep for some time as bg may not have been started.
    time.sleep(30)

    tc.iperf_client_resp = api.Trigger(clientReq)
    #Its faster kill iperf servers

    #Still call terminate on all
    api.Trigger_TerminateAllCommands(server_resp)

    return api.types.status.SUCCESS
Ejemplo n.º 2
0
def Trigger(tc):
    # check that there have been packets showing up after previous tests
    #       ip -s link show <pf>

    rate = tc.iterators.rate
    duration = 30
    if __SetAndCheckRate(tc.host1, tc.pf_1, tc.vfid,
                         rate) != api.types.status.SUCCESS:
        return api.types.status.ERROR

    servercmd = iperf.ServerCmd(server_ip=tc.remote_ip, port=7777, run_core=2)
    clientcmd = iperf.ClientCmd(tc.remote_ip,
                                client_ip=tc.vf_ip,
                                jsonOut=True,
                                port=7777,
                                proto='tcp',
                                time=duration,
                                run_core=2)

    sreq = api.Trigger_CreateExecuteCommandsRequest(serial=True)
    creq = api.Trigger_CreateExecuteCommandsRequest(serial=True)

    api.Trigger_AddHostCommand(sreq, tc.host2, servercmd, background=True)
    api.Trigger_AddHostCommand(creq, tc.host1, clientcmd, timeout=3600)

    server_resp = api.Trigger(sreq)
    if not server_resp:
        api.Logger.error("Unable to execute server command")
        return api.types.status.ERROR
    time.sleep(5)

    client_resp = api.Trigger(creq)
    if not client_resp:
        api.Logger.error("Unable to execute client command")
        return api.types.status.ERROR
    resp = client_resp.commands.pop()
    if resp.exit_code != 0:
        api.Logger.error("Iperf client failed with exit code %d" %
                         resp.exit_code)
        api.PrintCommandResults(resp)
        return api.types.status.ERROR
    if not iperf.Success(resp.stdout):
        api.Logger.error("Iperf failed with error: %s" %
                         iperf.Error(resp.stdout))
        return api.types.status.ERROR

    api.Logger.info("Obs rate %sMbps" % iperf.GetSentMbps(resp.stdout))
    obs_rate = float(iperf.GetSentMbps(resp.stdout))

    delta = (abs(obs_rate - rate) * 100) / rate

    if delta > 10:
        api.Logger.error("Configured Tx rate %f but observed %f delta %f%%" %
                         (rate, obs_rate, delta))
        return api.types.status.FAILURE

    api.Trigger_TerminateAllCommands(server_resp)

    return api.types.status.SUCCESS
Ejemplo n.º 3
0
def Trigger(tc):
    if api.IsDryrun(): return api.types.status.SUCCESS

    srv = tc.workloads[0]
    cli = tc.workloads[1]
    
    # Determine where the commands will be run - host or Naples.
    test_type = getattr(tc.args, "test-type", INTF_TEST_TYPE_HOST)
    is_naples_cmd = True
    if test_type == INTF_TEST_TYPE_HOST:
        is_naples_cmd = False

    srv_req = api.Trigger_CreateExecuteCommandsRequest(serial = False)
    cli_req = api.Trigger_CreateExecuteCommandsRequest(serial = False)

    proto = getattr(tc.iterators, "proto", 'tcp')
    number_of_iperf_threads = getattr(tc.args, "iperfthreads", 1)
    pktsize = getattr(tc.iterators, "pktsize", None)
    ipproto = getattr(tc.iterators, "ipproto", 'v4')

    if ipproto == 'v4':
        server_ip = srv.ip_address
        client_ip = cli.ip_address
    else:
        server_ip = srv.ipv6_address
        client_ip = cli.ipv6_address
        
    tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                   (srv.interface, server_ip, cli.interface, client_ip)

    api.Logger.info("Starting Iperf(%s/%s) test from %s"
                    % (proto, ipproto, tc.cmd_descr))

    duration =  10
    for i in range(number_of_iperf_threads):
        if proto == 'tcp':
            port = api.AllocateTcpPort()
        else:
            port = api.AllocateUdpPort()
 
        iperf_server_cmd = iperf.ServerCmd(port, naples = is_naples_cmd)
        api.Trigger_AddCommand(srv_req, srv.node_name, srv.workload_name, iperf_server_cmd, background = True)

        iperf_client_cmd = iperf.ClientCmd(server_ip, port, time=duration,
                                 proto=proto, jsonOut=True, ipproto=ipproto,
                                 pktsize=pktsize, client_ip=client_ip, naples = is_naples_cmd)
        api.Trigger_AddCommand(cli_req, cli.node_name, cli.workload_name, iperf_client_cmd, timeout = 60)

    srv_resp = api.Trigger(srv_req)
    # Wait for iperf server to start.
    time.sleep(10)
    tc.cli_resp = api.Trigger(cli_req)
    # Wait for iperf clients to finish.
    time.sleep(2*duration)

    srv_resp1 = api.Trigger_TerminateAllCommands(srv_resp)

    return api.types.status.SUCCESS
Ejemplo n.º 4
0
def send_iperf_cmd(tc, client_port, server_port, test_packet_count):
    """
    send iperf to the receiving node
    use specific client/server ports to sensure packets land in the desired queue
    """
    server_req = None
    client_req = None

    server_req = api.Trigger_CreateExecuteCommandsRequest(serial=False)
    client_req = api.Trigger_CreateExecuteCommandsRequest(serial=True)

    cmd_descr = f"Server: [({tc.server.workload_name})({tc.server_ip})] <--> Client: [({tc.client.workload_name})({tc.client_ip})]"
    tc.cmd_descr.append(cmd_descr)

    server_cmd = None
    client_cmd = None

    duration = 10
    server_cmd = iperf.ServerCmd(server_port)
    client_cmd = iperf.ClientCmd(tc.server_ip, server_port, time=duration, proto=tc.proto, jsonOut=True,\
                                ipproto=tc.tc_ip_proto, num_of_streams=tc.num_sessions,\
                                client_ip=tc.client_ip, client_port=client_port, packet_count=test_packet_count,\
                                bandwidth='10m')

    tc.server_cmds.append(server_cmd)
    tc.client_cmds.append(client_cmd)
    api.Logger.info(f"Iperf:  Server [{tc.server.node_name}.{tc.server.interface}]")
    api.Logger.info(f"        Client [{tc.client.node_name}.{tc.client.interface}]")

    api.Trigger_AddCommand(server_req, tc.server.node_name, tc.server.workload_name,
                           server_cmd, background=True)

    api.Trigger_AddCommand(client_req, tc.client.node_name, tc.client.workload_name,
                           client_cmd, background=False, timeout=400)

    api.Logger.info("Start Server")
    server_resp = api.Trigger(server_req)
    #Sleep for some time as bg may not have been started.
    time.sleep(10)

    api.Logger.info("Start Client")
    tc.iperf_client_resp = api.Trigger(client_req)

    api.Logger.info("Client Returned. Terminate Server")
    api.Trigger_TerminateAllCommands(server_resp)

    return api.types.status.SUCCESS
Ejemplo n.º 5
0
def Trigger(tc):

    store = tc.GetBundleStore()
    clientReq = api.Trigger_CreateAllParallelCommandsRequest()
    num_sessions = int(getattr(tc.args, "num_sessions", 1))
    for client in store["client_ctxts"]:
        clientCmd = iperf.ClientCmd(client.server_ip, client.server_port,
                proto=tc.iterators.proto, jsonOut=True,
                num_of_streams = num_sessions, connect_timeout = 15000)
        api.Trigger_AddCommand(clientReq, client.node_name, client.workload_name,
                               clientCmd, timeout = 0,
                               stdout_on_err = True, stderr_on_err = True)


    tc.iperf_client_resp = api.Trigger(clientReq)

    return api.types.status.SUCCESS
Ejemplo n.º 6
0
def SendTraffic(tc):
    req = api.Trigger_CreateExecuteCommandsRequest(serial=True)
    tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" % (
        tc.intf1.Name(), tc.intf1.GetIP(), tc.intf2.Name(), tc.intf2.GetIP())
    api.Logger.info("Starting Iperf  from %s" % (tc.cmd_descr))

    port = api.AllocateTcpPort()
    iperf_server_cmd = iperf.ServerCmd(port=port)
    tc.intf1.AddCommand(req, iperf_server_cmd, background=True)
    iperf_client_cmd = iperf.ClientCmd(server_ip=tc.intf1.GetIP(), port=port,
                                       proto='tcp', pktsize=512, ipproto='v4')
    tc.intf2.AddCommand(req, iperf_client_cmd)

    trig_resp = api.Trigger(req)
    term_resp = api.Trigger_TerminateAllCommands(trig_resp)

    tc.resp = api.Trigger_AggregateCommandsResponse(trig_resp, term_resp)
    return api.types.status.SUCCESS
Ejemplo n.º 7
0
def iperfWorkloads(workload_pairs,
                   af="ipv4",
                   proto="tcp",
                   packet_size=64,
                   bandwidth="100G",
                   time=1,
                   num_of_streams=None,
                   sleep_time=30,
                   background=False):
    serverCmds = []
    clientCmds = []
    cmdDesc = []
    ipproto = __get_ipproto(af)

    if not api.IsSimulation():
        serverReq = api.Trigger_CreateAllParallelCommandsRequest()
        clientReq = api.Trigger_CreateAllParallelCommandsRequest()
    else:
        serverReq = api.Trigger_CreateExecuteCommandsRequest(serial=False)
        clientReq = api.Trigger_CreateExecuteCommandsRequest(serial=False)

    for idx, pairs in enumerate(workload_pairs):
        client = pairs[0]
        server = pairs[1]
        server_addr = __get_workload_address(server, af)
        client_addr = __get_workload_address(client, af)
        if proto == 'udp':
            port = api.AllocateUdpPort()
            if port == 6081:
                port = api.AllocateUdpPort()
        else:
            port = api.AllocateTcpPort()

        serverCmd = iperf.ServerCmd(port, jsonOut=True)
        clientCmd = iperf.ClientCmd(server_addr,
                                    port,
                                    time,
                                    packet_size,
                                    proto,
                                    None,
                                    ipproto,
                                    bandwidth,
                                    num_of_streams,
                                    jsonOut=True)

        cmd_cookie = "Server: %s(%s:%s:%d) <--> Client: %s(%s)" %\
                     (server.workload_name, server_addr, proto, port,\
                      client.workload_name, client_addr)
        api.Logger.info("Starting Iperf test %s" % cmd_cookie)
        serverCmds.append(serverCmd)
        clientCmds.append(clientCmd)
        cmdDesc.append(cmd_cookie)

        api.Trigger_AddCommand(serverReq,
                               server.node_name,
                               server.workload_name,
                               serverCmd,
                               background=True)
        api.Trigger_AddCommand(clientReq,
                               client.node_name,
                               client.workload_name,
                               clientCmd,
                               background=background)

    server_resp = api.Trigger(serverReq)
    #Sleep for some time as bg may not have been started.
    api.Logger.info(
        f"Waiting {sleep_time} sec to start iperf server in background")
    __sleep(sleep_time)
    client_resp = api.Trigger(clientReq)
    __sleep(3)

    if background:
        return [cmdDesc, serverCmds, clientCmds], server_resp, client_resp
    else:
        api.Trigger_TerminateAllCommands(server_resp)
        return [cmdDesc, serverCmds, clientCmds], client_resp
Ejemplo n.º 8
0
def Trigger(tc):
    serverCmd = None
    clientCmd = None
    IPERF_TIMEOUT = 86400
    try:
        serverReq = api.Trigger_CreateExecuteCommandsRequest()
        clientReq = api.Trigger_CreateExecuteCommandsRequest()

        client = tc.wl_pair[0]
        server = tc.wl_pair[1]

        tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                       (server.workload_name, server.ip_address,
                        client.workload_name, client.ip_address)
        num_streams = int(getattr(tc.args, "num_streams", 2))
        api.Logger.info("Starting Iperf test from %s num-sessions %d" %
                        (tc.cmd_descr, num_streams))

        if tc.iterators.proto == 'tcp':
            port = api.AllocateTcpPort()
            serverCmd = iperf.ServerCmd(port, jsonOut=True, run_core=3)
            clientCmd = iperf.ClientCmd(server.ip_address,
                                        port,
                                        time=IPERF_TIMEOUT,
                                        jsonOut=True,
                                        num_of_streams=num_streams,
                                        run_core=3)
        else:
            port = api.AllocateUdpPort()
            serverCmd = iperf.ServerCmd(port, jsonOut=True, run_core=3)
            clientCmd = iperf.ClientCmd(server.ip_address,
                                        port,
                                        proto='udp',
                                        jsonOut=True,
                                        num_of_streams=num_streams,
                                        run_core=3)

        tc.serverCmd = serverCmd
        tc.clientCmd = clientCmd

        api.Trigger_AddCommand(serverReq,
                               server.node_name,
                               server.workload_name,
                               serverCmd,
                               background=True,
                               timeout=IPERF_TIMEOUT)

        api.Trigger_AddCommand(clientReq,
                               client.node_name,
                               client.workload_name,
                               clientCmd,
                               background=True,
                               timeout=IPERF_TIMEOUT)

        tc.server_resp = api.Trigger(serverReq)
        time.sleep(5)
        tc.iperf_client_resp = api.Trigger(clientReq)

        _run_vmedia_traffic(tc.node_name)
    except:
        api.Logger.error(traceback.format_exc())
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 9
0
def Trigger(tc):
    max_pings = int(getattr(tc.args, "max_pings", 60))
    num_runs = int(getattr(tc.args, "num_runs", 1))
    serverCmd = None
    clientCmd = None
    mode = tc.initial_mode
    IPERF_TIMEOUT = 86400
    try:
        serverReq = api.Trigger_CreateExecuteCommandsRequest()
        clientReq = api.Trigger_CreateExecuteCommandsRequest()
        
        client = tc.wl_pair[0]
        server = tc.wl_pair[1]

        tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                       (server.workload_name, server.ip_address,
                        client.workload_name, client.ip_address)
        num_streams = int(getattr(tc.args, "num_streams", 2))
        api.Logger.info("Starting Iperf test from %s num-sessions %d"
                        % (tc.cmd_descr, num_streams))

        if tc.iterators.proto == 'tcp':
            port = api.AllocateTcpPort()
            serverCmd = iperf.ServerCmd(port, jsonOut=True, run_core=3)
            clientCmd = iperf.ClientCmd(server.ip_address, port, time=IPERF_TIMEOUT,
                                        jsonOut=True, num_of_streams=num_streams,
                                        run_core=3)
        else:
            port = api.AllocateUdpPort()
            serverCmd = iperf.ServerCmd(port, jsonOut=True, run_core=3)
            clientCmd = iperf.ClientCmd(server.ip_address, port, proto='udp',
                                        jsonOut=True, num_of_streams=num_streams,
                                        run_core=3)

        tc.serverCmd = serverCmd
        tc.clientCmd = clientCmd

        api.Trigger_AddCommand(serverReq, server.node_name, server.workload_name,
                               serverCmd, background=True, timeout=IPERF_TIMEOUT)

        api.Trigger_AddCommand(clientReq, client.node_name, client.workload_name,
                               clientCmd, background=True, timeout=IPERF_TIMEOUT)
        
        tc.server_resp = api.Trigger(serverReq)
        time.sleep(5)
        tc.iperf_client_resp = api.Trigger(clientReq)

        for _i in range(num_runs):
            RF = get_redfish_obj(tc.cimc_info, mode=mode)
            obs_mode = get_nic_mode(RF)
            api.Logger.info("Iteration %d: curr_mode %s" % (_i, obs_mode))
            if mode != obs_mode:
                raise RuntimeError("Expected NIC mode %s, observed %s" % (mode, obs_mode))

            next_mode = "dedicated" if mode == "ncsi" else "ncsi"
            if next_mode == "ncsi":
                ret = set_ncsi_mode(RF, mode="dhcp")
            else:
                ret = set_dedicated_mode(RF, mode="dhcp")
            if ret != api.types.status.SUCCESS:
                api.Logger.error("Mode switch from %s -> %s failed" %(mode, next_mode))
                return api.types.status.FAILURE

            api.Logger.info("Switched mode to %s" % (next_mode))
            time.sleep(5)
            if ret == api.types.status.SUCCESS:
                curr_ilo_ip = tc.ilo_ip if next_mode == "dedicated" else tc.ilo_ncsi_ip
                ret = ping(curr_ilo_ip, max_pings)
                if ret != api.types.status.SUCCESS:
                    RF.logout()
                    raise RuntimeError('Unable to ping ILO, Port Switch fail from'
                                      ' %s -> %s' % (mode, next_mode))
                api.Logger.info("Mode switch from %s -> %s successful" % (mode, next_mode))
            else:
                raise RuntimeError('Mode switch config failed')
            mode = next_mode
    except:
        api.Logger.error(traceback.format_exc())
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 10
0
def Trigger(tc):
    # check that there have been packets showing up after previous tests
    #       ip -s link show <pf>

    packet_count = 1000
    mode = tc.iterators.mode
    if mode == "RX":
        pkt_cnt_before = GetVFRxStats(tc.host1, tc.pf_1, tc.vfid)
    else:
        pkt_cnt_before = GetVFTxStats(tc.host1, tc.pf_1, tc.vfid)

    if pkt_cnt_before == -1:
        api.Logger.error("Getting VF %s stats failed" % mode)
        return api.types.status.ERROR

    reverse = True if mode == "RX" else False
    servercmd = iperf.ServerCmd(server_ip=tc.remote_ip, port=7777)
    clientcmd = iperf.ClientCmd(tc.remote_ip,
                                packet_count=packet_count,
                                client_ip=tc.vf_ip,
                                jsonOut=True,
                                port=7777,
                                proto='udp',
                                reverse=reverse)

    sreq = api.Trigger_CreateExecuteCommandsRequest(serial=True)
    creq = api.Trigger_CreateExecuteCommandsRequest(serial=True)

    api.Trigger_AddHostCommand(sreq, tc.host2, servercmd, background=True)
    api.Trigger_AddHostCommand(creq, tc.host1, clientcmd, timeout=30)

    server_resp = api.Trigger(sreq)
    if not server_resp:
        api.Logger.error("Unable to execute server command")
        return api.types.status.ERROR
    time.sleep(5)

    client_resp = api.Trigger(creq)
    if not client_resp:
        api.Logger.error("Unable to execute client command")
        return api.types.status.ERROR
    resp = client_resp.commands.pop()
    if resp.exit_code != 0:
        api.Logger.error("Iperf client failed with exit code %d" %
                         resp.exit_code)
        api.PrintCommandResults(resp)
        return api.types.status.ERROR
    if not iperf.Success(resp.stdout):
        api.Logger.error("Iperf failed with error: %s" %
                         iperf.Error(resp.stdout))
        return api.types.status.ERROR

    if mode == "RX":
        pkt_cnt_after = GetVFRxStats(tc.host1, tc.pf_1, tc.vfid)
    else:
        pkt_cnt_after = GetVFTxStats(tc.host1, tc.pf_1, tc.vfid)

    delta_pkt_cnt = pkt_cnt_after - pkt_cnt_before
    if packet_count > delta_pkt_cnt:
        api.Logger.error("Incorrect %s stats, expected %d observed %d" %
                         (mode, packet_count, delta_pkt_cnt))
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 11
0
def iperf_test(tc):
    
    tc.flow_hit_cnt_before = {}
    tc.flow_hit_cnt_after = {}
    tc.flow_match_before = {}
    tc.flow_match_after = {}
    tc.conntrack_state = {}

    tc.is_ct_test = False
    if tc.duration is not None and tc.stateful:
        tc.is_ct_test = True
        api.Logger.info("Start Connection Tracking e2e iPerf Test")

    wl_nodes = [pair[0] for pair in tc.wl_node_nic_pairs]
    node1, node2 = wl_nodes[0], wl_nodes[1]
    node1_ath_nic = tc.athena_node_nic_pairs[0][1]
    node2_ath_nic = tc.athena_node_nic_pairs[1][1]
    tc.node_info = {'node1': node1, 'node2': node2,
                    'node1_ath_nic': node1_ath_nic,
                    'node2_ath_nic': node2_ath_nic}

    # cl_node => client node
    for cl_node in wl_nodes:
        tc.flow_hit_cnt_before[cl_node] = []
        tc.flow_hit_cnt_after[cl_node] = []
        tc.flow_match_before[cl_node] = []
        tc.flow_match_after[cl_node] = []
        tc.conntrack_state[cl_node] = []

        sintf, dintf, smac, dmac, sip, dip = _get_client_server_info(
                                                            cl_node, tc)    
        if tc.proto == 'UDP':
            sport = api.AllocateUdpPort()
            dport = api.AllocateUdpPort()
        else:
            sport = api.AllocateTcpPort()
            dport = api.AllocateTcpPort()

        flow_n1, flow_n2 = _get_bitw_flows(cl_node, tc.proto, sip, dip, 
                                            sport = sport, dport = dport)

        def _get_flow_match_info(flow_match_dict):
            for node, nic, vnic_id, flow in [
                    (node1, node1_ath_nic, tc.node1_vnic_id, flow_n1),
                    (node2, node2_ath_nic, tc.node2_vnic_id, flow_n2)]:
                
                rc, num_match_ent = utils.match_dynamic_flows(node, vnic_id, 
                                                                flow, nic)
                if rc != api.types.status.SUCCESS:
                    return rc
                
                flow_match_dict[cl_node].append((flow, num_match_ent))

            return (api.types.status.SUCCESS)        

        
        # check if flow installed on both athena nics before sending traffic
        rc = _get_flow_match_info(tc.flow_match_before) 
        if rc != api.types.status.SUCCESS:
            return rc

        # Send iperf traffic 
        if cl_node == 'node1':
            client_wl = tc.wl[0]
            server_wl = tc.wl[1]
        else:
            client_wl = tc.wl[1]
            server_wl = tc.wl[0]

        cmd_descr = "Client %s(%s) <--> Server %s(%s)" % (sip, sintf, 
                                                        dip, dintf)
        tc.cmd_descr.append(cmd_descr)
        api.Logger.info("Starting Iperf test: %s" % cmd_descr)
        
        serverCmd = iperf.ServerCmd(dport, server_ip = dip)
        
        if tc.proto == 'UDP':
            clientCmd = iperf.ClientCmd(dip, dport, proto = 'udp',
                                        jsonOut = True, client_ip = sip,
                                        client_port = sport, 
                                        pktsize = tc.pyld_size,
                                        packet_count = tc.pkt_cnt)
        else:
            if tc.is_ct_test:
                clientCmd = iperf.ClientCmd(dip, dport, jsonOut = True,
                                            client_ip = sip, client_port = sport,
                                            pktsize = tc.pyld_size,
                                            time = tc.duration)
            else:
                clientCmd = iperf.ClientCmd(dip, dport, jsonOut = True,
                                            client_ip = sip, client_port = sport,
                                            pktsize = tc.pyld_size,
                                            packet_count = tc.pkt_cnt)

        tc.serverCmds.append(serverCmd)
        tc.clientCmds.append(clientCmd)

        serverReq = api.Trigger_CreateExecuteCommandsRequest()
        clientReq = api.Trigger_CreateExecuteCommandsRequest()
        
        api.Trigger_AddCommand(serverReq, server_wl.node_name, 
                                server_wl.workload_name, serverCmd, 
                                background = True)

        api.Trigger_AddCommand(clientReq, client_wl.node_name, 
                                client_wl.workload_name, clientCmd,
                                background = True)

        server_resp = api.Trigger(serverReq)
        # sleep for bg iperf servers to be started
        time.sleep(3)

        tc.iperf_client_resp.append(api.Trigger(clientReq))

        if tc.is_ct_test:
            iperf_ct_test(tc, cl_node, flow_n1, flow_n2)

        api.Trigger_TerminateAllCommands(server_resp)

        # check if flow installed on both athena nics after sending traffic
        rc = _get_flow_match_info(tc.flow_match_after)
        if rc != api.types.status.SUCCESS:
            return rc

    return (api.types.status.SUCCESS)
Ejemplo n.º 12
0
def __runTraffic(intf):

    api.Logger.info("Run traffic: %s" % intf)

    client = None
    server = None
    clientCmd = None
    serverCmd = None
    clientReq = None
    serverReq = None

    for pairs in api.GetRemoteWorkloadPairs():
        client = pairs[0]
        if client.workload_name.find(intf) != -1:
            server = pairs[1]
            break

    if server is None:
        api.Logger.error("No workload found for interface %s" % intf)
        return api.types.status.FAILURE

    cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\
                   (server.workload_name, server.ip_address,\
                    client.workload_name, client.ip_address)
    api.Logger.info("Starting Iperf test from %s" % cmd_descr)

    port = api.AllocateTcpPort()
    serverCmd = iperf.ServerCmd(port)
    clientCmd = iperf.ClientCmd(server.ip_address, port)

    serverReq = api.Trigger_CreateExecuteCommandsRequest(serial=False)
    api.Trigger_AddCommand(serverReq,
                           server.node_name,
                           server.workload_name,
                           serverCmd,
                           background=True)

    clientReq = api.Trigger_CreateExecuteCommandsRequest(serial=False)
    api.Trigger_AddCommand(clientReq, client.node_name, client.workload_name,
                           clientCmd)

    # Server runs in the background
    server_resp = api.Trigger(serverReq)

    # Sleep for some time as bg may not have been started.
    time.sleep(5)
    client_resp = api.Trigger(clientReq)

    # Stop the backgrounded server
    term_resp = api.Trigger_TerminateAllCommands(server_resp)

    # We don't bother checking the iperf results, we just wanted traffic
    # so just check that the commands succeeded
    ret = api.types.status.SUCCESS
    for cmd in server_resp.commands:
        if cmd.exit_code != 0:
            ret = api.types.status.FAILURE
    for cmd in client_resp.commands:
        if cmd.exit_code != 0:
            ret = api.types.status.FAILURE
    for cmd in term_resp.commands:
        if cmd.exit_code != 0:
            ret = api.types.status.FAILURE

    return ret