Пример #1
0
def Setup(tc):
    tc.Nodes = api.GetNaplesHostnames()
    if arping.ArPing(tc) != api.types.status.SUCCESS:
        api.Logger.info("arping failed on setup")
    if ping.TestPing(tc, 'local_only', 'ipv4',
                     64) != api.types.status.SUCCESS or ping.TestPing(
                         tc, 'remote_only', 'ipv4',
                         64) != api.types.status.SUCCESS:
        api.Logger.info("ping test failed on setup")
        return api.types.status.FAILURE
    req = api.Trigger_CreateExecuteCommandsRequest()

    for node in tc.Nodes:
        api.Trigger_AddNaplesCommand(
            req, node, "rm -rf /update/upgrade_halt_state_machine")
        api.Trigger_AddNaplesCommand(req, node,
                                     "rm -rf /update/pcieport_upgdata")
        api.Trigger_AddNaplesCommand(req, node,
                                     "rm -rf /update/pciemgr_upgdata")
        api.Trigger_AddNaplesCommand(req, node,
                                     "rm -rf /update/pciemgr_upgrollback")
        api.Trigger_AddNaplesCommand(req, node,
                                     "rm -rf /update/nicmgr_upgstate")
        api.Trigger_AddNaplesCommand(
            req, node, "touch /data/upgrade_to_same_firmware_allowed")
    resp = api.Trigger(req)
    for cmd_resp in resp.commands:
        api.PrintCommandResults(cmd_resp)
        if cmd_resp.exit_code != 0:
            api.Logger.error("Setup failed %s", cmd_resp.command)

    return api.types.status.SUCCESS
Пример #2
0
def Setup(tc):
    tc.Nodes = api.GetNaplesHostnames()
    tc.AllNodes = api.GetWorkloadNodeHostnames()
    tc.uuidMap = api.GetNaplesNodeUuidMap()
    tc.new_node = None
    tc.old_node = None
    tc.vm_non_dsc_to_dsc = False
    tc.vm_dsc_to_dsc = False
    tc.move_info = []
    if tc.args.vm_type == 'non_dsc_to_dsc':
        tc.vm_non_dsc_to_dsc = True
    else:
        tc.vm_dsc_to_dsc = True
    tc.num_moves = int(getattr(tc.args, "num_moves", 1))

    getNonNaplesNodes(tc)
    if arping.ArPing(tc) != api.types.status.SUCCESS:
        api.Logger.info("arping failed on setup")
    if ping.TestPing(tc, 'local_only', 'ipv4',
                     64) != api.types.status.SUCCESS or ping.TestPing(
                         tc, 'remote_only', 'ipv4',
                         64) != api.types.status.SUCCESS:
        api.Logger.info("ping test failed on setup")
        return api.types.status.FAILURE

    #Start Fuz
    ret = start_fuz(tc)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Fuz start failed")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Пример #3
