示例#1
0
def Main(args):
    #time.sleep(120)
    api.Logger.info("Testsuite NIC Mode is %s" % (api.GetConfigNicMode()))
    agent_nodes = api.GetNaplesHostnames()
    netagent_api.Init(agent_nodes, hw=True)

    netagent_api.ReadConfigs(api.GetTopologyDirectory(), reset=False)

    ret = api.types.status.SUCCESS
    if api.GetConfigNicMode() in ['unified']:
        ret = UpdateNetworkAndEnpointObject()
        if ret != api.types.status.SUCCESS:
            return ret

    #Delete path is not stable yet
    #netagent_api.DeleteBaseConfig()

    if GlobalOptions.skip_setup:
        ret = RestoreWorkloads()
    else:
        nic_mode = api.GetConfigNicMode()
        if nic_mode not in ['classic', 'sriov']:
            kinds = ["SecurityProfile"] if nic_mode == 'unified' else None
            netagent_api.PushBaseConfig(kinds=kinds)
        ret = __add_workloads(api.GetNodes())
    return ret
示例#2
0
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
示例#3
0
def Verify(tc):
    if getattr(tc.args, 'vmotion_enable', False):
        vmotion_utils.PrepareWorkloadRestore(tc)

    if tc.skip: return api.types.status.SUCCESS
    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("Ping Results for %s" % (tc.cmd_cookies[cookie_idx]))
        api.PrintCommandResults(cmd)
        if cmd.exit_code != 0:
            if api.GetConfigNicMode() == 'hostpin' and tc.iterators.pktsize > 1024:
                result = api.types.status.SUCCESS
            else:
                try:
                    found = re.search(cmd.node_name+"_(.*)_subif_(.*$)",cmd.entity_name)
                    if found:
                        debugPing(cmd, found.group(1))
                    else:
                        api.Logger.debug("failed to determine interface name from {0}".format(cmd.entity_name))
                except:
                    api.Logger.debug("failed to debug {0} ping issue".format(cmd.entity_name))
                result = api.types.status.FAILURE
            #for future use
            #elif tc.args.type == 'local_only':
            #    return api.types.status.CRITICAL
            #else:
            #    raise OfflineTestbedException
        cookie_idx += 1
    return result
示例#4
0
def Verify(tc):
    if tc.os != host.OS_TYPE_BSD:
        api.Logger.info("Not implemented")
        return api.types.status.IGNORED

    result = api.types.status.SUCCESS

    for node in tc.nodes:
        # this is required to bring the testbed into operation state
        # after driver unload interfaces need to be initialized
        wl_api.ReAddWorkloads(node)

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

    if api.GetConfigNicMode() == 'classic':
        expect_exit_code = 0
    else:
        # expect OS's EPERM (FreeBSD/Linux is 1) (IONIC_RC_EPERM is 4)
        expect_exit_code = 1

    for cmd in tc.resp.commands:
        if cmd.exit_code != expect_exit_code:
            api.PrintCommandResults(cmd)
            api.Logger.error("Expected exit code %d" % expect_exit_code)
            api.Logger.error("Actual exit code %d" % cmd.exit_code)
            result = api.types.status.FAILURE

    return result
示例#5
0
def UpdateNodeUuidEndpoints(objects):
    #allocate pvlan pair for dvs
    if api.GetConfigNicMode() == 'hostpin_dvs':
        pvlan_start = api.GetPVlansStart()
        pvlan_end = api.GetPVlansEnd()
        index = 0
        for obj in objects:
            obj.spec.primary_vlan = pvlan_start + index
            obj.spec.secondary_vlan = pvlan_start + index + 1
            obj.spec.useg_vlan = obj.spec.primary_vlan
            index = index + 2
            if index > pvlan_end:
                assert (0)

    agent_uuid_map = api.GetNaplesNodeUuidMap()
    for ep in objects:
        node_name = getattr(ep.spec, "_node_name", None)
        if not node_name:
            node_name = ep.spec.node_uuid
        assert (node_name)
        if api.IsNaplesNode(node_name):
            ep.spec.node_uuid = formatMac(GetNaplesUUID(node_name))
        else:
            ep.spec.node_uuid = agent_uuid_map[node_name]
        ep.spec._node_name = node_name
示例#6
0
def Setup(tc):
    tc.skip = False

    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_dvs':
        api.Logger.info("Skipping Testcase: as vmotion nonly on dvs testsuite")
        tc.skip = True

    return api.types.status.SUCCESS
