Esempio n. 1
0
    def test_delete_with_hm_dissociates_hm(self):
        pool = fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS')
        hm = fake_objs.FakeHM("TCP")
        hm.pools.append(fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS'))
        pool.members = [fake_objs.FakeMember()]
        pool.health_monitors_status = [{'monitor_id': 'hm1', "pools": [pool]}]

        self.a.pool.neutron.openstack_driver._pool_get_hm.return_value = hm

        self._test_delete(pool)
        self.a.last_client.slb.service_group.update.assert_called_with(
            "id1", health_monitor="", health_check_disable=True)
Esempio n. 2
0
 def test_delete_without_health_monitor(self):
     pool = fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS')
     pool.members = [fake_objs.FakeMember()]
     pool.health_monitors_status = []
     self._test_delete(pool)
     (self.a.last_client.slb.service_group.delete.assert_called_with(
         pool.id))
Esempio n. 3
0
    def test_create(self):
        methods = {
            'ROUND_ROBIN':
            self.a.last_client.slb.service_group.ROUND_ROBIN,
            'LEAST_CONNECTIONS':
            self.a.last_client.slb.service_group.LEAST_CONNECTION,
            'SOURCE_IP':
            self.a.last_client.slb.service_group.WEIGHTED_LEAST_CONNECTION,
        }
        protocols = {
            'TCP': self.a.last_client.slb.service_group.TCP,
            'UDP': self.a.last_client.slb.service_group.UDP,
        }

        for p in protocols.keys():
            for m in methods.keys():
                self.a.reset_mocks()
                saw_exception = False

                pool = fake_objs.FakePool(p, m)
                self.a.pool.create(None, pool)

                self.print_mocks()
                (self.a.last_client.slb.service_group.create.assert_called())

                if not saw_exception:
                    n = str(self.a.last_client.mock_calls).index(
                        'slb.service_group.create')
                    self.assertTrue(n >= 0)
Esempio n. 4
0
 def test_stats(self):
     pool = fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS')
     z = self.a.pool
     z.neutron.pool_get_tenant_id = lambda x, y: 'hello'
     z._get_vip_id = lambda x, y: '2.2.2.2'
     z.stats(None, pool.id)
     self.print_mocks()
     s = str(self.a.last_client.mock_calls)
     self.assertTrue(s.index('slb.virtual_server.stats') >= 0)
Esempio n. 5
0
    def test_dissociate_calls_service_group_update(self):
        fake_pool = fake_objs.FakePool()
        fake_hm = fake_objs.FakeHM('HTTP')
        fake_hm.id = "id1"
        fake_hm.pools = []
        fake_hm.pools.append(fake_pool)
        fake_hm.tenant_id = "tenv1"

        self.a.hm.dissociate(self.a.last_client, None, fake_hm, fake_pool.id)
        self.a.last_client.slb.service_group.update.assert_called(
            fake_pool.id, health_monitor="", health_check_disable=True)
Esempio n. 6
0
    def test_delete(self):
        pool = fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS')
        pool.members = [fake_objs.FakeMember()]
        pool.health_monitors_status = [{'monitor_id': 'hm1', "pools": [pool]}]
        self.a.pool.neutron.openstack_driver._pool_get_hm.return_value = fake_objs.FakeHM(
        )

        self._test_delete(pool)

        (self.a.last_client.slb.service_group.delete.assert_called_with(
            pool['id']))
Esempio n. 7
0
    def test_delete(self):
        expected = fake_objs.FakePool()
        fakehm = fake_objs.FakeHM('HTTP')
        fakehm.tenant_id = 'tenv1'
        fakehm.id = 'fedcba'
        fakehm.pools.append(expected)

        self.a.hm.openstack_driver.plugin.get_pool.return_value = expected
        self.a.hm.openstack_driver._hm_binding_count.return_value = 1

        self.a.hm.delete(None, fakehm, 'p01')
        self.a.last_client.slb.hm.delete.assert_called_with(fakehm.id)
Esempio n. 8
0
    def test_dissociate_calls_hm_delete(self):
        fake_pool = fake_objs.FakePool()
        fake_hm = fake_objs.FakeHM('HTTP')
        fake_pool.health_monitor_status = [{"monitor_id": fake_hm.id}]
        fake_hm.id = "id1"
        fake_hm.pools = []
        fake_hm.pools.append(fake_pool)
        fake_hm.tenant_id = "tenv1"

        self.a.hm.dissociate(self.a.last_client, None, fake_hm, fake_pool.id)
        self.a.last_client.hm.service_group.delete.assert_called(
            self.a.hm._meta_name(fake_hm))
Esempio n. 9
0
    def test_delete_updates_pool_health_monitor(self):
        expected = fake_objs.FakePool()
        fakehm = fake_objs.FakeHM('HTTP')
        fakehm.tenant_id = 'tenv1'
        fakehm.id = 'fedcba'
        fakehm.pools = []
        fakehm.pools.append(expected)

        self.a.hm.openstack_driver._pool_get_hm.return_value = fakehm
        self.a.hm.openstack_driver.plugin.get_pool.return_value = expected
        self.a.hm.openstack_driver._hm_binding_count.return_value = 1

        pool_name = self.a.hm._pool_name(None, 'p01')
        self.a.hm.delete(None, fakehm, 'p01')

        self.a.last_client.slb.service_group.update.assert_called_with(
            pool_name, health_monitor='', health_check_disable=True)
Esempio n. 10
0
 def test_delete_removes_monitor(self):
     pool = fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS')
     pool.members = [fake_objs.FakeMember()]
     pool.health_monitors_status = [{'monitor_id': "hm1"}]
     self._test_delete(pool)
     self.a.last_client.slb.hm.delete.assert_called()
Esempio n. 11
0
 def test_update(self):
     old_pool = fake_objs.FakePool('TCP', 'LEAST_CONNECTIONS')
     pool = fake_objs.FakePool('TCP', 'ROUND_ROBIN')
     self.a.pool.update(None, old_pool, pool)
     self.print_mocks()
     self.a.last_client.slb.service_group.update.assert_called()