0
def Verify(tc):
    time.sleep(tc.args.sleep)

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

    for cmd in tc.resp.commands:
        api.PrintCommandResults(cmd)
        if cmd.exit_code != 0:
            return api.types.status.FAILURE

    req = api.Trigger_CreateExecuteCommandsRequest()
    for n in tc.Nodes:
        cmd = 'curl -k https://' + api.GetNicIntMgmtIP(
            n) + ':8888/api/v1/naples/rollout/'
        api.Trigger_AddHostCommand(req, n, cmd)
    tc.resp = api.Trigger(req)

    for cmd in tc.resp.commands:
        api.PrintCommandResults(cmd)

    if  netagent_cfg_api.switch_profile(push_base_profile=True) != \
        api.types.status.SUCCESS:
        api.Logger.warn("Failed to push base profile")
        return api.types.status.FAILURE

    if netagent_cfg_api.PushBaseConfig(ignore_error = False) != \
       api.types.status.SUCCESS:
        api.Logger.info("policy push failed")
        return api.types.status.FAILURE

    for cmd in tc.resp.commands:
        if cmd.exit_code != 0:
            api.Logger.info("cmd returned failure")
            return api.types.status.FAILURE
        if arping.ArPing(tc) != api.types.status.SUCCESS:
            api.Logger.info("arping failed on verify")
        if ping.TestPing(tc, 'local_only', 'ipv4',
                         64) != api.types.status.SUCCESS or ping.TestPing(
                             tc, 'remote_only', 'ipv4',
                             64) != api.types.status.SUCCESS:
            api.Logger.info("ping test failed")
            return api.types.status.FAILURE

        resp = json.loads(cmd.stdout)
        try:
            for item in resp['Status']['status']:
                if not item['Op'] == 4:
                    api.Logger.info("opcode is bad")
                    return api.types.status.FAILURE
                else:
                    if not item['opstatus'] == 'success':
                        api.Logger.info("opstatus is bad")
                        return api.types.status.FAILURE
        except:
            api.logger.info("resp : ", json.dumps(resp, indent=4))

    return api.types.status.SUCCESS
Пример #4
0
def PacketTestSetup(tc):
    if tc.upgrade_mode is None:
        return api.types.status.SUCCESS

    tc.bg_cmd_cookies = None
    tc.bg_cmd_resp = None
    tc.pktsize = 128
    tc.duration = tc.sleep
    tc.background = True
    tc.pktlossverif = False
    tc.interval = 0.001  #1msec
    tc.count = int(tc.duration / tc.interval)

    if tc.upgrade_mode != "graceful":
        tc.pktlossverif = True

    if api.IsDryrun():
        return api.types.status.SUCCESS

    # start background ping before start of test
    if ping.TestPing(tc, 'user_input', "ipv4", tc.pktsize, interval=tc.interval, \
            count=tc.count, pktlossverif=tc.pktlossverif, \
            background=tc.background, hping3=True) != api.types.status.SUCCESS:
        api.Logger.error("Failed in triggering background Ping.")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Пример #5
0
def verify_connectivity(tc):
    if arping.ArPing(tc) != api.types.status.SUCCESS:
        api.Logger.info("arping failed on setup")
    if ping.TestPing(tc, 'all', 'ipv4', 64) != api.types.status.SUCCESS:
        api.Logger.error("ping test failed on setup")
        return api.types.status.FAILURE
    return api.types.status.SUCCESS
Пример #6
0
def __setup_background_ping(tc):
    # We need to run background ping only for the workload where the moving
    # IP is destination.
    # Populate tc.workload_pairs with the desired pairs as that is used by
    # TestPing to initiate background ping
    tc.workload_pairs = []
    for pair in tc.wl_pairs:
        if (pair[1].ip_prefix == tc.mv_ctx['ip_prefix']
                or tc.mv_ctx['ip_prefix'] in pair[1].sec_ip_prefixes):
            tc.workload_pairs.append(pair)

    # start background ping
    api.Logger.verbose("Starting background ping")
    res = ping.TestPing(tc,
                        'user_input',
                        'ipv4',
                        128,
                        count=10000,
                        background=True,
                        hping3=True,
                        interval=0.2)
    if res != api.types.status.SUCCESS:
        api.Logger.error("Failed in triggering background Ping.")

    return res
