예제 #1
0
    def calculateExpectedTraffic(self, tgDutLinks):
        """
        Verifies that the whole transmitted traffic was received and no packet loss occurred nor errors
        :param tgDutLinks: BastTest.TGDutLinks dict
        """
        funcname = GetFunctionName(self.calculateExpectedTraffic)
        self.logger.debug(funcname +
                          'Verify received traffic on ports is as expected')
        rxPortsExpectedCounters = {
            v: 0
            for v in set(chain(*self._rxInterfaces.values()))
        }
        acceptablePrecentLoss = 0.045
        for txNum, txDits in self._txInterfaces.items():
            for vlanTested in txDits['vlan_tested']:
                try:
                    for rxPort in self._rxInterfaces[str(vlanTested)]:
                        rxDutPort = tgDutLinks[int(rxPort)].DutDevPort
                        rxPvid = Bridge1QConfig.getPVID(rxDutPort)
                        isTagged = Bridge1QConfig.isTagged(
                            rxDutPort, vlanTested)

                        if rxPvid and rxPvid == vlanTested and isTagged and 'X' in txDits[
                                'packet_vids']:
                            rxPortsExpectedCounters[rxPort] += (txDits['vlan_tested'][vlanTested] - 1) \
                                                               * self.numOfPackets + \
                                                               self.numOfPackets * (1 - acceptablePrecentLoss)
                        else:
                            rxPortsExpectedCounters[rxPort] += txDits[
                                'vlan_tested'][vlanTested] * self.numOfPackets
                except KeyError:
                    continue

        return rxPortsExpectedCounters
예제 #2
0
    def setRxAndNonRxPorts(self, tgDutLinks):
        """
        Maps all expected receiving ports and non-rx ports
        :param tgDutLinks: BastTest.TGDutLinks dict
        """
        Bridge1QConfig.getVlanSettings()
        vlanConf = Bridge1QConfig.interfaceVlanSettings()
        TGPorts2DutPorts = {
            tgDutLinks[int(tgPort)].DutDevPort.name: tgPort
            for tgPort in self._txInterfaces
        }
        for port in TGPorts2DutPorts:
            dits = self._txInterfaces[TGPorts2DutPorts[port]]
            for _ in range(dits['packet_vids'].count('X') +
                           dits['packet_vids'].count(0)):
                try:
                    if vlanConf[port]['pvid']:
                        dits['vlan_tested'].append(vlanConf[port]['pvid'])
                except TypeError:
                    continue

        for port in self._txInterfaces:
            self._txInterfaces[port]['vlan_tested'] = Counter(
                self._txInterfaces[port]['vlan_tested'])

        return \
            [[int(t) for t in Bridge1QConfig.getVIDs(x) if
              int(t) in self._txInterfaces[TGPorts2DutPorts[x]]['packet_vids']
              or t == Bridge1QConfig.getPVID(x)] for x, v in vlanConf.items() if
             x in TGPorts2DutPorts][0]
예제 #3
0
파일: TaggedAPI.py 프로젝트: Stas0k/testing
 def addTriggers(self, tgDutLinks, srcMac='AA:AA:AA:AA:AA:00', mask=None):
     for txPort, txDits in self._txInterfaces.items():
         for vlanTested in txDits['vlan_tested']:
             try:
                 for rxPort in self._rxInterfaces[vlanTested]:
                     rxDutPort = tgDutLinks[rxPort].DutDevPort.name
                     isTagged = Bridge1QConfig.isTagged(rxDutPort, str(vlanTested))
                     if isTagged and not len(
                             [x for x in Bridge1QConfig.getVIDs(rxDutPort).values() if x != 'tagged']):
                         self._addVlanTagging(tgDutLinks[rxPort], toHex(vlanTested), txPort=tgDutLinks[int(txPort)])
             except KeyError as e:
                 if e.args[0] in txDits['vlan_tested'] or e.args[0] == 'X':
                     continue
                 raise KeyError
예제 #4
0
 def __init__(self, testClass):
     super(GenericVlanAPI, self).__init__(testClass)
     self._bridge = Bridge1QConfig()
     self._interfaceToVlanMapping = []
     self._txInterfaces = {}
     self._rxInterfaces = {}
     self._nonRxPorts = []
예제 #5
0
    def addTriggers(self, tgDutLinks, srcMac='AA:AA:AA:AA:AA:00', mask=None):
        """
        :param tgDutLinks: BastTest.TGDutLinks dict
        :param srcMac: srcMac: the source MAC of the packet
        :param mask:
        :return:
        """
        def addTriggers(vlanTested):
            for port in self._rxInterfaces[vlanTested]:
                rxPort = self._testClassref.TGDutLinks[port].TGPort
                self._addTriggers(rxPort, mac.sa.value, mask, mac.da.value)

        for port in self._nonRxPorts:
            self._addTriggers(port.TGPort, srcMac, '00 00 00 00 00 FF')

        for txPort, txDits in self._txInterfaces.items():
            txTGDutLinkPort = tgDutLinks[int(txPort)]
            for vlanTested in txDits['packet_vids']:
                mac = txTGDutLinkPort.TGPort.streams[
                    f'testPacketVID#{vlanTested}'].packet.mac
                try:
                    addTriggers(str(vlanTested))
                except KeyError as e:
                    if e.args[0] in ('X', 0):
                        pvid = Bridge1QConfig.getPVID(
                            txTGDutLinkPort.DutDevPort)
                        if pvid:
                            addTriggers(pvid)
            srcMac = srcMac[:-1] + txPort
