Ejemplo n.º 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
Ejemplo n.º 2
0
def Verify(tc):
    misc_utils.Sleep(40)  # letting remote mappings to get programmed
    if not learn_utils.ValidateLearnInfo():
        api.Logger.error("Learn validation failed")
        return api.types.status.FAILURE
    workload_pairs = config_api.GetWorkloadPairs(
        config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY,
        config_api.WORKLOAD_PAIR_SCOPE_INTER_SUBNET)
    workload_pairs.extend(
        config_api.GetWorkloadPairs(
            config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY,
            config_api.WORKLOAD_PAIR_SCOPE_INTRA_SUBNET))
    workload_pairs.extend(
        config_api.GetWorkloadPairs(
            config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY,
            config_api.WORKLOAD_PAIR_SCOPE_INTER_SUBNET))
    return conn_utils.ConnectivityTest(workload_pairs, ['icmp'], ['ipv4'],
                                       [64], 0, 'all')
Ejemplo n.º 3
0
def TriggerConnectivityTestAll(proto="icmp", af="ipv4", pktsize=128, sec_ip_test_type="all"):
    wl_pairs = []
    for wl_type in [config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY, \
                    config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY]:
        for wl_scope in [config_api.WORKLOAD_PAIR_SCOPE_INTRA_SUBNET, \
                         config_api.WORKLOAD_PAIR_SCOPE_INTER_SUBNET] :

            if wl_type == config_api.WORKLOAD_PAIR_TYPE_LOCAL_ONLY and \
               wl_scope == config_api.WORKLOAD_PAIR_SCOPE_INTRA_SUBNET:
                continue
            wl_pairs += config_api.GetWorkloadPairs(wl_type, wl_scope)

    return TriggerConnectivityTest(wl_pairs, proto, af, pktsize, sec_ip_test_type)
Ejemplo n.º 4
0
def Setup(tc):
    tc_name = tc.Name().rsplit('_', 1)[0]
    if tc_name == 'ARP_Self_AddressDetection':
        tc.wl_type = "self"
    else:
        tc.wl_type = conn_utils.GetWorkloadType(tc.iterators)
    tc.wl_scope = conn_utils.GetWorkloadScope(tc.iterators)

    tc.workload_pairs = list()
    if tc.wl_type == "self":
        tc.workload_pairs = __getDuplicateWorkloads()
    else:
        tc.workload_pairs = config_api.GetWorkloadPairs(tc.wl_type, tc.wl_scope)

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

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

    tc.wloads = []
    for node in tc.Nodes:
        learn_mac_objs = learn_utils.GetLearnMACObjects(node)
        for obj in learn_mac_objs:
            wl = config_api.FindWorkloadByVnic(obj)
            tc.wloads.append(wl)
            api.Logger.info("WL %s added to the list of WL from VNIC"%wl.workload_name)

    tc.workload_pairs = config_api.GetWorkloadPairs(
            conn_utils.GetWorkloadType(tc.iterators),
            conn_utils.GetWorkloadScope(tc.iterators))
    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        tc.skip = True
        if tc.iterators.workload_type == 'local' and tc.iterators.workload_scope == 'intra-subnet':
            # Currently we dont support local-to-local intra-subnet connectivity
            return api.types.status.SUCCESS
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 6
0
def Setup(tc):
    tc.opers = []
    if hasattr(tc.iterators, "oper"):
        tc.opers = __getOperations(tc.iterators.oper)
        tc.selected_objs = config_api.SetupConfigObjects(tc.iterators.objtype)

    tc.sec_ip_test_type = getattr(tc.args, "use-sec-ip", "none")
    if tc.sec_ip_test_type not in ["all", "random", "none"]:
        api.Logger.error("Invalid value for use-sec-ip %s" %
                         (tc.sec_ip_test_type))
        return api.types.status.FAILURE

    tc.workload_pairs = config_api.GetWorkloadPairs(
        conn_utils.GetWorkloadType(tc.iterators),
        conn_utils.GetWorkloadScope(tc.iterators),
    )

    tc.workload_pairs = [
        workload_pair for workload_pair in tc.workload_pairs if
        workload_pair[0].vnic.DhcpEnabled and workload_pair[1].vnic.DhcpEnabled
    ]

    for pair in tc.workload_pairs:
        api.Logger.info("%s %s %s %s" % (
            pair[0].interface,
            pair[0].parent_interface,
            pair[1].interface,
            pair[1].parent_interface,
        ))
    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        if (tc.iterators.workload_type == "local"
                and tc.iterators.workload_scope == "intra-subnet"):
            # Currently we dont support local-to-local intra-subnet connectivity
            return api.types.status.SUCCESS
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 7
0
def Setup(tc):
    if tc.iterators.proto == 'icmp':
        tc.sec_ip_test_type = getattr(tc.args, 'ping-secondary-ip', 'none')
        if tc.sec_ip_test_type not in ['all', 'random', 'none']:
            api.Logger.error("Invalid value for ping-secondary-ip %s" %
                             (tc.sec_ip_test_type))
            return api.types.status.FAILURE
        api.Logger.verbose("Secondary IP test type set to %s" %
                           (tc.sec_ip_test_type))
    else:
        tc.sec_ip_test_type = 'none'

    tc.workload_pairs = config_api.GetWorkloadPairs(
        conn_utils.GetWorkloadType(tc.iterators),
        conn_utils.GetWorkloadScope(tc.iterators))
    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        if tc.iterators.workload_type == 'local' and tc.iterators.workload_scope == 'intra-subnet':
            # Currently we dont support local-to-local intra-subnet connectivity
            return api.types.status.SUCCESS
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 8
0
def Setup(tc):
    tc.workload_pairs = config_api.GetWorkloadPairs(conn_utils.GetWorkloadType(tc.iterators),
            conn_utils.GetWorkloadScope(tc.iterators))
    if len(tc.workload_pairs) == 0:
        api.Logger.error("Skipping Testcase due to no workload pairs.")
        if tc.iterators.workload_type == 'local' and tc.iterators.workload_scope == 'intra-subnet':
            # Currently we dont support local-to-local intra-subnet connectivity
            return api.types.status.SUCCESS
        return api.types.status.FAILURE

    if tc.iterators.timeout == 'drop':
        # Configure policy as deny so that the flows are created as drop
        modifyPolicyRule(tc.workload_pairs, tc.iterators.proto, 'deny')

    # Add DROP rule for TCP and UDP packets on endpoint to prevent TCP RST in
    # response to TCP SYN packets and ICMP unreachable in case of UDP
    if (tc.iterators.proto == 'udp' or
        (tc.iterators.proto == 'tcp' and tc.iterators.timeout != 'rst' and
        tc.iterators.timeout != 'longlived')):
        if not addPktFilterRuleOnEp(tc.workload_pairs, tc.iterators.proto):
            api.Logger.error("Failed to add drop rules")
            return api.types.status.FAILURE

    return api.types.status.SUCCESS