示例#7
0
def Setup(tc):
    tc.skip_flap = False
    tc.newObjects = None
    tc.collector_ip = []
    tc.collector_wl = []
    tc.collector_type = []
    tc.wl_sec_ip_info = defaultdict(lambda: dict())
    tc.IsBareMetal = utils.IsBareMetal()
    tc.port_down_time = getattr(tc.args, "port_down_time", 60)
    policies = utils.GetTargetJsons('mirror', tc.iterators.proto)
    policy_json = policies[0]
    tc.verif_json = utils.GetVerifJsonFromPolicyJson(policy_json)

    # Push Mirror objects
    tc.newObjects = agent_api.AddOneConfig(policy_json)
    ret = agent_api.PushConfigObjects(tc.newObjects)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Unable to push mirror objects")
        tc.newObjects = None
        return api.types.status.FAILURE

    # Populate secondary IP
    utils.PopulateSecondaryAddress(tc)

    # Get collector
    ret = GetCollectorWorkloadFromObjects(tc)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Failed to get collector workload")
        return ret

    ret = utils.DetectUpLinkState(api.GetNaplesHostnames(),
                                  utils.PORT_OPER_STATUS_UP, all)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("All uplink on Nodes are not in UP state.")
        tc.skip_flap = True
        return api.types.status.SUCCESS

    if api.GetConfigNicMode() in ["classic", "unified"]:
        api.Logger.info(
            f"NIC mode: {api.GetConfigNicMode()}, Skipping uplink flap")
        tc.skip_flap = True

    api.Logger.info("All uplink on Nodes are UP!")
    # Bring up inband and reset the active link on bond.
    ret = utils.SetupInbandInterface()
    if ret != api.types.status.SUCCESS:
        return ret
    return api.types.status.SUCCESS
示例#8
0
def Main(step):
    # time.sleep(120)
    #api.Init()
    agent_ips = api.GetNaplesMgmtIpAddresses()
    netagent_api.Init(agent_ips)

    netagent_api.ReadConfigs(api.GetTopologyDirectory())
    __init_lifdb()

    netagent_api.DeleteBaseConfig()
    if api.GetConfigNicMode() != 'classic':
        netagent_api.PushBaseConfig()

    if not api.IsConfigOnly():
        __add_workloads()
    return api.types.status.SUCCESS
示例#9
0
def verify_ping_to_bond_result(tc):
    result = api.types.status.SUCCESS
    cookie_idx = 0
    for cmd in tc.resp.commands:
        api.Logger.info("Ping Results for %s" % (tc.cmd_cookies[cookie_idx]))
        api.PrintCommandResults(cmd)
        if cmd.exit_code != 0:
            if api.GetConfigNicMode(
            ) == 'hostpin' and tc.iterators.pktsize > 1024:
                result = api.types.status.SUCCESS
            else:
                result = api.types.status.FAILURE
        cookie_idx += 1
    tc.resp = None
    tc.cmd_cookies = []
    return result
示例#10
0
def Setup(tc):
    tc.skip = False

    if tc.args.type == 'remote_only':
        tc.workload_pairs = subif_utils.getRemoteHostIntfWorkloadsPairs()
    else:
        tc.skip = True

    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
示例#11
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
示例#12
0
def Setup(tc):
    tc.skip = False
    # Fetching Vlan Id
    tc.vlan_id = api.GetRandomVlan()

    if tc.args.type == 'remote_only':
        tc.workload_pairs = api.GetRemoteWorkloadPairs()
    else:
        tc.skip = True

    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
示例#13
0
def Verify(tc):
    if tc.skip: return api.types.status.SUCCESS
    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("Ping Results for %s" % (tc.cmd_cookies[cookie_idx]))
        api.PrintCommandResults(cmd)
        if cmd.exit_code != 0:
            if tc.cmd_cookies[cookie_idx] == "Driver-FW-Version":
                continue # ignore failure for now
            if api.GetConfigNicMode() == 'hostpin' and tc.args.pktsize > 1024:
                result = api.types.status.SUCCESS
            else:
                result = api.types.status.FAILURE
        cookie_idx += 1
    return result
