Ejemplo n.º 1
0
def TestCaseSetup(tc):
    tc.AddIgnorePacketField('UDP', 'sport')
    tc.AddIgnorePacketField('UDP', 'chksum')
    tc.AddIgnorePacketField('TCP', 'chksum')
    if not utils.IsDryRun():
        return learn.ClearLearnStatistics()
    return True
Ejemplo n.º 2
0
def TestCaseStepVerify(tc, step):
    if utils.IsDryRun(): return True
    if "LEARN_MAC_IP_WITH_ARP" in tc.module.name:
        # verify pdsctl show learn mac/ip produced correct output
        # TODO: verify show vnic and show mapping output is correct
        ep_mac = learn.EpMac(tc.config.localmapping)
        ep_ip = learn.EpIp(tc.config.localmapping)
        if learn.ExistsOnDevice(ep_mac) and learn.ExistsOnDevice(ep_ip):
            stats = learn.GetLearnStatistics()
            if not stats:
                return False
            return stats['pktsrcvd'] == 1 and \
                    stats['pktssent'] == 1 and \
                    stats['maclearnevents'][1]['count'] == 1 and \
                    stats['iplearnevents'][1]['count'] == 1
        return False
    elif tc.module.name == "RECV_ARP_PROBE_AND_REPLY":
        # verify age is reflected correctly
        if step.step_id == 1:
            ep_ip = learn.EpIp(tc.config.localmapping)
            return learn.VerifyIPAgeRefreshed(tc, ep_ip)
        return True
    elif tc.module.name == "RECV_ARP_PROBES_AND_TIMEOUT_MAC_IP":
        # verify IP is timed out in step 3 and mac in step 4
        if step.step_id == 3:
            ep_ip = learn.EpIp(tc.config.localmapping)
            return not learn.ExistsOnDevice(ep_ip)
        elif step.step_id == 4:
            ep_mac = learn.EpMac(tc.config.localmapping)
            return not learn.ExistsOnDevice(ep_mac)
        else:
            return True
    elif tc.module.name == "CLEAR_MAC":
        # clear the learnt MAC
        ep_mac = learn.EpMac(tc.config.localmapping)
        return learn.ClearOnDevice(ep_mac) and \
                not learn.ExistsOnDevice(ep_mac) and \
                learn.ClearLearnStatistics()
    elif tc.module.name == "LEARN_MAC_WITH_RARP":
        ep_mac = learn.EpMac(tc.config.localmapping)
        if learn.ExistsOnDevice(ep_mac):
            stats = learn.GetLearnStatistics()
            if not stats:
                return False
            return stats['pktsrcvd'] == 1 and \
                    stats['maclearnevents'][1]['count'] == 1
        return False
    return True
Ejemplo n.º 3
0
def Teardown(infra, module):
    if utils.IsDryRun(): return True
    if module.name == "LEARN_NEG_IP_NOT_IN_SUBNET":
        return learn.ClearAllLearntMacs() and learn.ClearLearnStatistics()
    return True
Ejemplo n.º 4
0
def TestCaseStepTeardown(tc, step):
    if not utils.IsDryRun():
        return learn.ClearLearnStatistics() and learn.ClearAllLearntMacs()
    return True