Beispiel #1
0
    def test_pool_3(self):
        n = JubaNode('localhost', range(10000,10003), None, '/tmp', [])

        port1 = n.lease_port()
        port2 = n.lease_port()

        self.assertEqual(10000, port1)
        self.assertEqual(10001, port2)
        self.assertEqual(3, len(n._ports))
        self.assertEqual(1, len(n._free_ports))
        self.assertEqual(2, n.ports_used())

        n.free_port(port1)
        n.free_port(port2)

        self.assertEqual(3, len(n._ports))
        self.assertEqual(3, len(n._free_ports))
        self.assertEqual(0, n.ports_used())

        port3 = n.lease_port()

        self.assertEqual(10002, port3)

        port4 = n.lease_port()

        self.assertEqual(10000, port4)
Beispiel #2
0
    def test_pool_skip(self):
        n = JubaNode('localhost', range(10000,10003), None, '/tmp', [])

        port1 = n.lease_port()
        port2 = n.lease_port()
        port3 = n.lease_port()

        self.assertRaises(JubaSkipTest, n.lease_port)
Beispiel #3
0
    def test_pool_doublefree(self):
        n = JubaNode('localhost', range(10000,10003), None, '/tmp', [])

        port1 = n.lease_port()
        n.free_port(port1)

        self.assertRaises(JubaTestAssertionError, n.free_port, port1)
Beispiel #4
0
    def test_pool_1(self):
        n = JubaNode('localhost', range(10,11), None, '/tmp', [])

        port = n.lease_port()

        self.assertEqual(10, port)
        self.assertEqual(1, len(n._ports))
        self.assertEqual(0, len(n._free_ports))

        n.free_port(port)

        self.assertEqual(1, len(n._ports))
        self.assertEqual(1, len(n._free_ports))
Beispiel #5
0
    def test_pool_1(self):
        n = JubaNode('localhost', range(10,11), None, '/tmp', [])

        port = n.lease_port()

        self.assertEqual(10, port)
        self.assertEqual(1, len(n._ports))
        self.assertEqual(0, len(n._free_ports))

        n.free_port(port)

        self.assertEqual(1, len(n._ports))
        self.assertEqual(1, len(n._free_ports))