예제 #6
0
파일: TaggedAPI.py 프로젝트: Stas0k/testing
 def addTriggers(self, tgDutLinks, srcMac='AA:AA:AA:AA:AA:00', mask=None):
     super(TrunkModeMultiBroadCastAPI, self).addTriggers(tgDutLinks, srcMac, mask)
     for rxPort in list(self._rxInterfaces.values())[-1]:
         vlanTested = list(self._rxInterfaces.keys())[-1]
         GenericVlanAPI._addTriggers(tgDutLinks[rxPort].TGPort, srcMac, mask)
         isTagged = Bridge1QConfig.isTagged(tgDutLinks[rxPort].DutDevPort.name, str(vlanTested))
         if isTagged:
             self._addVlanTagging(tgDutLinks[rxPort], toHex(vlanTested), vlanMask='0F')
예제 #7
0
 def verifyingMaxVlans(self):
     funcname = GetFunctionName(self.verifyingMaxVlans)
     max_vlans1 = self._testClassref.TestCaseData["vlans_sizes"][
         self._testClassref.TestData.DutInfo.Board_Model]["index1"]
     max_vlans2 = self._testClassref.TestCaseData["vlans_sizes"][
         self._testClassref.TestData.DutInfo.Board_Model]["index2"]
     total = max_vlans1 + max_vlans2
     max_instances = self._testClassref.TestCaseData["STP"]["max_instances"]
     ret = len(
         Bridge1QConfig.getVIDs(
             self._testClassref.TGDutLinks[1].DutDevPort)) + len(
                 Bridge1QConfig.getVIDs(
                     self._testClassref.TGDutLinks[2].DutDevPort))
     if ret < total:
         self.FailTheTest(
             f"{funcname} {ret} max vlans didn't match expected {total} amount"
         )
예제 #8
0
    def setupStream(self,
                    tgDutLinks,
                    srcMac='AA:AA:AA:AA:AA:00',
                    dstMac='ff:ff:ff:ff:ff:ff'):
        """
        :param tgDutLinks: BastTest.TGDutLinks dict
        :param srcMac: the source MAC of the packet
        :param dstMac: the destination MAC of the packet
        """
        super(GenericVlanUnicastAPI, self).setupStream(tgDutLinks, srcMac,
                                                       dstMac)
        for vlan, learningPortNum in self._rxInterfaces.items():
            learningPort = tgDutLinks[learningPortNum[-1]].TGPort
            if f'learningPacket#{vlan}' not in learningPort.streams:
                learningPort.add_stream(f'learningPacket#{vlan}')
                stream = learningPort.streams[f'learningPacket#{vlan}']
                stream.packet.mac.da.value = dstMac
                stream.packet.mac.sa.value = '00' + MAC.MacManager(
                ).GenerateRandomMac()[2:]
                stream.control.packets_per_burst = 1
                stream.control.mode = TGEnums.STREAM_TRANSMIT_MODE.ADVANCE_TO_NEXT_STREAM
                if Bridge1QConfig.isTagged(
                        tgDutLinks[learningPortNum[-1]].DutDevPort, vlan):
                    stream.packet.add_vlan(f'VID#{vlan}')
                    stream.packet.vlans[f'VID#{vlan}'].vid.value = vlan
                    stream.packet.size = self._packetSize + 4

        def setMacDest(vlanTested):
            stream.packet.mac.da.value = \
                tgDutLinks[self._rxInterfaces[vlanTested][-1]].TGPort.streams[
                    f'learningPacket#{vlanTested}'].packet.mac.sa.value

        for txPort, txDits in self._txInterfaces.items():
            for vlanTested in txDits['packet_vids']:
                stream = tgDutLinks[int(
                    txPort)].TGPort.streams[f'testPacketVID#{vlanTested}']
                try:
                    setMacDest(str(vlanTested))
                except KeyError as e:
                    if e.args[0] in ('X', '0'):
                        vlanTested = Bridge1QConfig.getPVID(
                            tgDutLinks[int(txPort)].DutDevPort)
                        setMacDest(vlanTested)
예제 #9
0
파일: TaggedAPI.py 프로젝트: Stas0k/testing
    def addTriggers(self, tgDutLinks, srcMac='AA:AA:AA:AA:AA:00', mask=None):
        super(TrunkModeUnicastAPI, self).addTriggers(tgDutLinks, srcMac, mask)
        vlanTested = list(self._rxInterfaces.keys())[-1]
        GenericVlanAPI._addTriggers(tgDutLinks[self._rxInterfaces[vlanTested][-1]].TGPort, srcMac, srcMask=mask)
        isTagged = Bridge1QConfig.isTagged(tgDutLinks[self._rxInterfaces[vlanTested][-1]].DutDevPort, str(vlanTested))
        if isTagged:
            self._addVlanTagging(tgDutLinks[self._rxInterfaces[vlanTested][-1]], toHex(vlanTested), vlanMask='0F')

        for port in self._nonRxPorts:
            GenericVlanAPI._addTriggers(port.TGPort, srcMac, '00 00 00 00 00 FF')
예제 #10
0
 def __init__(self, testClass):
     super(RoutedAclAPI, self).__init__(testClass)
     self._bridge = Bridge1QConfig(SwitchDevDutInterface('br0'))
예제 #11
0
 def removeInterfaceFromVlan(self, dev, vlan):
     funcname = GetFunctionName(self.removeInterfaceFromVlan)
     ret = Bridge1QConfig.removeInterfaceFromVlan(dev, str(vlan))
     if ret:
         self.FailTheTest(
             f"{funcname} {ret} Could not remove port {dev} from vlan")
예제 #12
0
 def addInterfaceToVlan(self, dev, vlan=1):
     funcname = GetFunctionName(self.addInterfaceToVlan)
     ret = Bridge1QConfig.addInterfaceToVlan(dev, str(vlan))
     if ret:
         self.FailTheTest(
             f"{funcname} {ret} Unable to add port {dev} to vlan")