Пример #1
0
def Setup(tc):
    if tc.args.type == 'local_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY)
    elif tc.args.type == 'remote_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    elif tc.args.type == 'igw_only':
        local_vnic_has_public_ip = getattr(tc.args, "public_vnic", False)
        direction = getattr(tc.args, "direction", "tx")
        tc.workload_pairs = config_api.GetWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_IGW_ONLY,
            wl_pair_scope=config_api.WORKLOAD_PAIR_SCOPE_INTER_SUBNET,
            nat_type=tc.args.nat_type,
            local_vnic_has_public_ip=local_vnic_has_public_ip,
            direction=direction)

        if tc.args.nat_type == 'napt' or tc.args.nat_type == 'napt_service':
            tc.nat_port_blocks = config_api.GetAllNatPortBlocks()
            tc.nat_pre_stats = {}
            tc.nat_pre_stats = nat_pb.NatPbStats()
            for pb in tc.nat_port_blocks:
                stats = pb.GetStats()
                if pb.ProtoName == 'icmp':
                    tc.nat_pre_stats.Add(stats)

    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Пример #2
0
def Setup(tc):
    tc.skip = False
    tc.workloads = api.GetWorkloads()
    tc.packet_types = getattr(tc.args, "pkt_type", None)
    if not tc.args.pkt_type:
        tc.packet_types = ["ICMPv6-NS", "ICMPv6-NA", "ICMPv6-RS", "ICMPv6-RA"]

    if tc.args.type == 'local_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type = config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY)
    else:
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type = config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True
        return api.types.status.SUCCESS

    PrintWLInfo(tc)

    InstallScapyPackge(tc)

    if SetupPacketScapy(tc) != api.types.status.SUCCESS:
        api.Logger.info("Failed to copy packet scapy script to WL(s)")
        return api.types.status.SUCCESS
    return api.types.status.SUCCESS
Пример #3
0
def Setup(tc):
    if tc.args.type == 'local_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY)
    elif tc.args.type == 'remote_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    elif tc.args.type == 'igw_napt_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_IGW_NAPT_ONLY)

    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        return api.types.status.FAILURE


#    import pdb; pdb.set_trace()
    tc.selected_objs = []
    if tc.iterators.action == 'deny':
        for pair in tc.workload_pairs:
            objs = config_api.GetPolicyObjectsByWorkload(pair[0])
            for obj in objs:
                for rule in obj.rules:
                    if rule.L3Match.Proto == IPProtos.ICMP:
                        tc.selected_objs.append(obj)
                        obj.Update()

    return api.types.status.SUCCESS
Пример #4
0
def __add_static_arp():

    workload_pairs = config_api.GetPingableWorkloadPairs()

    if len(workload_pairs) == 0:
        api.Logger.info("No workload pairs to setup static arp")
        return api.types.status.FAILURE

    #req = api.Trigger_CreateAllParallelCommandsRequest()
    req = api.Trigger_CreateExecuteCommandsRequest()
    for pair in workload_pairs:
        w1 = pair[0]
        w2 = pair[1]
        arp_cmd = __get_arp_add_cmd(w1.ip_address, w1.mac_address,
                                    w2.interface)
        api.Trigger_AddCommand(req, w2.node_name, w2.workload_name, arp_cmd)
        #arp_cmd = __get_arp_add_cmd(w1.ipv6_address, w1.mac_address, w2.interface, "-6")
        #api.Trigger_AddCommand(req, w2.node_name, w2.workload_name, arp_cmd)

    resp = api.Trigger(req)

    for cmd in resp.commands:
        if cmd.exit_code != 0:
            api.Logger.error("Failed to install static arp entries")
            api.PrintCommandResults(cmd)
            return api.types.status.FAILURE

    return api.types.status.SUCCESS
