Beispiel #1
0
def verify_iperf(tc):
    conn_timedout = 0
    control_socker_err = 0
    for idx, cmd in enumerate(tc.iperf_client_resp.commands):
        api.Logger.info("Iperf Results for %s" % (tc.cmd_descr[idx]))
        api.Logger.info("Iperf Server cmd  %s" % (tc.serverCmds[idx]))
        api.Logger.info("Iperf Client cmd %s" % (tc.clientCmds[idx]))
        if cmd.exit_code != 0:
            api.Logger.error("Iperf client exited with error")
            if iperf.ConnectionTimedout(cmd.stdout):
                api.Logger.error("Connection timeout, ignoring for now")
                conn_timedout = conn_timedout + 1
                continue
            if iperf.ControlSocketClosed(cmd.stdout):
                api.Logger.error("Control socket cloned, ignoring for now")
                control_socker_err = control_socker_err + 1
                continue
            if iperf.ServerTerminated(cmd.stdout):
                api.Logger.error("Iperf server terminated")
                return api.types.status.FAILURE
            if not iperf.Success(cmd.stdout):
                api.Logger.error("Iperf failed", iperf.Error(cmd.stdout))
                return api.types.status.FAILURE
        #api.Logger.info("Iperf Send Rate in Gbps ", iperf.GetSentGbps(cmd.stdout))
        #api.Logger.info("Iperf Receive Rate in Gbps ", iperf.GetReceivedGbps(cmd.stdout))

    api.Logger.info("Iperf test successfully")
    api.Logger.info("Number of connection timeouts : {}".format(conn_timedout))
    api.Logger.info("Number of control socket errors : {}".format(control_socker_err))
    return api.types.status.SUCCESS
Beispiel #2
0
def verify_iperf(tc):
    conn_timedout = 0
    control_socker_err = 0
    measured_send_bw = 0
    measured_received_bw = 0
    for idx, cmd in enumerate(tc.iperf_client_resp.commands):
        if cmd.exit_code != 0:
            api.Logger.error("Iperf client exited with error")
            if iperf.ConnectionTimedout(cmd.stdout):
                api.Logger.error("Connection timeout, ignoring for now")
                conn_timedout = conn_timedout + 1
                continue
            if iperf.ControlSocketClosed(cmd.stdout):
                api.Logger.error("Control socket cloned, ignoring for now")
                control_socker_err = control_socker_err + 1
                continue
            if iperf.ServerTerminated(cmd.stdout):
                api.Logger.error("Iperf server terminated")
                return api.types.status.FAILURE
            if not iperf.Success(cmd.stdout):
                api.Logger.error("Iperf failed", iperf.Error(cmd.stdout))
                return api.types.status.FAILURE
            sent_bw = iperf.GetSentGbps(cmd.stdout)
            api.Logger.info("Iperf Send Rate in Gbps ", sent_bw)
            measured_send_bw += float(sent_bw)
            received_bw = iperf.GetReceivedGbps(cmd.stdout)
            api.Logger.info("Iperf Receive Rate in Gbps ", received_bw)
            measured_received_bw += float(received_bw)

    api.Logger.info("Iperf test successfull")
    api.Logger.info("Number of connection timeouts : {}".format(conn_timedout))
    api.Logger.info("Number of control socket errors : {}".format(control_socker_err))
    api.Logger.info("Total Send BW : {}".format(measured_send_bw))
    api.Logger.info("Total Received BW : {}".format(measured_received_bw))
    return api.types.status.SUCCESS