示例#14
0
def TestTerminateBackgroundPing(tc, pktsize, pktlossverif=False):

    result = api.types.status.SUCCESS
    term_resp = api.Trigger_TerminateAllCommands(tc.bg_cmd_resp)
    tc.resp = api.Trigger_AggregateCommandsResponse(tc.bg_cmd_resp, term_resp)

    cookie_idx = 0
    for cmd in tc.resp.commands:
        api.Logger.info("ping results for %s" % (tc.bg_cmd_cookies[cookie_idx]))
        api.PrintCommandResults(cmd)
        if cmd.exit_code != 0:
            if api.GetConfigNicMode() == 'hostpin' and pktsize > 1024:
                result = api.types.status.SUCCESS
            else:
                result = api.types.status.FAILURE
        elif pktlossverif:
            ping_result = parsePingResult(cmd.stdout)
            if not ping_result:
                api.Logger.info("Background ping failed in packet loss verification")
                result = api.types.status.FAILURE

        cookie_idx += 1
    return result
示例#15
0
def TestPing(tc, input_type, ipaf, pktsize, interval=0.2, count=20, deadline=0,
             pktlossverif=False, background=False, hping3=False):
    if input_type == 'user_input':
        api.Logger.info("user_input")
    elif input_type == 'local_only':
        api.Logger.info("local_only test")
        tc.workload_pairs = api.GetLocalWorkloadPairs()
    elif input_type == 'remote_only':
        api.Logger.info("remote_only test")
        tc.workload_pairs = api.GetRemoteWorkloadPairs()
    else:
        tc.workload_pairs = api.GetLocalWorkloadPairs()
        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 ipaf == 'ipv6':
        api.Logger.info("Skipping Testcase: IPv6 not supported in hostpin mode.")
        return api.types.status.SUCCESS

    req = None
    if not api.IsSimulation():
        req = api.Trigger_CreateAllParallelCommandsRequest()
    else:
        req = api.Trigger_CreateExecuteCommandsRequest(serial = False)

    tc.cmd_cookies = []

    deadline_str = ""
    count_str = ""
    cmd_timeout = 60
    if deadline:
        deadline_str = "-w {}".format(deadline)
        cmd_timeout = deadline + 5
    else:
        count_str = "-c {}".format(count)
        cmd_timeout = int(count * interval) + 5

    cmd_timeout = 60 if cmd_timeout < 60 else cmd_timeout

    for pair in tc.workload_pairs:
        w1 = pair[0]
        w2 = pair[1]
        if ipaf == 'ipv6':
            cmd_cookie = "%s(%s) --> %s(%s)" %\
                         (w1.workload_name, w1.ipv6_address, w2.workload_name, w2.ipv6_address)
            api.Trigger_AddCommand(req, w1.node_name, w1.workload_name,
                                   "sudo ping6 -q -i %s %s -s %d %s %s" % (interval, count_str,
                                   pktsize, w2.ipv6_address, deadline_str),
                                   background=background, timeout=cmd_timeout)
        else:
            cmd_cookie = "%s(%s) --> %s(%s) pktsize: %s, count: %s, interval: %s, deadline: %s, background: %s" %\
                         (w1.workload_name, w1.ip_address, w2.workload_name, w2.ip_address, pktsize, count, interval,
                          deadline, background)
            if hping3:
                # working around hping --quiet mode issue.
                cmd = f"sudo hping3 --icmp -i u{interval*1000000} {count_str} -d {pktsize} {w2.ip_address} 2> out 1> /dev/null && cat out"
            else:
                cmd = f"sudo ping -q -i {interval} {count_str} -s {pktsize} {w2.ip_address} {deadline_str}"
            api.Trigger_AddCommand(req, w1.node_name, w1.workload_name, cmd, background=background, timeout=cmd_timeout)

        api.Logger.info("Ping test 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
    if not background:
        cookie_idx = 0
        for cmd in tc.resp.commands:
            api.Logger.info("ping results for %s" % (tc.cmd_cookies[cookie_idx]))
            api.PrintCommandResults(cmd)
            if cmd.exit_code != 0:
                if api.GetConfigNicMode() == 'hostpin' and pktsize > 1024:
                    result = api.types.status.SUCCESS
                else:
                    result = api.types.status.FAILURE
            elif pktlossverif:
                ping_result = parsePingResult(cmd.stdout)
                if not ping_result:
                    api.Logger.info("ping failed in packet loss verification")
                    result = api.types.status.FAILURE
                    break
            cookie_idx += 1
    else:
        tc.bg_cmd_cookies = tc.cmd_cookies
        tc.bg_cmd_resp   = tc.resp

    return result