Пример #7
0
def Setup(tc):
    vm_threads = []
    node_list  = []
    node = getattr(tc.args, "node", None)
    if node:
        node_list.append(node)
    else:
        '''
        add all nodes in the topo
        '''
        nodes = api.GetNodes()
        for node in nodes:
            node_list.append(node.Name())
    tc.Nodes    = api.GetNaplesHostnames()
    tc.AllNodes = api.GetWorkloadNodeHostnames()
    tc.uuidMap  = api.GetNaplesNodeUuidMap()
    tc.move_info         = []
    tc.vm_dsc_to_dsc     = True
    tc.num_moves         = 0

    if hasattr(tc.args, "conntrack"):
        tc.detailed = True
    else:
        tc.detailed = False


    getNonNaplesNodes(tc)
    if arping.ArPing(tc) != api.types.status.SUCCESS:
        api.Logger.info("arping failed on setup")
    if ping.TestPing(tc, 'local_only', 'ipv4', 64) != api.types.status.SUCCESS or ping.TestPing(tc, 'remote_only', 'ipv4', 64) != api.types.status.SUCCESS:
        api.Logger.info("ping test failed on setup")
        return api.types.status.FAILURE

    for node in node_list:
        (wls,new_node) = getWorkloadsToRemove(tc, node)
        tc.num_moves = len(wls)
        vm_utils.update_move_info(tc, wls, False, new_node)

    #Start Fuz
    ret = vm_utils.start_fuz(tc)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Fuz start failed")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS
Пример #8
0
def Setup(tc):
    tc.Nodes = api.GetNaplesHostnames()
    tc.AllNodes = api.GetWorkloadNodeHostnames()
    tc.uuidMap = api.GetNaplesNodeUuidMap()
    tc.new_node = None
    tc.old_node = None
    tc.vm_non_dsc_to_dsc = False
    tc.vm_dsc_to_dsc = False
    tc.move_info = []
    if tc.args.vm_type == 'non_dsc_to_dsc':
        tc.vm_non_dsc_to_dsc = True
    else:
        tc.vm_dsc_to_dsc = True
    tc.num_moves = int(getattr(tc.args, "num_moves", 1))

    tc.trigger = None
    tc.trigger = getattr(tc.args, "trigger_type", None)
    tc.trigger_on = getattr(tc.args, "trigger_on", 'new')
    '''
    if tc.args.trigger_type  == 'port_flap':
        tc.trigger = 'port_flap'
    elif tc.args.trigger_type == 'mgmt_down':
        tc.trigger = 'mgmt_down'
    elif tc.args.trigger_type == 'delete_ep':
        tc.trigger = 'delete_ep'
    '''

    getNonNaplesNodes(tc)
    #Start Fuz

    if arping.ArPing(tc) != api.types.status.SUCCESS:
        api.Logger.info("arping failed on setup")
    tc1 = ping.TestPing(tc, 'local_only', 'ipv4', 64)
    tc2 = ping.TestPing(tc, 'remote_only', 'ipv4', 64)
    if tc1 != api.types.status.SUCCESS or tc2 != api.types.status.SUCCESS:
        api.Logger.info("ping test failed on setup")
        return api.types.status.FAILURE

    ret = start_fuz(tc, "20s", "20")
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Fuz start failed")
        return api.types.status.FAILURE
    stop_fuz(tc)
    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
    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 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
Пример #11
0
def Trigger(tc):
    api.Logger.info("starting ping in background ..")
    ping.TestPing(tc,
                  "all",
                  'ipv4',
                  tc.pkt_size,
                  interval=tc.interval,
                  count=tc.count,
                  background=True,
                  hping3=True)

    req = api.Trigger_CreateExecuteCommandsRequest()
    for n in tc.Nodes:
        cmd = 'curl -k -d \'{"kind": "SmartNICRollout","meta": {"name": "test disruptive upgrade","tenant": "tenant-foo"},"spec": {"ops": [{"op": 4,"version": "0.1"}]}}\' -X POST -H "Content-Type:application/json" ' + 'https://' + api.GetNicIntMgmtIP(
            n) + ':8888/api/v1/naples/rollout/'
        api.Trigger_AddHostCommand(req, n, cmd)
    tc.resp = api.Trigger(req)
    return api.types.status.SUCCESS
