def test_delete(self):
        members = [[], [test_base.FakeMember()]]
        hms = [None, test_base.FakeHM('PING')]
        persistences = [None, 'SOURCE_IP', 'HTTP_COOKIE']
        listeners = [False, True]

        for m in members:
            for hm in hms:
                for pers in persistences:
                    for lst in listeners:
                        self.a.reset_mocks()

                        pool = test_base.FakePool('TCP', 'ROUND_ROBIN',
                                                  pers, lst,
                                                  members=m,
                                                  hm=hm)
                        self.a.pool.delete(None, pool)

                        self.print_mocks()

                        (self.a.last_client.slb.service_group.delete.
                            assert_called_with(pool.id))

                        if pers == 'SOURCE_IP':
                            (self.a.last_client.slb.template.
                                src_ip_persistence.delete.
                                assert_called_with(pool.id))
                        elif pers == 'HTTP_COOKIE':
                            (self.a.last_client.slb.template.
                                cookie_persistence.delete.
                                assert_called_with(pool.id))
 def test_delete(self):
     m = test_base.FakeHM('HTTP')
     self.a.hm.tenant_id = "tenant-id"
     self.a.hm.delete(None, m)
     self.a.openstack_driver.health_monitor.successful_completion.assert_called_with(
         None, m, delete=True)
     self.a.last_client.slb.hm.delete.assert_called_with('fake-hm-id-001')
 def test_create_http_with_pool(self):
     m = test_base.FakeHM('HTTP', pool=mock.MagicMock())
     self.a.hm.create(None, m)
     self.assert_hm(m, self.a.last_client.slb.hm.HTTP, 'GET', '/', '200')
     self.a.last_client.slb.service_group.update.assert_called_with(
         m.pool.id,
         health_monitor='fake-hm-id-001',
         health_check_disable=False)
Esempio n. 4
0
 def test_delete_with_pool(self):
     m = test_base.FakeHM('TCP', pool=mock.MagicMock())
     self.a.hm.delete(None, m)
     self.a.openstack_driver.health_monitor.db_delete.assert_called_with(
         None, 'fake-hm-id-001')
     self.a.last_client.slb.service_group.update.assert_called_with(
         m.pool.id, health_monitor='')
     self.a.last_client.slb.hm.delete.assert_called_with('fake-hm-id-001')
 def test_delete_with_pool(self):
     m = test_base.FakeHM('TCP', pool=mock.MagicMock())
     self.a.hm.delete(None, m)
     self.a.openstack_driver.health_monitor.successful_completion.assert_called_with(
         None, m, delete=True)
     self.a.last_client.slb.service_group.update.assert_called_with(
         m.pool.id, health_monitor='', health_check_disable=True)
     self.a.last_client.slb.hm.delete.assert_called_with('fake-hm-id-001')
 def test_update_tcp_add_pool(self):
     m = test_base.FakeHM('TCP', pool=mock.MagicMock())
     self.test_update_tcp(m=m)
     self.print_mocks()
     self.a.last_client.slb.service_group.update.assert_called_with(
         m.pool.id,
         health_monitor='fake-hm-id-001',
         health_check_disable=False)
Esempio n. 7
0
 def test_update_tcp(self, m_old=None, m=None):
     if m_old is None:
         m_old = test_base.FakeHM('TCP')
     if m is None:
         m = test_base.FakeHM('TCP')
     m.delay = 20
     self.a.hm.update(None, m_old, m)
     self.a.openstack_driver.health_monitor.active.assert_called_with(
         None, 'fake-hm-id-001')
     self.a.last_client.slb.hm.update.assert_called_with(
         'fake-hm-id-001',
         self.a.last_client.slb.hm.TCP,
         20,
         7,
         8,
         method=None,
         url=None,
         expect_code=None)
Esempio n. 8
0
    def test_dissociate_calls_service_group_update(self):
        fake_pool = test_base.FakePool()
        fake_hm = test_base.FakeHM()
        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. 9
0
    def test_delete(self):
        expected = test_base.FakePool()
        fakehm = test_base.FakeHM()
        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. 10
0
    def test_dissociate_calls_hm_delete(self):
        fake_pool = test_base.FakePool()
        fake_hm = test_base.FakeHM()
        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. 11
0
    def test_delete(self):
        pool = self.fake_pool('TCP', 'LEAST_CONNECTIONS')
        pool['members'] = [test_handler_member._fake_member()]
        pool['health_monitors_status'] = [{
            'monitor_id': 'hm1',
            "pools": [pool]
        }]
        self.a.pool.neutron.openstack_driver._pool_get_hm.return_value = test_base.FakeHM(
        )

        self._test_delete(pool)

        (self.a.last_client.slb.service_group.delete.assert_called_with(
            pool['id']))
Esempio n. 12
0
    def test_delete_updates_pool_health_monitor(self):
        expected = test_base.FakePool()
        fakehm = test_base.FakeHM()
        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)
 def test_create_http(self):
     m = test_base.FakeHM('HTTP')
     self.a.hm.create(None, m)
     self.assert_hm(m, self.a.last_client.slb.hm.HTTP, 'GET', '/', '200')
 def test_create_tcp(self):
     m = test_base.FakeHM('TCP')
     self.a.hm.create(None, m)
     self.print_mocks()
     self.assert_hm(m, self.a.last_client.slb.hm.TCP, None, None, None)
Esempio n. 15
0
 def test_delete(self):
     self.a.hm.delete(None, test_base.FakeHM('HTTP'))
     self.a.openstack_driver.health_monitor.db_delete.assert_called_with(
         None, 'fake-hm-id-001')
     self.a.last_client.slb.hm.delete.assert_called_with('fake-hm-id-001')
Esempio n. 16
0
 def test_update_tcp_delete_pool(self):
     m_old = test_base.FakeHM('TCP', pool=mock.MagicMock())
     self.test_update_tcp(m_old=m_old)
     self.a.last_client.slb.service_group.update.assert_called_with(
         m_old.pool.id, health_monitor='')
Esempio n. 17
0
 def test_create_ping(self):
     self.a.hm.create(None, test_base.FakeHM('PING'))
     self.assert_hm(self.a.last_client.slb.hm.ICMP, None, None, None)
Esempio n. 18
0
 def test_create_https(self):
     self.a.hm.create(None, test_base.FakeHM('HTTPS'))
     self.assert_hm(self.a.last_client.slb.hm.HTTPS, 'GET', '/', '200')
Esempio n. 19
0
 def test_create_tcp(self):
     self.a.hm.create(None, test_base.FakeHM('TCP'))
     self.assert_hm(self.a.last_client.slb.hm.TCP, None, None, None)