Ejemplo n.º 9
0
def Setup(tc):

    flow_type = getattr(tc.iterators, "flow_type", "intra-subnet")
    tc.skip = False
    tc.mv_ctx = {}
    tc.bg_cmd_resp = None
    tc.sessionInfo = {}

    # Select movable workload pair
    if flow_type == "intra-subnet":
        wl_type = config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY
        wl_scope = config_api.WORKLOAD_PAIR_SCOPE_INTRA_SUBNET
    elif flow_type == "inter-subnet":
        wl_type = config_api.WORKLOAD_PAIR_TYPE_REMOTE_ONLY
        wl_scope = config_api.WORKLOAD_PAIR_SCOPE_INTER_SUBNET
    else:
        assert 0, ("Flow type %s not supported" % flow_type)

    pairs = config_api.GetWorkloadPairs(wl_type, wl_scope)
    if not pairs:
        tc.skip = True
        return api.types.status.SUCCESS

    # Setup move of primary IP address of source workload to destination
    # workload.
    src_wl, dst_wl = pairs[0]
    tc.mv_ctx['src_wl'] = src_wl
    tc.mv_ctx['dst_wl'] = dst_wl
    tc.mv_ctx['ip_prefix'] = src_wl.ip_prefix
    tc.mv_ctx['inter'] = "inter" in flow_type
    tc.wl_pairs = pairs

    # Clear move stats
    stats_utils.Clear()
    learn_utils.DumpLearnData()

    # Clear flows
    flow_utils.clearFlowTable(None)

    # Increase ICMP idle timeout
    cmd = "set pds security-profile icmp-idle-timeout 600"
    vppctl.ExecuteVPPctlCommand(src_wl.node_name, cmd)
    vppctl.ExecuteVPPctlCommand(dst_wl.node_name, cmd)

    ret = __setup_background_ping(tc)
    if ret != api.types.status.SUCCESS:
        return ret

    ret = __validate_flows(tc, src_wl.node_name)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Failed to validate flows on node %s" %
                         src_wl.node_name)
        return api.types.status.FAILURE

    ret = __validate_flows(tc, dst_wl.node_name)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Failed to validate flows on node %s" %
                         dst_wl.node_name)
        return api.types.status.FAILURE

    return api.types.status.SUCCESS