Пример #12
0
def PacketTestSetup(tc):
    tc.bg_cmd_cookies = None
    tc.bg_cmd_resp = None
    tc.pktsize = 128
    tc.duration = tc.sleep
    tc.pktlossverif = False
    tc.interval = 0.001  #1msec
    tc.count = int(tc.duration / tc.interval)

    # start background ping before start of test
    if tc.background_ping:
        tc.workload_pairs = tc.background_ping_pairs
        if ping.TestPing(tc, 'user_input', "ipv4", tc.pktsize, interval=tc.interval, \
                count=tc.count, pktlossverif=tc.pktlossverif, \
                background=tc.background_ping, hping3=True) != api.types.status.SUCCESS:
            api.Logger.error(
                "Failed in triggering background Ping during Setup")
            tc.skip = True
            return api.types.status.FAILURE

    if tc.iperf:
        out = traffic.iperfWorkloads(tc.iperf_pairs, time=tc.duration, \
                                    proto="udp", bandwidth="100M", \
                                    num_of_streams=32, sleep_time=30, \
                                    packet_size=64, background=True)
        tc.cmd_desc, tc.server_resp, tc.client_resp = out[0], out[1], out[2]

    # Start Trex
    if tc.trex:
        tc.trex_peers = traffic_gen.find_workload_peers(tc.trex_pairs)
        max_active_flow = tc.iterators.max_active_flow
        cps = tc.iterators.cps
        duration = getattr(tc.iterators, "duration", None)
        if traffic_gen.start_trex_traffic(tc.trex_peers, duration,
                                          max_active_flow,
                                          cps) != api.types.status.SUCCESS:
            api.Logger.error("Failed to start Trex traffic")
            tc.skip = True
            return api.types.status.FAILURE
    return api.types.status.SUCCESS
Пример #13
0
def Setup(tc):
    '''
    for n in api.GetNaplesHostnames():
        uuid = GetNaplesUUID(n)
        api.SetNaplesNodeUuid(n, uuid)
    '''

    tc.Nodes = api.GetNaplesHostnames()
    tc.AllNodes = api.GetWorkloadNodeHostnames()
    tc.uuidMap = api.GetNaplesNodeUuidMap()
    tc.new_node = None
    tc.old_node = None
    tc.vm_non_dsc_to_dsc = False
    tc.vm_dsc_to_dsc = False
    tc.skip_teardown = False
    tc.move_info = []
    tc.dbg_stats_before = dict()
    tc.dbg_stats_after = dict()
    if tc.args.vm_type == 'non_dsc_to_dsc':
        tc.vm_non_dsc_to_dsc = True
    else:
        tc.vm_dsc_to_dsc = True
    tc.num_moves = int(getattr(tc.args, "num_moves", 1))
    tc.dsc_conn_type = getattr(tc.args, "dsc_con_type", "oob")

    if hasattr(tc.args, "conntrack"):
        tc.detailed = True
    else:
        tc.detailed = False

    if hasattr(tc.args, "skip_teardown"):
        api.Logger.info("Setting tc to skip teardown")
        tc.skip_teardown = True
        #if tc.args.skip_teardown == "True":
        #    tc.skip_teardown = True

    vm_utils.increase_timeout()

    getNonNaplesNodes(tc)
    if arping.ArPing(tc) != api.types.status.SUCCESS:
        api.Logger.info("arping failed on setup")
    if ping.TestPing(tc, 'local_only', 'ipv4',
                     64) != api.types.status.SUCCESS or ping.TestPing(
                         tc, 'remote_only', 'ipv4',
                         64) != api.types.status.SUCCESS:
        api.Logger.info("ping test failed on setup")
        return api.types.status.FAILURE
    '''
    identify workloads to be moved, as we want to run fuz if wl being moved is involved
    '''
    vm_utils.create_move_info(tc, tc.vm_dsc_to_dsc)

    vm_utils.get_vm_dbg_stats(tc)

    #Start Fuz
    ret = vm_utils.start_fuz(tc)
    if ret != api.types.status.SUCCESS:
        api.Logger.error("Fuz start failed")
        return api.types.status.FAILURE

    return api.types.status.SUCCESS