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
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
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
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)
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
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