Beispiel #3
0
def iperf_resp_verify(tc):
    conn_timedout = 0
    control_socker_err = 0
    cmd_idx = 0 
    
    for resp in tc.iperf_client_resp:
        for cmd in resp.commands:
            api.Logger.info("Iperf Results for %s" % (tc.cmd_descr[cmd_idx]))
            api.Logger.info("Iperf Server cmd  %s" % (tc.serverCmds[cmd_idx]))
            api.Logger.info("Iperf Client cmd %s" % (tc.clientCmds[cmd_idx]))
            cmd_idx += 1
            if cmd.exit_code != 0:
                api.Logger.error("Iperf client exited with error")
                if iperf.ConnectionTimedout(cmd.stdout):
                    api.Logger.error("Connection timeout, ignoring for now")
                    conn_timedout = conn_timedout + 1
                    continue
                if iperf.ControlSocketClosed(cmd.stdout):
                    api.Logger.error("Control socket cloned, ignoring for now")
                    control_socker_err = control_socker_err + 1
                    continue
                if iperf.ServerTerminated(cmd.stdout):
                    api.Logger.error("Iperf server terminated")
                    return api.types.status.FAILURE
                if not iperf.Success(cmd.stdout):
                    api.Logger.error("Iperf failed", iperf.Error(cmd.stdout))
                    return api.types.status.FAILURE

    api.Logger.info("Iperf test passed successfully")
    api.Logger.info("Number of connection timeouts : {}".format(conn_timedout))
    api.Logger.info("Number of control socket errors : {}".format(control_socker_err))

    wl_nodes = [pair[0] for pair in tc.wl_node_nic_pairs]
    node1, node2 = wl_nodes[0], wl_nodes[1]
     
    for cl_node in wl_nodes:
        # verify flows are installed
        flow, num_match_after = tc.flow_match_after[cl_node][0]
        
        if num_match_after == 0:
            api.Logger.error("For %s pkts sent from %s, flow not installed on "
                            "node1 athena nic:" % (tc.proto, cl_node))
            flow.Display()
            return api.types.status.FAILURE 

        flow, num_match_after = tc.flow_match_after[cl_node][1]
        
        if num_match_after == 0:
            api.Logger.error("For %s pkts sent from %s, flow not installed on "
                            "node2 athena nic:" % (tc.proto, cl_node))
            flow.Display()
            return api.types.status.FAILURE 
        
        for node, state, rc in tc.conntrack_state[cl_node]:
            if not rc:
                api.Logger.error("For %s, state verification failed for state %s"
                                % (node, state))
                return api.types.status.FAILURE
    
    return api.types.status.SUCCESS
Beispiel #4
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
Beispiel #5
0
def Verify(tc):
    if api.IsDryrun(): return api.types.status.SUCCESS
    if getattr(tc.args, 'capture_pcap', False):
        ret = common.stop_pcap_capture(tc)
        if ret != api.types.status.SUCCESS:
            api.Logger.info("pcap caputre failed")
            return ret

    if getattr(tc.args, 'capture_single_pcap', False):
        ret = common.stop_single_pcap_capture(tc)
        if ret != api.types.status.SUCCESS:
            api.Logger.info("single pcap caputre failed")
            return ret

    if tc.cli_resp is None:
        return api.types.status.FAILURE

    sendGbps = []
    recvGbps = []
    for cmd in tc.cli_resp.commands:

        if cmd.exit_code != 0:
            api.Logger.error("Iperf client exited with error")
            api.PrintCommandResults(cmd)
            if iperf.ConnectionTimedout(cmd.stdout):
                api.Logger.error("Connection timeout, ignoring for now")
                continue
            if iperf.ControlSocketClosed(cmd.stdout):
                api.Logger.error("Control socket cloned, ignoring for now")
                continue
            if iperf.ServerTerminated(cmd.stdout):
                api.Logger.error("Iperf server terminated")
                return api.types.status.FAILURE
            if not iperf.Success(cmd.stdout):
                api.Logger.error("Iperf failed", iperf.Error(cmd.stdout))
                return api.types.status.FAILURE
        elif not api.GlobalOptions.dryrun:
            sendGbps.append(float(iperf.GetSentGbps(cmd.stdout)))
            recvGbps.append(float(iperf.GetReceivedGbps(cmd.stdout)))
            api.Logger.info("Iperf Send Rate in Gbps ", iperf.GetSentGbps(cmd.stdout))
            api.Logger.info("Iperf Receive Rate in Gbps ", iperf.GetReceivedGbps(cmd.stdout))

    api.Logger.info("Iperf Send Rate in Gbps ", sendGbps)
    api.Logger.info("Iperf Receive Rate in Gbps ", recvGbps)
    api.Logger.info("iperf test successfull total send Gbps ", sum(sendGbps), " receive Gbps ", sum(recvGbps))

    return verify.driver_feature_verify(tc)
