def setupWorkloadDict(tc, kind=None): workload_pairs = [] if kind != None: if kind == 'remote': workload_pairs = api.GetRemoteWorkloadPairs() elif kind == 'local': workload_pairs.extend(api.GetLocalWorkloadPairs()) else: workload_pairs = api.GetRemoteWorkloadPairs() workload_pairs.extend(api.GetLocalWorkloadPairs()) naples_node_name_list = api.GetNaplesHostnames() w_list = [] for w1,w2 in workload_pairs: if w1.node_name in naples_node_name_list or \ w2.node_name in naples_node_name_list: w_list.append((w1,w2)) api.Logger.info("Adding Naples workload w1: %s and w2: %s to list"% (w1.workload_name, w2.workload_name)) else: api.Logger.debug("Skipping non Naples workload w1: %s and w2: %s"% (w1.workload_name, w2.workload_name)) tc.workload_dict = workload_dict = {} for w1,w2 in w_list: l = workload_dict.get(w1, []) l.append(w2) workload_dict[w1] = l for w1, dst_workload_list in tc.workload_dict.items(): l = [w2.workload_name for w2 in dst_workload_list] api.Logger.info("%s => %s"%(w1.workload_name, ",".join(l)))
def ArPing(tc): if tc.args.type == 'local_only': api.Logger.info("local_only test") tc.workload_pairs = api.GetLocalWorkloadPairs() elif tc.args.type == 'both': api.Logger.info(" both local and remote test") tc.workload_pairs = api.GetLocalWorkloadPairs() tc.workload_pairs.extend(api.GetRemoteWorkloadPairs()) else: api.Logger.info("remote_only test") tc.workload_pairs = api.GetRemoteWorkloadPairs() if len(tc.workload_pairs) == 0: api.Logger.info("Skipping Testcase due to no workload pairs.") tc.skip = True req = None interval = "0.2" if not api.IsSimulation(): req = api.Trigger_CreateAllParallelCommandsRequest() else: req = api.Trigger_CreateExecuteCommandsRequest(serial=False) interval = "3" tc.cmd_cookies = [] for pair in tc.workload_pairs: w1 = pair[0] w2 = pair[1] cmd_cookie = "%s %s %s %s" % (w1.node_name, w1.workload_name, w1.interface, w1.ip_address) api.Trigger_AddCommand(req, w1.node_name, w1.workload_name, "arping -c 5 -U %s -I eth1" % (w1.ip_address)) api.Logger.info("ArPing from %s" % (cmd_cookie)) tc.cmd_cookies.append(cmd_cookie) cmd_cookie = "%s %s %s %s" % (w2.node_name, w2.workload_name, w2.interface, w2.ip_address) api.Trigger_AddCommand(req, w2.node_name, w2.workload_name, "arping -c 5 -U %s -I eth1" % (w2.ip_address)) api.Logger.info("ArPing from %s" % (cmd_cookie)) tc.cmd_cookies.append(cmd_cookie) tc.resp = api.Trigger(req) if tc.resp is None: return api.types.status.FAILURE result = api.types.status.SUCCESS cookie_idx = 0 for cmd in tc.resp.commands: api.Logger.info("ArPing Results for %s" % (tc.cmd_cookies[cookie_idx])) api.PrintCommandResults(cmd) if cmd.exit_code != 0: result = api.types.status.FAILURE cookie_idx += 1 return result
def Trigger(tc): if tc.skip: return api.types.status.SUCCESS status = api.types.status.SUCCESS # clean up resources before run subif_utils.clearAll() # initialize config: subif_utils.initialize_tagged_config_workloads() # Delete existing subinterfaces __delete_subifs() time.sleep(3) # Create subinterfaces for every workload/host interface # as per <subif_count> __create_subifs() time.sleep(2) tc.workload_pairs = api.GetRemoteWorkloadPairs() tc.cmd_cookies = [] req1 = api.Trigger_CreateExecuteCommandsRequest(serial = True) __run_ping_test(req1, tc) tc.resp2 = api.Trigger(req1) result = changeMacAddrTrigger(tc) time.sleep(5) api.Logger.debug("UC MAC filter : Trigger -> Change MAC addresses result ", result) api.Logger.debug("UC MAC filter : LIF reset ") # reset the LIFs if requested lif_reset = getattr(tc.args, 'lif_reset', False) if lif_reset: if do_bsd_lif_resets(): api.Logger.error("UC MAC filter : LIF reset failed") status = api.types.status.FAILURE tc.wload_ep_set, tc.host_ep_set, tc.naples_ep_set, tc.hal_ep_set = ValidateMacRegistration(tc) req = api.Trigger_CreateExecuteCommandsRequest(serial = True) tc.workload_pairs = api.GetRemoteWorkloadPairs() __run_ping_test(req, tc) tc.resp = api.Trigger(req) return status
def Trigger(tc): pairs = api.GetRemoteWorkloadPairs() mgmt_ip = api.GetNaplesMgmtIpAddresses() w1 = pairs[0][0] w2 = pairs[0][1] req = api.Trigger_CreateExecuteCommandsRequest(serial=True) tc.cmd_descr = "Node1: %s(%s) <--> Node2: %s(%s)" %\ (w1.workload_name, w1.ip_address, w2.workload_name, w2.ip_address) api.Logger.info("Starting POST check for %s" % (tc.cmd_descr)) #ignore RTC and Local temperature as of now until DavidV fix the i2c bus issue cmd = "! grep FAIL /var/log/pensando/post_report*.txt | grep -v Local | grep -v RTC" cmd1 = "grep PASS /var/log/pensando/post_report*.txt" cmd2 = "cat /var/log/pensando/post.*.log" if w1.IsNaples() or w2.IsNaples(): if w1.IsNaples(): api.Trigger_AddNaplesCommand(req, w1.node_name, cmd) api.Trigger_AddNaplesCommand(req, w1.node_name, cmd1) api.Trigger_AddNaplesCommand(req, w1.node_name, cmd2) if w2.IsNaples(): api.Trigger_AddNaplesCommand(req, w2.node_name, cmd) api.Trigger_AddNaplesCommand(req, w2.node_name, cmd1) api.Trigger_AddNaplesCommand(req, w2.node_name, cmd2) tc.resp = api.Trigger(req) else: tc.resp = None return api.types.status.SUCCESS
def Setup(tc): if tc.iterators.eptype == 'local': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() return api.types.status.SUCCESS
def Trigger(tc): pairs = api.GetRemoteWorkloadPairs() w1 = pairs[0][0] w2 = pairs[0][1] req = api.Trigger_CreateExecuteCommandsRequest(serial=True) tc.cmd_descr = "Server: %s(%s) <--> Client: %s(%s)" %\ (w1.workload_name, w1.ip_address, w2.workload_name, w2.ip_address) api.Logger.info("Starting Ping test from %s" % (tc.cmd_descr)) if w1.IsNaples() and w2.IsNaples(): api.Trigger_AddNaplesCommand( req, w1.node_name, "ifconfig bond0 20.20.20.20 netmask 255.255.255.0 up") api.SetBondIp(w1.node_name, "20.20.20.20") api.Trigger_AddNaplesCommand( req, w2.node_name, "ifconfig bond0 20.20.20.21 netmask 255.255.255.0 up") api.SetBondIp(w2.node_name, "20.20.20.21") api.Trigger_AddNaplesCommand(req, w1.node_name, "ping -I bond0 -c3 20.20.20.21") tc.resp = api.Trigger(req) else: tc.resp = None return api.types.status.SUCCESS
def memcheck(tc, count_dur=1, sleep=900): count = 0 while (count < count_dur): print(" Start of count:{}".format(count)) pairs = api.GetRemoteWorkloadPairs() req = api.Trigger_CreateExecuteCommandsRequest(serial=True) server, client = pairs[0] cmd_cookie = "cat /proc/$(pidof hal)/status | grep -i RSS" add_command(req, tc, 'hal', server, cmd_cookie, naples=True) cmd_cookie = "/nic/bin/halctl show system memory mtrack" add_command(req, tc, 'mtrack', server, cmd_cookie, naples=True) cmd_cookie = "/nic/bin/halctl show system memory slab" add_command(req, tc, 'slab', server, cmd_cookie, naples=True) cmd_cookie = "/nic/bin/halctl show system memory summary" add_command(req, tc, 'summary', server, cmd_cookie, naples=True) trig_resp = api.Trigger(req) tc.resp = trig_resp for cmd in tc.resp.commands: api.PrintCommandResults(cmd) print( "=========================================================================" ) print(" End of count:{}".format(count)) count = count + 1 time.sleep(sleep_dur) return api.types.status.SUCCESS
def Setup(tc): api.Logger.info ("Driver compat test") if api.IsDryrun(): return api.types.status.SUCCESS tc.nodes = api.GetNaplesHostnames() tc.os = api.GetNodeOs(tc.nodes[0]) tc.skip = False tc.driver_changed = False if tc.os == compat.OS_TYPE_BSD: # Not supportig BSD right now tc.skip = True return api.types.status.SUCCESS # Intention to test locally built FW with target-version driver tc.target_version = getattr(tc.iterators, 'release', 'latest') if compat.LoadDriver(tc.nodes, node_os, tc.target_version): tc.driver_changed = True if getattr(tc.args, 'type', 'local_only') == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() if len(tc.workload_pairs) == 0: api.Logger.info("Skipping ping part of testcase due to no workload pairs.") tc.skip = True return api.types.status.SUCCESS
def Setup(tc): tc.desc = ''' Test : QoS Set classification type Opcode : Config, Verify ''' tc.nodes = api.GetNaplesHostnames() tc.os = api.GetNodeOs(tc.nodes[0]) pairs = api.GetRemoteWorkloadPairs() # get workloads from each node tc.w = [] tc.w.append(pairs[0][0]) tc.w.append(pairs[0][1]) class_type = getattr(tc.args, 'class_type', None) if class_type == None: api.Logger.error("Mandatory argument class_type not passed") return api.types.status.FAILURE if int(class_type) != 1 and int(class_type) != 2: api.Logger.error( "Invalid argument class_type {} passed. Supported values are 1 (PCP) and 2 (DSCP)" .format(class_type)) return api.types.status.FAILURE tc.class_type = class_type return api.types.status.SUCCESS
def Trigger(tc): fail = 0 pairs = api.GetRemoteWorkloadPairs() hosts = pairs[0] for host in hosts: if not host.IsNaples(): continue api.Logger.info("Checking host %s" % host.node_name) lif_info = __getLifInfo(host.node_name) intfs = api.GetNaplesHostInterfaces(host.node_name) for intf in intfs: api.Logger.info("Checking interface %s" % intf) if lif_info.find(intf) == -1: api.Logger.info("interface %s not found" % intf) fail += 1 if fail != 0: return api.types.status.FAILURE return api.types.status.SUCCESS
def Setup(tc): tc.cmd_cookies = [] # Determine the client, server and the naples nodes. pairs = api.GetRemoteWorkloadPairs() tc.server, tc.client = pairs[0] # Force the naples node to be the client always till the fte bug is fixed. if not tc.client.IsNaples(): tc.client, tc.server = pairs[0] assert (tc.client.IsNaples()) tc.naples = tc.client # Create the ShmDumpHelper object global shmDumpHelper shmDumpHelper = ShmDumpHelper() # Assign the ports global server_port, client_port server_port = api.AllocateUdpPort() client_port = api.AllocateUdpPort() if server_port and client_port: api.Logger.info("Using %d as client port and %d as server port" % (client_port, server_port)) stopServer(tc) return startServer(tc)
def Trigger(tc): pairs = api.GetRemoteWorkloadPairs() mgmt_ip = api.GetNaplesMgmtIpAddresses() w1 = pairs[0][0] w2 = pairs[0][1] req = api.Trigger_CreateExecuteCommandsRequest(serial=True) tc.cmd_descr = "Node1: %s(%s) <--> Node2: %s(%s)" %\ (w1.workload_name, w1.ip_address, w2.workload_name, w2.ip_address) api.Logger.info("Starting Offline Diags for %s" % (tc.cmd_descr)) cmd1 = "LD_LIBRARY_PATH=/platform/lib:/nic/lib /nic/bin/diag_test offline &> /var/log/pensando/offline_diags_report.txt" #ignore RTC and Local temperature as of now until DavidV fix the i2c bus issue cmd2 = "! grep FAIL /var/log/pensando/offline_diags_report.txt | grep -v Local | grep -v RTC" cmd3 = "grep PASS /var/log/pensando/offline_diags_report.txt" cmd4 = "cat /var/log/pensando/offline-diags.*.log" if w1.IsNaples() or w2.IsNaples(): if w1.IsNaples(): api.Trigger_AddNaplesCommand(req, w1.node_name, cmd1) api.Trigger_AddNaplesCommand(req, w1.node_name, cmd2) api.Trigger_AddNaplesCommand(req, w1.node_name, cmd3) api.Trigger_AddNaplesCommand(req, w1.node_name, cmd4) if w2.IsNaples(): api.Trigger_AddNaplesCommand(req, w2.node_name, cmd1) api.Trigger_AddNaplesCommand(req, w2.node_name, cmd2) api.Trigger_AddNaplesCommand(req, w2.node_name, cmd3) api.Trigger_AddNaplesCommand(req, w2.node_name, cmd4) tc.resp = api.Trigger(req) else: tc.resp = None return api.types.status.SUCCESS
def Setup(tc): tc.desc = ''' Test: ibv_rc_pingpong Opcode: N/A Num QP: 1 modes: workload1 as server, workload2 as client workload2 as server, workload1 as client ''' tc.iota_path = api.GetTestsuiteAttr("driver_path") pairs = api.GetRemoteWorkloadPairs() # get workloads from each node tc.w = [] tc.w.append(pairs[0][0]) tc.w.append(pairs[0][1]) tc.devices = [] tc.gid = [] tc.ib_prefix = [] for i in range(2): tc.devices.append(api.GetTestsuiteAttr(tc.w[i].ip_address + '_device')) tc.gid.append(api.GetTestsuiteAttr(tc.w[i].ip_address + '_gid')) if tc.w[i].IsNaples(): tc.ib_prefix.append('cd ' + tc.iota_path + ' && ./run_rdma.sh ') else: tc.ib_prefix.append('') tc.stats_results = [] return api.types.status.SUCCESS
def start_single_pcap_capture(tc): try: req = api.Trigger_CreateExecuteCommandsRequest(serial=True) nodes = api.GetWorkloadNodeHostnames() tc.pcap_cmds = [] intf = api.GetRemoteWorkloadPairs()[0][0].interface tc.pcap_filename = pcap_file_name(intf) cmd = cmd_builder.tcpdump_cmd(intf, tc.pcap_filename) api.Trigger_AddHostCommand(req, n, cmd, background=True) resp = api.Trigger(req) for cmd in resp.commands: if cmd.handle == None or len(cmd.handle) == 0: api.Logger.error("Error starting pcap : %s " % cmd.command) api.Logger.error("Std Output : %s " % cmd.stdout) api.Logger.error("Std Err : %s " % cmd.stdout) return api.types.status.FAILURE api.Logger.info("Success running cmd : %s" % cmd.command) tc.pcap_trigger = resp return api.types.status.SUCCESS except: api.Logger.info("failed to start single pcap capture") api.Logger.debug( "failed to start single pcap capture. error was: {0}".format( traceback.format_exc())) return api.types.status.SUCCESS
def Setup(tc): if tc.args.type != 'remote_only': api.Logger.info("This test runs only for remote workloads. Ignoring test for non-remote type") return api.types.status.SUCCESS tc.workload_pairs = api.GetRemoteWorkloadPairs() return api.types.status.SUCCESS
def Trigger(tc): names = api.GetNaplesHostnames() name = names[0] if api.GetNodeOs(name) != "linux": return api.types.status.SUCCESS # Set up to run the macvlan offload test shellscript req = api.Trigger_CreateExecuteCommandsRequest(serial=True) # Get the workload interface information pairs = api.GetRemoteWorkloadPairs() pair = pairs[0] w1 = pair[0] w2 = pair[1] tc.cmd_descr = "Server: %s %s --> %s" % (w1.interface, w1.ip_address, w2.ip_address) api.Logger.info("Starting macvlan offload test from %s" % (tc.cmd_descr)) basecmd = './%s %s %s %s' % (macvlan_test_script, w1.interface, w1.ip_address, w2.ip_address) api.Trigger_AddHostCommand(req, w1.node_name, basecmd, background=False) # Send the commands tc.resp = api.Trigger(req) return api.types.status.SUCCESS
def Setup(tc): tc.skip = False if tc.selected: tc.workload_pairs = tc.selected else: if tc.args.type == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() tc.workload_pairs = tc.workload_pairs[:1] if len(tc.workload_pairs) == 0: api.Logger.info("Skipping Testcase due to no workload pairs.") tc.skip = True if getattr(tc.args, 'vmotion_enable', False): wloads = [] # collecting all server for wl_pair in tc.workload_pairs: wloads.append(wl_pair[1]) vmotion_utils.PrepareWorkloadVMotion(tc, wloads) #Have to fix it later. return api.types.status.SUCCESS
def Setup(tc): tc.Nodes = api.GetNaplesHostnames() tc.uuidMap = api.GetNaplesNodeUuidMap() tc.old_node = None tc.new_node = None tc.skip_security_prof = getattr(tc.args, "skip_security_prof", False) if tc.args.type == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() w1, w2 = tc.workload_pairs[0] tc.old_node = w1.node_name if w1.IsNaples() else w2.node_name tc.wl = w1 # remove the node being used to pick wl for traffic # pick the next node in the naples nodes naples_nodes = tc.Nodes[:] naples_nodes.remove(w1.node_name) assert (len(naples_nodes) >= 1) new_node = naples_nodes[0] tc.new_node = new_node move_info = vm_utils.MoveInfo() move_info.new_node = new_node move_info.wl = w1 move_info.old_node = w1.node_name tc.move_info.append(move_info) return api.types.status.SUCCESS
def Setup(tc): tc.skip = False if tc.args.type == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() if len(tc.workload_pairs) == 0: api.Logger.info("Skipping Testcase due to no workload pairs.") tc.skip = True if api.GetConfigNicMode() == 'hostpin' and tc.iterators.ipaf == 'ipv6': api.Logger.info("Skipping Testcase: IPv6 not supported in hostpin mode.") tc.skip = True if getattr(tc.args, 'vmotion_enable', False): wloads = [] for idx, pair in enumerate(tc.workload_pairs): if idx % 2: continue w2 = pair[1] wloads.append(w2) vmotion_utils.PrepareWorkloadVMotion(tc, wloads) return api.types.status.SUCCESS
def getNaplesNodeandWorkloads(): pairs = api.GetRemoteWorkloadPairs() workload1 = pairs[0][0] workload2 = pairs[0][1] api.Logger.verbose("workload1 : ", workload1.workload_name, workload1.node_name, workload1.uplink_vlan, id(workload1), workload1.interface, workload1.IsNaples()) api.Logger.verbose("workload2 : ", workload2.workload_name, workload2.node_name, workload2.uplink_vlan, id(workload2), workload2.interface, workload2.IsNaples()) naples_node = "" skip_tc = False if workload1.IsNaples(): naples_node = workload1.node_name elif workload2.IsNaples(): naples_node = workload2.node_name else: # no naples workload - so set skip to TRUE skip_tc = True return skip_tc, pairs, naples_node
def Setup(tc): naples_nodes = api.GetNaplesNodes() if len(naples_nodes) == 0: api.Logger.error("No naples node found") return api.types.status.ERROR tc.test_node = naples_nodes[0] tc.node_name = tc.test_node.Name() cimc_info = tc.test_node.GetCimcInfo() if not cimc_info: api.Logger.error("CimcInfo is None, exiting") return api.types.status.ERROR tc.ilo_ip = cimc_info.GetIp() tc.ilo_ncsi_ip = cimc_info.GetNcsiIp() tc.cimc_info = cimc_info if ping(tc.ilo_ip, 2) == api.types.status.SUCCESS: tc.initial_mode = "dedicated" elif ping(tc.ilo_ncsi_ip, 2) == api.types.status.SUCCESS: tc.initial_mode = "ncsi" else: api.Logger.error('ILO unreachable') return api.types.status.FAILURE # Tune linux settings tuneLinux() workload_pairs = api.GetRemoteWorkloadPairs() if not workload_pairs: api.Logger.error('No workload pairs found') return api.types.status.ERROR tc.wl_pair = workload_pairs[0] return api.types.status.SUCCESS
def Setup(tc): tc.Nodes = api.GetNaplesHostnames() tc.uuidMap = api.GetNaplesNodeUuidMap() tc.old_node = None tc.new_node = None tc.skip_security_prof = getattr(tc.args, "skip_security_prof", False) tc.client, tc.server, tc.naples = None, None, None if tc.args.type == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs(naples=True) else: tc.workload_pairs = api.GetRemoteWorkloadPairs() if len(tc.workload_pairs) == 0: api.Logger.error("Failed to get client server pair") return api.types.status.FAIL # pick a node to run traffic test ret = chooseNaples(tc, tc.workload_pairs[0]) if ret != api.types.status.SUCCESS: return ret # pick a new node to move one of the vms to ret = vm_utils.pick_new_node(tc) if ret != api.types.status.SUCCESS: return ret if not addPktFltrRuleOnEp(tc): api.Logger.error("Failed to add packet filter on EP") return api.types.status.FAIL return api.types.status.SUCCESS
def Setup(tc): tc.desc = ''' Test : QoS Config teardown test Opcode : Config, Verify FC TYPE : 1 (1=Link Level; 2=PFC) ''' tc.nodes = api.GetNaplesHostnames() tc.os = api.GetNodeOs(tc.nodes[0]) pairs = api.GetRemoteWorkloadPairs() # get workloads from each node tc.w = [] tc.w.append(pairs[0][0]) tc.w.append(pairs[0][1]) tc.cmd_cookies = [] tc.enable = 0 tc.no_drop = 0 # hardcode mtu to 1500 while deleting the user class as 0 is not allowed tc.mtu = 1500 tc.wt = 0 tc.pcp = 0 tc.pfc_cos = 0 tc.wt_configured = False tc.pcp_configured = False tc.pfc_cos_configured = False return api.types.status.SUCCESS
def getRemoteWorkloadPairs(): pairs = [] wpairs = api.GetRemoteWorkloadPairs() for w1, w2 in wpairs: if w1.encap_vlan == w2.encap_vlan: pairs.append((w1, w2)) return pairs
def Setup(tc): if tc.args.type == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() w1, w2 = tc.workload_pairs[0] tc.naples = w1 if w1.IsNaples() else w2 return api.types.status.SUCCESS
def Trigger(tc): if tc.skip: return api.types.status.SUCCESS loop_count = int(tc.args.loop_count) tc.ping_results = [] tc.cmd_cookies = {} tc.cmd_mac_validation_results = {} result = api.types.status.SUCCESS for cnt in range(loop_count): # clean up resources before run subif_utils.clearAll() # initialize config: subif_utils.initialize_tagged_config_workloads() # Delete existing subinterfaces __delete_subifs() time.sleep(3) # Create subinterfaces for every workload/host interface __create_subifs() time.sleep(2) # Generate traffic pairs with same vlan id tc.workload_pairs = api.GetRemoteWorkloadPairs() # run ping test between newly created workload pairs req = api.Trigger_CreateExecuteCommandsRequest(serial=True) tc.iter_cnt = cnt __run_ping_test(req, tc) resp = api.Trigger(req) tc.ping_results.append(resp) tc.wload_ep_set, tc.host_ep_set, tc.naples_ep_set, tc.hal_ep_set = ValidateMacRegistration( ) verify_result = api.types.status.FAILURE if resp != None: if not verifyEndPoints(tc): verify_result = api.types.status.FAILURE result = api.types.status.FAILURE tc.cmd_mac_validation_results[tc.iter_cnt] = verify_result break else: verify_result = api.types.status.SUCCESS tc.cmd_mac_validation_results[tc.iter_cnt] = verify_result # Return failure if resp is None: result = api.types.status.FAILURE break api.Logger.info("Trigger result: %s\n" % result) return result
def Setup(tc): tc.workload_pairs = api.GetRemoteWorkloadPairs() if len(tc.workload_pairs) == 0: api.Logger.info("Skipping Testcase due to no workload pairs.") tc.skip = True return api.types.status.SUCCESS
def Setup(tc): api.Logger.info("Setup.") tc.pcap_file_name = None tc.dir_path = os.path.dirname(os.path.realpath(__file__)) tc.test_mss = 900 if tc.iterators.kind == "remote": pairs = api.GetRemoteWorkloadPairs() if not pairs: api.Logger.info("no remtote eps") return api.types.status.SUCCESS else: pairs = api.GetLocalWorkloadPairs() tc.resp_flow = getattr(tc.args, "resp_flow", 0) tc.cmd_cookies = {} req = api.Trigger_CreateExecuteCommandsRequest(serial=True) if pairs[0][0].IsNaples(): tc.client, tc.server = pairs[0] else: tc.server, tc.client = pairs[0] fullpath = tc.dir_path + '/' + "scapy_3way.py" resp = api.CopyToWorkload(tc.server.node_name, tc.server.workload_name, [fullpath]) resp = api.CopyToWorkload(tc.client.node_name, tc.client.workload_name, [fullpath]) cmd_cookie = start_nc_server(tc.server, "1237") add_command(req, tc, 'server', tc.server, cmd_cookie, True) ret = __add_remove_tcp_drop_rule(tc.client) if ret != api.types.status.SUCCESS: api.Logger.error( f"Failed to drop the drop rule on {tc.client.workload_name}") return ret #start session cmd_cookie = "sudo -E python3 ./scapy_3way.py {} {}".format( tc.client.ip_address, tc.server.ip_address) api.Trigger_AddCommand(req, tc.client.node_name, tc.client.workload_name, cmd_cookie, False) cmd_cookie = "/nic/bin/halctl show session --dstport 1237 --dstip {} --yaml".format( tc.server.ip_address) add_command(req, tc, 'show before', tc.client, cmd_cookie, naples=True) tc.first_resp = api.Trigger(req) cmd = tc.first_resp.commands[-1] api.PrintCommandResults(cmd) tc.pre_ctrckinf = get_conntrackinfo(cmd) if getattr(tc.args, 'vmotion_enable', False): vmotion_utils.PrepareWorkloadVMotion(tc, [tc.client]) return api.types.status.SUCCESS
def findWorkloadPeers(tc): for w1, w2 in api.GetRemoteWorkloadPairs(): if w1 not in tc.workloadPeers and w2 not in tc.workloadPeers: peers = tc.workloadPeers.get(w1, []) peers.append(w2) tc.workloadPeers[w1] = peers peers = tc.workloadPeers.get(w2, []) peers.append(w1) tc.workloadPeers[w2] = peers
def Setup(tc): tc.skip = False if tc.args.type == 'local_only': tc.workload_pairs = api.GetLocalWorkloadPairs() else: tc.workload_pairs = api.GetRemoteWorkloadPairs() if len(tc.workload_pairs) == 0: api.Logger.info("Skipping Testcase due to no workload pairs.") tc.skip = True return api.types.status.SUCCESS