Пример #5
0
def ChooseWorkLoads(tc):
    tc.workload_pairs = config_api.GetPingableWorkloadPairs(
        wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        tc.skip = True
        return api.types.status.FAILURE
    return api.types.status.SUCCESS
Пример #6
0
def ChooseWorkLoads(tc):
    def __find_unique_workload_pairs(workload_pairs):
        workloads = set()
        unique_workload_pairs = []
        for w1, w2 in workload_pairs:
            if w1 not in workloads and w2 not in workloads:
                unique_workload_pairs.append((w1, w2))
                workloads.add(w1)
                workloads.add(w2)
        return unique_workload_pairs

    def __expand_pairs(pairs_name):
        for pair_name in pairs_name:
            pairs = getattr(tc, pair_name, None)
            tmp = []
            if not pairs:
                continue
            for w1, w2 in pairs:
                tmp.append([w2, w1])
            pairs += tmp

    tc.workload_pairs = config_api.GetPingableWorkloadPairs(
        wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    workload_pairs = __find_unique_workload_pairs(tc.workload_pairs)
    if len(workload_pairs) < MIN_WORKLOAD_PAIR:
        api.Logger.error(
            f"Skipping Testcase due to no workload pairs less than {MIN_WORKLOAD_PAIR}"
        )
        tc.skip = True
        return api.types.status.FAILURE

    workloads_per_app = int(len(workload_pairs) / MIN_WORKLOAD_PAIR)
    ipref_start = workloads_per_app
    trex_start = workloads_per_app * 2

    if tc.background_ping and tc.iperf and tc.trex:
        tc.background_ping_pairs = workload_pairs[:ipref_start]
        tc.iperf_pairs = workload_pairs[ipref_start:trex_start]
        tc.trex_pairs = workload_pairs[trex_start:]
    elif tc.background_ping and tc.iperf and not tc.trex:
        tc.background_ping_pairs = workload_pairs[:ipref_start]
        tc.iperf_pairs = workload_pairs[ipref_start:]
    elif tc.background_ping and not tc.iperf and tc.trex:
        tc.background_ping_pairs = workload_pairs[:ipref_start]
        tc.trex_pairs = workload_pairs[ipref_start:]
    elif tc.background_ping and not tc.iperf and not tc.trex:
        tc.background_ping_pairs = workload_pairs
    elif not tc.background_ping and tc.iperf and tc.trex:
        tc.iperf_pairs = workload_pairs[:trex_start]
        tc.trex_pairs = workload_pairs[trex_start:]
    elif not tc.background_ping and tc.iperf and not tc.trex:
        tc.iperf_pairs = workload_pairs
    elif not tc.background_ping and not tc.iperf and tc.trex:
        tc.trex_pairs = workload_pairs

    __expand_pairs(["background_ping_pairs", "iperf_pairs", "trex_pairs"])

    return api.types.status.SUCCESS
Пример #7
0
def Setup(tc):
    api.Logger.verbose("MTU filter : Setup")
    tc.skip = False
    result = api.types.status.SUCCESS
    global __IS_FREEBSD

    if not api.RunningOnSameSwitch():
        tc.skip = True
        api.Logger.error(
            "MTU filter : Setup -> Multi switch topology not supported yet - So skipping the TC"
        )
        return api.types.status.IGNORED

    tc.naples_node, res = naples_host.GetNaplesNodeName()
    if res is False:
        tc.skip = True

    if tc.skip:
        api.Logger.error(
            "MTU filter : Setup -> No Naples Topology - So skipping the TC")
        return api.types.status.IGNORED
    """
      # In Intel cards, post MTU change, need to wait for few sec before pinging
      # instead, set max MTU on peer node
    """
    result = initPeerNode(tc.naples_node)

    __IS_FREEBSD = isFreeBSDTestbed()
    tc.new_mtu = getMTUconfigs(tc)

    if tc.args.type == 'local_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY)
    else:
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    if len(tc.workload_pairs) == 0:
        api.Logger.info("Skipping Testcase due to no workload pairs.")
        tc.skip = True

    api.Logger.info("MTU filter : new MTU - ", tc.new_mtu)

    api.Logger.info("MTU filter : Setup final result - ", result)
    debug_utils.collect_showtech(result)
    return result
Пример #8
0
def Setup(tc):
    tc.skip = False

    if tc.args.type == 'local_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY)
    else:
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    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

    return api.types.status.SUCCESS
Пример #9
0
def VerifyConnectivity(tc):
    if api.IsDryrun():
        return api.types.status.SUCCESS
    # ensure connectivity with foreground ping before test
    tc.workload_pairs = config_api.GetPingableWorkloadPairs(
        wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)
    if ping.TestPing(tc, "user_input", "ipv4", pktsize=128, interval=0.001, \
            count=5) != api.types.status.SUCCESS:
        api.Logger.info("Connectivity Verification Failed")
        return api.types.status.FAILURE
    return api.types.status.SUCCESS
Пример #10
0
def Setup(tc):
    result = api.types.status.SUCCESS
    if tc.args.type == 'local_only':
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY)
    else:
        tc.workload_pairs = config_api.GetPingableWorkloadPairs(
            wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)

    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        result = api.types.status.FAILURE

    tc.opers = __getOperations(tc.iterators.oper)
    tc.selected_objs = config_api.SetupConfigObjects(tc.iterators.objtype)

    if hasattr(tc.args, 'preclear'):
        for obj in tc.selected_objs:
            setattr(obj, tc.args.preclear, None)

    return result
Пример #11
0
def Setup(tc):
    tc.num_streams = getattr(tc.args, "num_streams", 1)
    tc.duration = getattr(tc.args, "duration", 10)
    tc.workload_pairs = config_api.GetPingableWorkloadPairs(
        wl_pair_type=config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY)

    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        return api.types.status.FAILURE

    if not SetupPolicer(tc):
        return api.types.status.FAILURE

    return api.types.status.SUCCESS