Beispiel #6
0
def verify_iperf(tc):
    """
    Verifies iperf command output
    Handles exceptions
    Returns Success/Failure
    """
    api.Logger.info("Verifying iperf command")
    conn_timedout = 0
    control_socker_err = 0
    for idx, cmd in enumerate(tc.iperf_client_resp.commands):
        api.Logger.info(tc.cmd_descr[idx])
        api.Logger.info("Server cmd %s" % (tc.server_cmds[idx]))
        api.Logger.info("Client cmd %s" % (tc.client_cmds[idx]))
        if cmd.exit_code != 0:
            api.Logger.error(f"Iperf client exited with error. Stderr: {cmd.stderr}. Stdout: {cmd.stdout}")
            if iperf.ConnectionTimedout(cmd.stdout):
                api.Logger.error("Connection timeout, ignoring for now")
                conn_timedout = conn_timedout + 1
                continue
            if iperf.ControlSocketClosed(cmd.stdout):
                api.Logger.error("Control socket cloned, ignoring for now")
                control_socker_err = control_socker_err + 1
                continue
            if iperf.ServerTerminated(cmd.stdout):
                api.Logger.error("Iperf server terminated")
                return api.types.status.FAILURE
            if not iperf.Success(cmd.stdout):
                api.Logger.error("Iperf failed", iperf.Error(cmd.stdout))
                return api.types.status.FAILURE

    if conn_timedout > 0:
        api.Logger.info("Number of connection timeouts : {}".format(conn_timedout))
    if control_socker_err > 0:
        api.Logger.info("Number of control socket errors : {}".format(control_socker_err))

    return api.types.status.SUCCESS
Beispiel #7
0
def verifyIPerf(cmd_cookies,
                response,
                exit_code=0,
                min_bw=0,
                max_bw=0,
                server_rsp=False):
    result = api.types.status.SUCCESS
    conn_timedout = 0
    control_socker_err = 0
    cmdDesc = cmd_cookies[0]
    serverCmds = cmd_cookies[1]
    clientCmds = cmd_cookies[2]
    for idx, cmd in enumerate(response.commands):
        api.Logger.debug("Iperf Result for %s" % (cmdDesc[idx]))
        api.Logger.debug("Iperf Server cmd %s" % (serverCmds[idx]))
        api.Logger.debug("Iperf Client cmd %s" % (clientCmds[idx]))
        # for server logs we need to remove the last summary data. otherwise
        # json parser fails
        if server_rsp:
            try:
                off = re.search('\n{', cmd.stdout).start()
                cmd.stdout = cmd.stdout[0:off + 1]
            except:
                pass
        if cmd.exit_code != exit_code:
            api.Logger.error("Iperf client exited with error")
            api.PrintCommandResults(cmd)
            if iperf.ConnectionTimedout(cmd.stdout):
                api.Logger.error("Connection timeout, ignoring for now")
                conn_timedout = conn_timedout + 1
                continue
            if iperf.ControlSocketClosed(cmd.stdout):
                api.Logger.error("Control socket cloned, ignoring for now")
                control_socker_err = control_socker_err + 1
                continue
            if iperf.ServerTerminated(cmd.stdout):
                api.Logger.error("Iperf server terminated")
                result = api.types.status.FAILURE
            if not iperf.Success(cmd.stdout):
                api.Logger.error("Iperf failed", iperf.Error(cmd.stdout))
                result = api.types.status.FAILURE
        elif not api.GlobalOptions.dryrun:
            tx_bw = iperf.GetSentMbps(cmd.stdout)
            rx_bw = iperf.GetReceivedMbps(cmd.stdout)
            rx_pps = iperf.GetReceivedPPS(cmd.stdout)

            api.Logger.info(f"Iperf Send Rate {tx_bw} Mbps")
            api.Logger.info(f"Iperf Receive Rate {rx_bw} Mbps ")
            api.Logger.info(f"Iperf Receive Rate {rx_pps} Packets/sec ")
            api.Logger.debug(
                f"Expected Rate min:{min_bw} Mbps max:{max_bw} Mbps")
            if min_bw:
                if float(tx_bw) < float(min_bw) or float(rx_bw) < float(
                        min_bw):
                    api.Logger.error(
                        f"Iperf min bw not met tx:{tx_bw} rx:{rx_bw} min:{min_bw}"
                    )
                    return api.types.status.FAILURE
            if max_bw:
                if float(rx_bw) > float(max_bw):
                    api.Logger.error(
                        f"Iperf max bw not met tx:{tx_bw} rx:{rx_bw} max:{max_bw}"
                    )
                    return api.types.status.FAILURE

    api.Logger.info("Iperf test successful")
    api.Logger.info("Number of connection timeouts : {}".format(conn_timedout))
    api.Logger.info(
        "Number of control socket errors : {}".format(control_socker_err))
    return result
Beispiel #8
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