Beispiel #1
0
class VlanMapTest(unittest.TestCase):

    def setUp(self):
        self.vmap = VlanMap()

    def tearDown(self):
        pass

    def testAddVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.assertTrue(vlan_id == 2)

    def testReleaseVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.vmap.release("foobar")
        self.assertTrue(self.vmap.get(vlan_id) is None)

    def testAddRelease4kVlans(self):
        vlan_id = None
        for id in range(2, 4000):
            vlan_id = self.vmap.acquire(id)
            self.assertTrue(vlan_id == id)
        for id in range(2, 4000):
            self.vmap.release(id)
            self.assertTrue(self.vmap.get(id) is None)
Beispiel #2
0
class VlanMapTest(unittest.TestCase):

    def setUp(self):
        self.vmap = VlanMap()

    def tearDown(self):
        pass

    def testAddVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.assertTrue(vlan_id == 2)

    def testReleaseVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.vmap.release("foobar")
        self.assertTrue(self.vmap.get(vlan_id) == None)
Beispiel #3
0
class VlanMapTest(unittest.TestCase):

    def setUp(self):
        self.vmap = VlanMap()

    def tearDown(self):
        pass

    def testAddVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.assertTrue(vlan_id == 2)

    def testReleaseVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.vmap.release("foobar")
        self.assertTrue(self.vmap.get(vlan_id) is None)
class VlanMapTest(unittest.TestCase):

    def setUp(self):
        self.vmap = VlanMap()

    def tearDown(self):
        pass

    def testAddVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.assertTrue(vlan_id >= VlanMap.VLAN_MIN)
        self.assertTrue(vlan_id <= VlanMap.VLAN_MAX)

    def testReleaseVlan(self):
        vlan_id = self.vmap.acquire("foobar")
        self.vmap.release("foobar")

    def testAddRelease4kVlans(self):
        vlan_id = None
        num_vlans = VlanMap.VLAN_MAX - VlanMap.VLAN_MIN
        for id in xrange(num_vlans):
            vlan_id = self.vmap.acquire("net-%s" % id)
            self.assertTrue(vlan_id >= VlanMap.VLAN_MIN)
            self.assertTrue(vlan_id <= VlanMap.VLAN_MAX)
        for id in xrange(num_vlans):
            self.vmap.release("net-%s" % id)

    def testAlreadyUsed(self):
        existing_vlan = 2
        self.vmap.already_used(existing_vlan, "net1")
        try:
            # this value is high enough that we will exhaust
            # all VLANs.  We want to make sure 'existing_vlan'
            # is never reallocated.
            num_vlans = VlanMap.VLAN_MAX - VlanMap.VLAN_MIN + 1
            for x in xrange(num_vlans):
                vlan_id = self.vmap.acquire("net-%x" % x)
                self.assertTrue(vlan_id != existing_vlan)

            self.fail("Did not run out of VLANs as expected")
        except NoFreeVLANException:
            pass  # Expected exit
Beispiel #5
0
 def setUp(self):
     self.vmap = VlanMap()
Beispiel #6
0
 def setUp(self):
     self.vmap = VlanMap()