octavia 12.0.0.0rc2__py3-none-any.whl → 13.0.0.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- octavia/amphorae/backends/agent/api_server/osutils.py +1 -0
- octavia/amphorae/backends/agent/api_server/plug.py +21 -7
- octavia/amphorae/backends/agent/api_server/templates/amphora-netns.systemd.j2 +2 -2
- octavia/amphorae/backends/agent/api_server/util.py +21 -0
- octavia/amphorae/backends/health_daemon/health_daemon.py +9 -3
- octavia/amphorae/backends/health_daemon/health_sender.py +2 -0
- octavia/amphorae/backends/utils/interface.py +14 -6
- octavia/amphorae/backends/utils/interface_file.py +6 -3
- octavia/amphorae/backends/utils/keepalivedlvs_query.py +8 -9
- octavia/amphorae/drivers/driver_base.py +1 -2
- octavia/amphorae/drivers/haproxy/rest_api_driver.py +11 -25
- octavia/amphorae/drivers/health/heartbeat_udp.py +34 -24
- octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py +3 -12
- octavia/amphorae/drivers/noop_driver/driver.py +3 -5
- octavia/api/common/pagination.py +4 -4
- octavia/api/drivers/amphora_driver/v2/driver.py +11 -5
- octavia/api/drivers/driver_agent/driver_get.py +22 -14
- octavia/api/drivers/driver_agent/driver_updater.py +8 -4
- octavia/api/drivers/utils.py +4 -2
- octavia/api/healthcheck/healthcheck_plugins.py +4 -2
- octavia/api/root_controller.py +4 -1
- octavia/api/v2/controllers/amphora.py +35 -38
- octavia/api/v2/controllers/availability_zone_profiles.py +43 -33
- octavia/api/v2/controllers/availability_zones.py +22 -18
- octavia/api/v2/controllers/flavor_profiles.py +37 -28
- octavia/api/v2/controllers/flavors.py +19 -15
- octavia/api/v2/controllers/health_monitor.py +44 -33
- octavia/api/v2/controllers/l7policy.py +52 -40
- octavia/api/v2/controllers/l7rule.py +68 -55
- octavia/api/v2/controllers/listener.py +88 -61
- octavia/api/v2/controllers/load_balancer.py +52 -34
- octavia/api/v2/controllers/member.py +63 -52
- octavia/api/v2/controllers/pool.py +55 -42
- octavia/api/v2/controllers/quotas.py +5 -3
- octavia/api/v2/types/listener.py +15 -0
- octavia/cmd/octavia_worker.py +0 -3
- octavia/cmd/status.py +1 -4
- octavia/common/clients.py +25 -45
- octavia/common/config.py +64 -22
- octavia/common/constants.py +3 -2
- octavia/common/data_models.py +7 -1
- octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py +12 -1
- octavia/common/jinja/haproxy/combined_listeners/templates/macros.j2 +5 -2
- octavia/common/jinja/lvs/jinja_cfg.py +4 -2
- octavia/common/keystone.py +58 -5
- octavia/common/validate.py +35 -0
- octavia/compute/drivers/noop_driver/driver.py +6 -0
- octavia/controller/healthmanager/health_manager.py +3 -6
- octavia/controller/housekeeping/house_keeping.py +36 -37
- octavia/controller/worker/amphora_rate_limit.py +5 -4
- octavia/controller/worker/task_utils.py +57 -41
- octavia/controller/worker/v2/controller_worker.py +160 -103
- octavia/controller/worker/v2/flows/listener_flows.py +3 -0
- octavia/controller/worker/v2/flows/load_balancer_flows.py +9 -14
- octavia/controller/worker/v2/tasks/amphora_driver_tasks.py +152 -91
- octavia/controller/worker/v2/tasks/compute_tasks.py +4 -2
- octavia/controller/worker/v2/tasks/database_tasks.py +542 -400
- octavia/controller/worker/v2/tasks/network_tasks.py +119 -79
- octavia/db/api.py +26 -23
- octavia/db/base_models.py +2 -2
- octavia/db/healthcheck.py +2 -1
- octavia/db/migration/alembic_migrations/versions/632152d2d32e_add_http_strict_transport_security_.py +42 -0
- octavia/db/models.py +12 -2
- octavia/db/prepare.py +2 -0
- octavia/db/repositories.py +462 -482
- octavia/hacking/checks.py +1 -1
- octavia/network/base.py +0 -14
- octavia/network/drivers/neutron/allowed_address_pairs.py +92 -135
- octavia/network/drivers/neutron/base.py +65 -77
- octavia/network/drivers/neutron/utils.py +69 -85
- octavia/network/drivers/noop_driver/driver.py +0 -7
- octavia/statistics/drivers/update_db.py +10 -10
- octavia/tests/common/constants.py +91 -84
- octavia/tests/common/sample_data_models.py +13 -1
- octavia/tests/fixtures.py +32 -0
- octavia/tests/functional/amphorae/backend/agent/api_server/test_server.py +9 -10
- octavia/tests/functional/api/drivers/driver_agent/test_driver_agent.py +260 -15
- octavia/tests/functional/api/test_root_controller.py +3 -28
- octavia/tests/functional/api/v2/base.py +5 -3
- octavia/tests/functional/api/v2/test_amphora.py +18 -5
- octavia/tests/functional/api/v2/test_availability_zone_profiles.py +1 -0
- octavia/tests/functional/api/v2/test_listener.py +51 -19
- octavia/tests/functional/api/v2/test_load_balancer.py +10 -1
- octavia/tests/functional/db/base.py +31 -16
- octavia/tests/functional/db/test_models.py +27 -28
- octavia/tests/functional/db/test_repositories.py +407 -50
- octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py +2 -0
- octavia/tests/unit/amphorae/backends/agent/api_server/test_osutils.py +1 -1
- octavia/tests/unit/amphorae/backends/agent/api_server/test_plug.py +54 -6
- octavia/tests/unit/amphorae/backends/agent/api_server/test_util.py +35 -0
- octavia/tests/unit/amphorae/backends/health_daemon/test_health_daemon.py +8 -0
- octavia/tests/unit/amphorae/backends/health_daemon/test_health_sender.py +18 -0
- octavia/tests/unit/amphorae/backends/utils/test_interface.py +81 -0
- octavia/tests/unit/amphorae/backends/utils/test_interface_file.py +2 -0
- octavia/tests/unit/amphorae/backends/utils/test_keepalivedlvs_query.py +129 -5
- octavia/tests/unit/amphorae/drivers/haproxy/test_rest_api_driver_1_0.py +42 -20
- octavia/tests/unit/amphorae/drivers/health/test_heartbeat_udp.py +18 -20
- octavia/tests/unit/amphorae/drivers/keepalived/jinja/test_jinja_cfg.py +4 -4
- octavia/tests/unit/amphorae/drivers/noop_driver/test_driver.py +4 -1
- octavia/tests/unit/api/drivers/driver_agent/test_driver_get.py +3 -3
- octavia/tests/unit/api/drivers/driver_agent/test_driver_updater.py +11 -13
- octavia/tests/unit/base.py +6 -0
- octavia/tests/unit/cmd/test_interface.py +2 -2
- octavia/tests/unit/cmd/test_status.py +2 -2
- octavia/tests/unit/common/jinja/haproxy/combined_listeners/test_jinja_cfg.py +152 -1
- octavia/tests/unit/common/sample_configs/sample_configs_combined.py +10 -3
- octavia/tests/unit/common/test_clients.py +0 -39
- octavia/tests/unit/common/test_keystone.py +54 -0
- octavia/tests/unit/common/test_validate.py +67 -0
- octavia/tests/unit/controller/healthmanager/test_health_manager.py +8 -22
- octavia/tests/unit/controller/housekeeping/test_house_keeping.py +3 -64
- octavia/tests/unit/controller/worker/test_amphora_rate_limit.py +1 -1
- octavia/tests/unit/controller/worker/test_task_utils.py +44 -24
- octavia/tests/unit/controller/worker/v2/flows/test_load_balancer_flows.py +0 -1
- octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py +49 -26
- octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py +399 -196
- octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks_quota.py +37 -64
- octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py +3 -14
- octavia/tests/unit/controller/worker/v2/test_controller_worker.py +2 -2
- octavia/tests/unit/network/drivers/neutron/test_allowed_address_pairs.py +456 -561
- octavia/tests/unit/network/drivers/neutron/test_base.py +181 -194
- octavia/tests/unit/network/drivers/neutron/test_utils.py +14 -30
- octavia/tests/unit/statistics/drivers/test_update_db.py +7 -5
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/README.rst +1 -1
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/AUTHORS +4 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/METADATA +4 -4
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/RECORD +141 -189
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/entry_points.txt +1 -2
- octavia-13.0.0.0rc1.dist-info/pbr.json +1 -0
- octavia/api/drivers/amphora_driver/v1/__init__.py +0 -11
- octavia/api/drivers/amphora_driver/v1/driver.py +0 -547
- octavia/controller/queue/v1/__init__.py +0 -11
- octavia/controller/queue/v1/consumer.py +0 -64
- octavia/controller/queue/v1/endpoints.py +0 -160
- octavia/controller/worker/v1/__init__.py +0 -11
- octavia/controller/worker/v1/controller_worker.py +0 -1157
- octavia/controller/worker/v1/flows/__init__.py +0 -11
- octavia/controller/worker/v1/flows/amphora_flows.py +0 -610
- octavia/controller/worker/v1/flows/health_monitor_flows.py +0 -105
- octavia/controller/worker/v1/flows/l7policy_flows.py +0 -94
- octavia/controller/worker/v1/flows/l7rule_flows.py +0 -100
- octavia/controller/worker/v1/flows/listener_flows.py +0 -128
- octavia/controller/worker/v1/flows/load_balancer_flows.py +0 -692
- octavia/controller/worker/v1/flows/member_flows.py +0 -230
- octavia/controller/worker/v1/flows/pool_flows.py +0 -127
- octavia/controller/worker/v1/tasks/__init__.py +0 -11
- octavia/controller/worker/v1/tasks/amphora_driver_tasks.py +0 -453
- octavia/controller/worker/v1/tasks/cert_task.py +0 -51
- octavia/controller/worker/v1/tasks/compute_tasks.py +0 -335
- octavia/controller/worker/v1/tasks/database_tasks.py +0 -2756
- octavia/controller/worker/v1/tasks/lifecycle_tasks.py +0 -173
- octavia/controller/worker/v1/tasks/model_tasks.py +0 -41
- octavia/controller/worker/v1/tasks/network_tasks.py +0 -970
- octavia/controller/worker/v1/tasks/retry_tasks.py +0 -74
- octavia/tests/unit/api/drivers/amphora_driver/v1/__init__.py +0 -11
- octavia/tests/unit/api/drivers/amphora_driver/v1/test_driver.py +0 -824
- octavia/tests/unit/controller/queue/v1/__init__.py +0 -11
- octavia/tests/unit/controller/queue/v1/test_consumer.py +0 -61
- octavia/tests/unit/controller/queue/v1/test_endpoints.py +0 -189
- octavia/tests/unit/controller/worker/v1/__init__.py +0 -11
- octavia/tests/unit/controller/worker/v1/flows/__init__.py +0 -11
- octavia/tests/unit/controller/worker/v1/flows/test_amphora_flows.py +0 -474
- octavia/tests/unit/controller/worker/v1/flows/test_health_monitor_flows.py +0 -72
- octavia/tests/unit/controller/worker/v1/flows/test_l7policy_flows.py +0 -67
- octavia/tests/unit/controller/worker/v1/flows/test_l7rule_flows.py +0 -67
- octavia/tests/unit/controller/worker/v1/flows/test_listener_flows.py +0 -91
- octavia/tests/unit/controller/worker/v1/flows/test_load_balancer_flows.py +0 -431
- octavia/tests/unit/controller/worker/v1/flows/test_member_flows.py +0 -106
- octavia/tests/unit/controller/worker/v1/flows/test_pool_flows.py +0 -77
- octavia/tests/unit/controller/worker/v1/tasks/__init__.py +0 -11
- octavia/tests/unit/controller/worker/v1/tasks/test_amphora_driver_tasks.py +0 -792
- octavia/tests/unit/controller/worker/v1/tasks/test_cert_task.py +0 -46
- octavia/tests/unit/controller/worker/v1/tasks/test_compute_tasks.py +0 -634
- octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py +0 -2615
- octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks_quota.py +0 -415
- octavia/tests/unit/controller/worker/v1/tasks/test_lifecycle_tasks.py +0 -401
- octavia/tests/unit/controller/worker/v1/tasks/test_model_tasks.py +0 -44
- octavia/tests/unit/controller/worker/v1/tasks/test_network_tasks.py +0 -1788
- octavia/tests/unit/controller/worker/v1/tasks/test_retry_tasks.py +0 -47
- octavia/tests/unit/controller/worker/v1/test_controller_worker.py +0 -2096
- octavia-12.0.0.0rc2.dist-info/pbr.json +0 -1
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/LICENSE +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/README.rst +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/diskimage-create.sh +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/image-tests.sh +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/requirements.txt +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/test-requirements.txt +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/tox.ini +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/data/share/octavia/diskimage-create/version.txt +0 -0
- {octavia-12.0.0.0rc2.data → octavia-13.0.0.0rc1.data}/scripts/octavia-wsgi +0 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/LICENSE +0 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/WHEEL +0 -0
- {octavia-12.0.0.0rc2.dist-info → octavia-13.0.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,824 +0,0 @@
|
|
1
|
-
# Copyright 2018 Rackspace, US Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
4
|
-
# not use this file except in compliance with the License. You may obtain
|
5
|
-
# a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
12
|
-
# License for the specific language governing permissions and limitations
|
13
|
-
# under the License.
|
14
|
-
from unittest import mock
|
15
|
-
|
16
|
-
from octavia_lib.api.drivers import data_models as driver_dm
|
17
|
-
from octavia_lib.api.drivers import exceptions
|
18
|
-
from oslo_utils import uuidutils
|
19
|
-
|
20
|
-
from octavia.api.drivers.amphora_driver.v1 import driver
|
21
|
-
from octavia.common import constants as consts
|
22
|
-
from octavia.network import base as network_base
|
23
|
-
from octavia.tests.common import sample_data_models
|
24
|
-
from octavia.tests.unit import base
|
25
|
-
|
26
|
-
|
27
|
-
class TestAmphoraDriver(base.TestRpc):
|
28
|
-
def setUp(self):
|
29
|
-
super().setUp()
|
30
|
-
self.amp_driver = driver.AmphoraProviderDriver()
|
31
|
-
self.sample_data = sample_data_models.SampleDriverDataModels()
|
32
|
-
|
33
|
-
@mock.patch('octavia.common.utils.get_network_driver')
|
34
|
-
def test_create_vip_port(self, mock_get_net_driver):
|
35
|
-
mock_net_driver = mock.MagicMock()
|
36
|
-
mock_get_net_driver.return_value = mock_net_driver
|
37
|
-
mock_net_driver.allocate_vip.return_value = (self.sample_data.db_vip,
|
38
|
-
[])
|
39
|
-
|
40
|
-
provider_vip_dict, add_vips = self.amp_driver.create_vip_port(
|
41
|
-
self.sample_data.lb_id, self.sample_data.project_id,
|
42
|
-
self.sample_data.provider_vip_dict)
|
43
|
-
|
44
|
-
self.assertEqual(self.sample_data.provider_vip_dict, provider_vip_dict)
|
45
|
-
self.assertEqual([], add_vips)
|
46
|
-
|
47
|
-
@mock.patch('octavia.common.utils.get_network_driver')
|
48
|
-
def test_create_vip_port_without_port_security_enabled(
|
49
|
-
self, mock_get_net_driver):
|
50
|
-
mock_net_driver = mock.MagicMock()
|
51
|
-
mock_get_net_driver.return_value = mock_net_driver
|
52
|
-
network = mock.MagicMock()
|
53
|
-
network.port_security_enabled = False
|
54
|
-
mock_net_driver.get_network.return_value = network
|
55
|
-
mock_net_driver.allocate_vip.return_value = self.sample_data.db_vip
|
56
|
-
|
57
|
-
self.assertRaises(exceptions.DriverError,
|
58
|
-
self.amp_driver.create_vip_port,
|
59
|
-
self.sample_data.lb_id, self.sample_data.project_id,
|
60
|
-
self.sample_data.provider_vip_dict)
|
61
|
-
|
62
|
-
@mock.patch('octavia.common.utils.get_network_driver')
|
63
|
-
def test_create_vip_port_failed(self, mock_get_net_driver):
|
64
|
-
mock_net_driver = mock.MagicMock()
|
65
|
-
mock_get_net_driver.return_value = mock_net_driver
|
66
|
-
mock_net_driver.allocate_vip.side_effect = (
|
67
|
-
network_base.AllocateVIPException())
|
68
|
-
|
69
|
-
self.assertRaises(exceptions.DriverError,
|
70
|
-
self.amp_driver.create_vip_port,
|
71
|
-
self.sample_data.lb_id, self.sample_data.project_id,
|
72
|
-
self.sample_data.provider_vip_dict)
|
73
|
-
|
74
|
-
@mock.patch('octavia.common.utils.get_network_driver')
|
75
|
-
def test_create_vip_with_additional_vips(self, mock_get_net_driver):
|
76
|
-
mock_net_driver = mock.MagicMock()
|
77
|
-
mock_get_net_driver.return_value = mock_net_driver
|
78
|
-
mock_net_driver.allocate_vip.return_value = self.sample_data.db_vip
|
79
|
-
|
80
|
-
additional_vips = [{
|
81
|
-
consts.SUBNET_ID: uuidutils.generate_uuid()
|
82
|
-
}]
|
83
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
84
|
-
self.amp_driver.create_vip_port,
|
85
|
-
self.sample_data.lb_id, self.sample_data.project_id,
|
86
|
-
self.sample_data.provider_vip_dict, additional_vips)
|
87
|
-
|
88
|
-
# Load Balancer
|
89
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
90
|
-
def test_loadbalancer_create(self, mock_cast):
|
91
|
-
provider_lb = driver_dm.LoadBalancer(
|
92
|
-
loadbalancer_id=self.sample_data.lb_id)
|
93
|
-
self.amp_driver.loadbalancer_create(provider_lb)
|
94
|
-
payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id,
|
95
|
-
consts.FLAVOR: None,
|
96
|
-
consts.AVAILABILITY_ZONE: None}
|
97
|
-
mock_cast.assert_called_with({}, 'create_load_balancer', **payload)
|
98
|
-
|
99
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
100
|
-
def test_loadbalancer_delete(self, mock_cast):
|
101
|
-
provider_lb = driver_dm.LoadBalancer(
|
102
|
-
loadbalancer_id=self.sample_data.lb_id)
|
103
|
-
self.amp_driver.loadbalancer_delete(provider_lb)
|
104
|
-
payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id,
|
105
|
-
'cascade': False}
|
106
|
-
mock_cast.assert_called_with({}, 'delete_load_balancer', **payload)
|
107
|
-
|
108
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
109
|
-
def test_loadbalancer_failover(self, mock_cast):
|
110
|
-
self.amp_driver.loadbalancer_failover(self.sample_data.lb_id)
|
111
|
-
payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id}
|
112
|
-
mock_cast.assert_called_with({}, 'failover_load_balancer', **payload)
|
113
|
-
|
114
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
115
|
-
def test_loadbalancer_update(self, mock_cast):
|
116
|
-
old_provider_lb = driver_dm.LoadBalancer(
|
117
|
-
loadbalancer_id=self.sample_data.lb_id)
|
118
|
-
provider_lb = driver_dm.LoadBalancer(
|
119
|
-
loadbalancer_id=self.sample_data.lb_id, admin_state_up=True)
|
120
|
-
lb_dict = {'enabled': True}
|
121
|
-
self.amp_driver.loadbalancer_update(old_provider_lb, provider_lb)
|
122
|
-
payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id,
|
123
|
-
consts.LOAD_BALANCER_UPDATES: lb_dict}
|
124
|
-
mock_cast.assert_called_with({}, 'update_load_balancer', **payload)
|
125
|
-
|
126
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
127
|
-
def test_loadbalancer_update_name(self, mock_cast):
|
128
|
-
old_provider_lb = driver_dm.LoadBalancer(
|
129
|
-
loadbalancer_id=self.sample_data.lb_id)
|
130
|
-
provider_lb = driver_dm.LoadBalancer(
|
131
|
-
loadbalancer_id=self.sample_data.lb_id, name='Great LB')
|
132
|
-
lb_dict = {'name': 'Great LB'}
|
133
|
-
self.amp_driver.loadbalancer_update(old_provider_lb, provider_lb)
|
134
|
-
payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id,
|
135
|
-
consts.LOAD_BALANCER_UPDATES: lb_dict}
|
136
|
-
mock_cast.assert_called_with({}, 'update_load_balancer', **payload)
|
137
|
-
|
138
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
139
|
-
def test_loadbalancer_update_qos(self, mock_cast):
|
140
|
-
qos_policy_id = uuidutils.generate_uuid()
|
141
|
-
old_provider_lb = driver_dm.LoadBalancer(
|
142
|
-
loadbalancer_id=self.sample_data.lb_id)
|
143
|
-
provider_lb = driver_dm.LoadBalancer(
|
144
|
-
loadbalancer_id=self.sample_data.lb_id,
|
145
|
-
vip_qos_policy_id=qos_policy_id)
|
146
|
-
lb_dict = {'vip': {'qos_policy_id': qos_policy_id}}
|
147
|
-
self.amp_driver.loadbalancer_update(old_provider_lb, provider_lb)
|
148
|
-
payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id,
|
149
|
-
consts.LOAD_BALANCER_UPDATES: lb_dict}
|
150
|
-
mock_cast.assert_called_with({}, 'update_load_balancer', **payload)
|
151
|
-
|
152
|
-
# Listener
|
153
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
154
|
-
def test_listener_create(self, mock_cast):
|
155
|
-
provider_listener = driver_dm.Listener(
|
156
|
-
listener_id=self.sample_data.listener1_id,
|
157
|
-
protocol=consts.PROTOCOL_HTTPS,
|
158
|
-
alpn_protocols=consts.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
159
|
-
self.amp_driver.listener_create(provider_listener)
|
160
|
-
payload = {consts.LISTENER_ID: self.sample_data.listener1_id}
|
161
|
-
mock_cast.assert_called_with({}, 'create_listener', **payload)
|
162
|
-
|
163
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
164
|
-
def test_listener_create_unsupported_alpn(self, mock_cast):
|
165
|
-
provider_listener = driver_dm.Listener(
|
166
|
-
listener_id=self.sample_data.listener1_id,
|
167
|
-
protocol=consts.PROTOCOL_HTTPS)
|
168
|
-
provider_listener.alpn_protocols = ['http/1.1', 'eureka']
|
169
|
-
self.assertRaises(
|
170
|
-
exceptions.UnsupportedOptionError,
|
171
|
-
self.amp_driver.listener_create,
|
172
|
-
provider_listener)
|
173
|
-
mock_cast.assert_not_called()
|
174
|
-
|
175
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
176
|
-
def test_listener_create_unsupported_protocol(self, mock_cast):
|
177
|
-
provider_listener = driver_dm.Listener(
|
178
|
-
listener_id=self.sample_data.listener1_id,
|
179
|
-
protocol='UNSUPPORTED_PROTO')
|
180
|
-
self.assertRaises(
|
181
|
-
exceptions.UnsupportedOptionError,
|
182
|
-
self.amp_driver.listener_create,
|
183
|
-
provider_listener)
|
184
|
-
mock_cast.assert_not_called()
|
185
|
-
|
186
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
187
|
-
def test_listener_delete(self, mock_cast):
|
188
|
-
provider_listener = driver_dm.Listener(
|
189
|
-
listener_id=self.sample_data.listener1_id)
|
190
|
-
self.amp_driver.listener_delete(provider_listener)
|
191
|
-
payload = {consts.LISTENER_ID: self.sample_data.listener1_id}
|
192
|
-
mock_cast.assert_called_with({}, 'delete_listener', **payload)
|
193
|
-
|
194
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
195
|
-
def test_listener_update(self, mock_cast):
|
196
|
-
old_provider_listener = driver_dm.Listener(
|
197
|
-
listener_id=self.sample_data.listener1_id)
|
198
|
-
provider_listener = driver_dm.Listener(
|
199
|
-
listener_id=self.sample_data.listener1_id, admin_state_up=False)
|
200
|
-
listener_dict = {'enabled': False}
|
201
|
-
self.amp_driver.listener_update(old_provider_listener,
|
202
|
-
provider_listener)
|
203
|
-
payload = {consts.LISTENER_ID: self.sample_data.listener1_id,
|
204
|
-
consts.LISTENER_UPDATES: listener_dict}
|
205
|
-
mock_cast.assert_called_with({}, 'update_listener', **payload)
|
206
|
-
|
207
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
208
|
-
def test_listener_update_name(self, mock_cast):
|
209
|
-
old_provider_listener = driver_dm.Listener(
|
210
|
-
listener_id=self.sample_data.listener1_id)
|
211
|
-
provider_listener = driver_dm.Listener(
|
212
|
-
listener_id=self.sample_data.listener1_id, name='Great Listener')
|
213
|
-
listener_dict = {'name': 'Great Listener'}
|
214
|
-
self.amp_driver.listener_update(old_provider_listener,
|
215
|
-
provider_listener)
|
216
|
-
payload = {consts.LISTENER_ID: self.sample_data.listener1_id,
|
217
|
-
consts.LISTENER_UPDATES: listener_dict}
|
218
|
-
mock_cast.assert_called_with({}, 'update_listener', **payload)
|
219
|
-
|
220
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
221
|
-
def test_listener_update_unsupported_alpn(self, mock_cast):
|
222
|
-
old_provider_listener = driver_dm.Listener(
|
223
|
-
listener_id=self.sample_data.listener1_id)
|
224
|
-
provider_listener = driver_dm.Listener(
|
225
|
-
listener_id=self.sample_data.listener1_id,
|
226
|
-
alpn_protocols=['http/1.1', 'eureka'])
|
227
|
-
self.assertRaises(
|
228
|
-
exceptions.UnsupportedOptionError,
|
229
|
-
self.amp_driver.listener_update,
|
230
|
-
old_provider_listener,
|
231
|
-
provider_listener)
|
232
|
-
|
233
|
-
# Pool
|
234
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
235
|
-
def test_pool_create(self, mock_cast):
|
236
|
-
provider_pool = driver_dm.Pool(
|
237
|
-
pool_id=self.sample_data.pool1_id,
|
238
|
-
lb_algorithm=consts.LB_ALGORITHM_ROUND_ROBIN,
|
239
|
-
alpn_protocols=consts.AMPHORA_SUPPORTED_ALPN_PROTOCOLS)
|
240
|
-
self.amp_driver.pool_create(provider_pool)
|
241
|
-
payload = {consts.POOL_ID: self.sample_data.pool1_id}
|
242
|
-
mock_cast.assert_called_with({}, 'create_pool', **payload)
|
243
|
-
|
244
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
245
|
-
def test_pool_create_unsupported_algorithm(self, mock_cast):
|
246
|
-
provider_pool = driver_dm.Pool(
|
247
|
-
pool_id=self.sample_data.pool1_id)
|
248
|
-
provider_pool.lb_algorithm = 'foo'
|
249
|
-
self.assertRaises(
|
250
|
-
exceptions.UnsupportedOptionError,
|
251
|
-
self.amp_driver.pool_create,
|
252
|
-
provider_pool)
|
253
|
-
mock_cast.assert_not_called()
|
254
|
-
|
255
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
256
|
-
def test_pool_create_unsupported_alpn(self, mock_cast):
|
257
|
-
provider_pool = driver_dm.Pool(pool_id=self.sample_data.pool1_id)
|
258
|
-
provider_pool.alpn_protocols = ['http/1.1', 'eureka']
|
259
|
-
self.assertRaises(
|
260
|
-
exceptions.UnsupportedOptionError,
|
261
|
-
self.amp_driver.pool_create,
|
262
|
-
provider_pool)
|
263
|
-
mock_cast.assert_not_called()
|
264
|
-
|
265
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
266
|
-
def test_pool_delete(self, mock_cast):
|
267
|
-
provider_pool = driver_dm.Pool(
|
268
|
-
pool_id=self.sample_data.pool1_id)
|
269
|
-
self.amp_driver.pool_delete(provider_pool)
|
270
|
-
payload = {consts.POOL_ID: self.sample_data.pool1_id}
|
271
|
-
mock_cast.assert_called_with({}, 'delete_pool', **payload)
|
272
|
-
|
273
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
274
|
-
def test_pool_update(self, mock_cast):
|
275
|
-
old_provider_pool = driver_dm.Pool(
|
276
|
-
pool_id=self.sample_data.pool1_id)
|
277
|
-
provider_pool = driver_dm.Pool(
|
278
|
-
pool_id=self.sample_data.pool1_id, admin_state_up=True,
|
279
|
-
ca_tls_container_data='CA DATA', ca_tls_container_ref='CA REF',
|
280
|
-
crl_container_data='CRL DATA', crl_container_ref='CRL REF',
|
281
|
-
description='TEST DESCRIPTION', name='TEST NAME',
|
282
|
-
lb_algorithm=consts.LB_ALGORITHM_SOURCE_IP,
|
283
|
-
session_persistence='FAKE SP', tls_container_data='TLS DATA',
|
284
|
-
tls_container_ref='TLS REF', tls_enabled=False)
|
285
|
-
pool_dict = {'description': 'TEST DESCRIPTION',
|
286
|
-
'lb_algorithm': 'SOURCE_IP', 'name': 'TEST NAME',
|
287
|
-
'session_persistence': 'FAKE SP', 'tls_enabled': False,
|
288
|
-
'enabled': True, 'tls_certificate_id': 'TLS REF',
|
289
|
-
'ca_tls_certificate_id': 'CA REF',
|
290
|
-
'crl_container_id': 'CRL REF'}
|
291
|
-
self.amp_driver.pool_update(old_provider_pool, provider_pool)
|
292
|
-
payload = {consts.POOL_ID: self.sample_data.pool1_id,
|
293
|
-
consts.POOL_UPDATES: pool_dict}
|
294
|
-
mock_cast.assert_called_with({}, 'update_pool', **payload)
|
295
|
-
|
296
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
297
|
-
def test_pool_update_name(self, mock_cast):
|
298
|
-
old_provider_pool = driver_dm.Pool(
|
299
|
-
pool_id=self.sample_data.pool1_id)
|
300
|
-
provider_pool = driver_dm.Pool(
|
301
|
-
pool_id=self.sample_data.pool1_id, name='Great pool',
|
302
|
-
admin_state_up=True, tls_enabled=True)
|
303
|
-
pool_dict = {'name': 'Great pool',
|
304
|
-
'enabled': True,
|
305
|
-
'tls_enabled': True}
|
306
|
-
self.amp_driver.pool_update(old_provider_pool, provider_pool)
|
307
|
-
payload = {consts.POOL_ID: self.sample_data.pool1_id,
|
308
|
-
consts.POOL_UPDATES: pool_dict}
|
309
|
-
mock_cast.assert_called_with({}, 'update_pool', **payload)
|
310
|
-
|
311
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
312
|
-
def test_pool_update_unsupported_algorithm(self, mock_cast):
|
313
|
-
old_provider_pool = driver_dm.Pool(
|
314
|
-
pool_id=self.sample_data.pool1_id)
|
315
|
-
provider_pool = driver_dm.Pool(
|
316
|
-
pool_id=self.sample_data.pool1_id)
|
317
|
-
provider_pool.lb_algorithm = 'foo'
|
318
|
-
self.assertRaises(
|
319
|
-
exceptions.UnsupportedOptionError,
|
320
|
-
self.amp_driver.pool_update,
|
321
|
-
old_provider_pool,
|
322
|
-
provider_pool)
|
323
|
-
mock_cast.assert_not_called()
|
324
|
-
|
325
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
326
|
-
def test_pool_update_unsupported_alpn(self, mock_cast):
|
327
|
-
old_provider_pool = driver_dm.Pool(pool_id=self.sample_data.pool1_id)
|
328
|
-
provider_pool = driver_dm.Pool(
|
329
|
-
listener_id=self.sample_data.pool1_id,
|
330
|
-
alpn_protocols=['http/1.1', 'eureka'])
|
331
|
-
self.assertRaises(
|
332
|
-
exceptions.UnsupportedOptionError,
|
333
|
-
self.amp_driver.pool_update,
|
334
|
-
old_provider_pool,
|
335
|
-
provider_pool)
|
336
|
-
|
337
|
-
# Member
|
338
|
-
@mock.patch('octavia.db.api.get_session')
|
339
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
340
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
341
|
-
def test_member_create(self, mock_cast, mock_pool_get, mock_session):
|
342
|
-
provider_member = driver_dm.Member(
|
343
|
-
member_id=self.sample_data.member1_id)
|
344
|
-
self.amp_driver.member_create(provider_member)
|
345
|
-
payload = {consts.MEMBER_ID: self.sample_data.member1_id}
|
346
|
-
mock_cast.assert_called_with({}, 'create_member', **payload)
|
347
|
-
|
348
|
-
@mock.patch('octavia.db.api.get_session')
|
349
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
350
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
351
|
-
def test_member_create_udp_ipv4(self, mock_cast, mock_pool_get,
|
352
|
-
mock_session):
|
353
|
-
mock_lb = mock.MagicMock()
|
354
|
-
mock_lb.vip = mock.MagicMock()
|
355
|
-
mock_lb.vip.ip_address = "192.0.1.1"
|
356
|
-
mock_listener = mock.MagicMock()
|
357
|
-
mock_listener.load_balancer = mock_lb
|
358
|
-
mock_pool = mock.MagicMock()
|
359
|
-
mock_pool.protocol = consts.PROTOCOL_UDP
|
360
|
-
mock_pool.listeners = [mock_listener]
|
361
|
-
mock_pool_get.return_value = mock_pool
|
362
|
-
|
363
|
-
provider_member = driver_dm.Member(
|
364
|
-
member_id=self.sample_data.member1_id,
|
365
|
-
address="192.0.2.1")
|
366
|
-
self.amp_driver.member_create(provider_member)
|
367
|
-
payload = {consts.MEMBER_ID: self.sample_data.member1_id}
|
368
|
-
mock_cast.assert_called_with({}, 'create_member', **payload)
|
369
|
-
|
370
|
-
@mock.patch('octavia.db.api.get_session')
|
371
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
372
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
373
|
-
def test_member_create_udp_ipv4_ipv6(self, mock_cast, mock_pool_get,
|
374
|
-
mock_session):
|
375
|
-
mock_lb = mock.MagicMock()
|
376
|
-
mock_lb.vip = mock.MagicMock()
|
377
|
-
mock_lb.vip.ip_address = "fe80::1"
|
378
|
-
mock_listener = mock.MagicMock()
|
379
|
-
mock_listener.load_balancer = mock_lb
|
380
|
-
mock_pool = mock.MagicMock()
|
381
|
-
mock_pool.protocol = consts.PROTOCOL_UDP
|
382
|
-
mock_pool.listeners = [mock_listener]
|
383
|
-
mock_pool_get.return_value = mock_pool
|
384
|
-
|
385
|
-
provider_member = driver_dm.Member(
|
386
|
-
member_id=self.sample_data.member1_id,
|
387
|
-
address="192.0.2.1")
|
388
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
389
|
-
self.amp_driver.member_create,
|
390
|
-
provider_member)
|
391
|
-
|
392
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
393
|
-
def test_member_delete(self, mock_cast):
|
394
|
-
provider_member = driver_dm.Member(
|
395
|
-
member_id=self.sample_data.member1_id)
|
396
|
-
self.amp_driver.member_delete(provider_member)
|
397
|
-
payload = {consts.MEMBER_ID: self.sample_data.member1_id}
|
398
|
-
mock_cast.assert_called_with({}, 'delete_member', **payload)
|
399
|
-
|
400
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
401
|
-
def test_member_update(self, mock_cast):
|
402
|
-
old_provider_member = driver_dm.Member(
|
403
|
-
member_id=self.sample_data.member1_id)
|
404
|
-
provider_member = driver_dm.Member(
|
405
|
-
member_id=self.sample_data.member1_id, admin_state_up=True)
|
406
|
-
member_dict = {'enabled': True}
|
407
|
-
self.amp_driver.member_update(old_provider_member, provider_member)
|
408
|
-
payload = {consts.MEMBER_ID: self.sample_data.member1_id,
|
409
|
-
consts.MEMBER_UPDATES: member_dict}
|
410
|
-
mock_cast.assert_called_with({}, 'update_member', **payload)
|
411
|
-
|
412
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
413
|
-
def test_member_update_name(self, mock_cast):
|
414
|
-
old_provider_member = driver_dm.Member(
|
415
|
-
member_id=self.sample_data.member1_id)
|
416
|
-
provider_member = driver_dm.Member(
|
417
|
-
member_id=self.sample_data.member1_id, name='Great member')
|
418
|
-
member_dict = {'name': 'Great member'}
|
419
|
-
self.amp_driver.member_update(old_provider_member, provider_member)
|
420
|
-
payload = {consts.MEMBER_ID: self.sample_data.member1_id,
|
421
|
-
consts.MEMBER_UPDATES: member_dict}
|
422
|
-
mock_cast.assert_called_with({}, 'update_member', **payload)
|
423
|
-
|
424
|
-
@mock.patch('octavia.db.api.get_session')
|
425
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
426
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
427
|
-
def test_member_batch_update(self, mock_cast, mock_pool_get, mock_session):
|
428
|
-
mock_pool = mock.MagicMock()
|
429
|
-
mock_pool.members = self.sample_data.db_pool1_members
|
430
|
-
mock_pool_get.return_value = mock_pool
|
431
|
-
|
432
|
-
prov_mem_update = driver_dm.Member(
|
433
|
-
member_id=self.sample_data.member2_id,
|
434
|
-
pool_id=self.sample_data.pool1_id, admin_state_up=False,
|
435
|
-
address='192.0.2.17', monitor_address='192.0.2.77',
|
436
|
-
protocol_port=80, name='updated-member2')
|
437
|
-
prov_new_member = driver_dm.Member(
|
438
|
-
member_id=self.sample_data.member3_id,
|
439
|
-
pool_id=self.sample_data.pool1_id,
|
440
|
-
address='192.0.2.18', monitor_address='192.0.2.28',
|
441
|
-
protocol_port=80, name='member3')
|
442
|
-
prov_members = [prov_mem_update, prov_new_member]
|
443
|
-
|
444
|
-
update_mem_dict = {'ip_address': '192.0.2.17',
|
445
|
-
'name': 'updated-member2',
|
446
|
-
'monitor_address': '192.0.2.77',
|
447
|
-
'id': self.sample_data.member2_id,
|
448
|
-
'enabled': False,
|
449
|
-
'protocol_port': 80,
|
450
|
-
'pool_id': self.sample_data.pool1_id}
|
451
|
-
|
452
|
-
self.amp_driver.member_batch_update(
|
453
|
-
self.sample_data.pool1_id, prov_members)
|
454
|
-
|
455
|
-
payload = {'old_member_ids': [self.sample_data.member1_id],
|
456
|
-
'new_member_ids': [self.sample_data.member3_id],
|
457
|
-
'updated_members': [update_mem_dict]}
|
458
|
-
mock_cast.assert_called_with({}, 'batch_update_members', **payload)
|
459
|
-
|
460
|
-
@mock.patch('octavia.db.api.get_session')
|
461
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
462
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
463
|
-
def test_member_batch_update_no_admin_addr(self, mock_cast,
|
464
|
-
mock_pool_get, mock_session):
|
465
|
-
mock_pool = mock.MagicMock()
|
466
|
-
mock_pool.members = self.sample_data.db_pool1_members
|
467
|
-
mock_pool_get.return_value = mock_pool
|
468
|
-
|
469
|
-
prov_mem_update = driver_dm.Member(
|
470
|
-
member_id=self.sample_data.member2_id,
|
471
|
-
pool_id=self.sample_data.pool1_id,
|
472
|
-
monitor_address='192.0.2.77',
|
473
|
-
protocol_port=80, name='updated-member2')
|
474
|
-
prov_new_member = driver_dm.Member(
|
475
|
-
member_id=self.sample_data.member3_id,
|
476
|
-
pool_id=self.sample_data.pool1_id,
|
477
|
-
address='192.0.2.18', monitor_address='192.0.2.28',
|
478
|
-
protocol_port=80, name='member3')
|
479
|
-
prov_members = [prov_mem_update, prov_new_member]
|
480
|
-
|
481
|
-
update_mem_dict = {'name': 'updated-member2',
|
482
|
-
'monitor_address': '192.0.2.77',
|
483
|
-
'id': self.sample_data.member2_id,
|
484
|
-
'protocol_port': 80,
|
485
|
-
'pool_id': self.sample_data.pool1_id}
|
486
|
-
|
487
|
-
self.amp_driver.member_batch_update(
|
488
|
-
self.sample_data.pool1_id, prov_members)
|
489
|
-
|
490
|
-
payload = {'old_member_ids': [self.sample_data.member1_id],
|
491
|
-
'new_member_ids': [self.sample_data.member3_id],
|
492
|
-
'updated_members': [update_mem_dict]}
|
493
|
-
mock_cast.assert_called_with({}, 'batch_update_members', **payload)
|
494
|
-
|
495
|
-
@mock.patch('octavia.db.api.get_session')
|
496
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
497
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
498
|
-
def test_member_batch_update_clear_already_empty(
|
499
|
-
self, mock_cast, mock_pool_get, mock_session):
|
500
|
-
"""Expect that we will pass an empty payload if directed.
|
501
|
-
|
502
|
-
Logic for whether or not to attempt this will be done above the driver
|
503
|
-
layer, so our driver is responsible to forward the request even if it
|
504
|
-
is a perceived no-op.
|
505
|
-
"""
|
506
|
-
mock_pool = mock.MagicMock()
|
507
|
-
mock_pool_get.return_value = mock_pool
|
508
|
-
|
509
|
-
self.amp_driver.member_batch_update(
|
510
|
-
self.sample_data.pool1_id, [])
|
511
|
-
|
512
|
-
payload = {'old_member_ids': [],
|
513
|
-
'new_member_ids': [],
|
514
|
-
'updated_members': []}
|
515
|
-
mock_cast.assert_called_with({}, 'batch_update_members', **payload)
|
516
|
-
|
517
|
-
# Health Monitor
|
518
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
519
|
-
def test_health_monitor_create(self, mock_cast):
|
520
|
-
provider_HM = driver_dm.HealthMonitor(
|
521
|
-
healthmonitor_id=self.sample_data.hm1_id)
|
522
|
-
self.amp_driver.health_monitor_create(provider_HM)
|
523
|
-
payload = {consts.HEALTH_MONITOR_ID: self.sample_data.hm1_id}
|
524
|
-
mock_cast.assert_called_with({}, 'create_health_monitor', **payload)
|
525
|
-
|
526
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
527
|
-
def test_health_monitor_delete(self, mock_cast):
|
528
|
-
provider_HM = driver_dm.HealthMonitor(
|
529
|
-
healthmonitor_id=self.sample_data.hm1_id)
|
530
|
-
self.amp_driver.health_monitor_delete(provider_HM)
|
531
|
-
payload = {consts.HEALTH_MONITOR_ID: self.sample_data.hm1_id}
|
532
|
-
mock_cast.assert_called_with({}, 'delete_health_monitor', **payload)
|
533
|
-
|
534
|
-
@mock.patch('octavia.db.api.get_session')
|
535
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
536
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
537
|
-
def test_member_batch_update_udp_ipv4(self, mock_cast, mock_pool_get,
|
538
|
-
mock_session):
|
539
|
-
|
540
|
-
mock_lb = mock.MagicMock()
|
541
|
-
mock_lb.vip = mock.MagicMock()
|
542
|
-
mock_lb.vip.ip_address = "192.0.1.1"
|
543
|
-
mock_listener = mock.MagicMock()
|
544
|
-
mock_listener.load_balancer = mock_lb
|
545
|
-
mock_pool = mock.MagicMock()
|
546
|
-
mock_pool.protocol = consts.PROTOCOL_UDP
|
547
|
-
mock_pool.listeners = [mock_listener]
|
548
|
-
mock_pool.members = self.sample_data.db_pool1_members
|
549
|
-
mock_pool_get.return_value = mock_pool
|
550
|
-
|
551
|
-
prov_mem_update = driver_dm.Member(
|
552
|
-
member_id=self.sample_data.member2_id,
|
553
|
-
pool_id=self.sample_data.pool1_id, admin_state_up=False,
|
554
|
-
address='192.0.2.17', monitor_address='192.0.2.77',
|
555
|
-
protocol_port=80, name='updated-member2')
|
556
|
-
prov_new_member = driver_dm.Member(
|
557
|
-
member_id=self.sample_data.member3_id,
|
558
|
-
pool_id=self.sample_data.pool1_id,
|
559
|
-
address='192.0.2.18', monitor_address='192.0.2.28',
|
560
|
-
protocol_port=80, name='member3')
|
561
|
-
prov_members = [prov_mem_update, prov_new_member]
|
562
|
-
|
563
|
-
update_mem_dict = {'ip_address': '192.0.2.17',
|
564
|
-
'name': 'updated-member2',
|
565
|
-
'monitor_address': '192.0.2.77',
|
566
|
-
'id': self.sample_data.member2_id,
|
567
|
-
'enabled': False,
|
568
|
-
'protocol_port': 80,
|
569
|
-
'pool_id': self.sample_data.pool1_id}
|
570
|
-
|
571
|
-
self.amp_driver.member_batch_update(
|
572
|
-
self.sample_data.pool1_id, prov_members)
|
573
|
-
|
574
|
-
payload = {'old_member_ids': [self.sample_data.member1_id],
|
575
|
-
'new_member_ids': [self.sample_data.member3_id],
|
576
|
-
'updated_members': [update_mem_dict]}
|
577
|
-
mock_cast.assert_called_with({}, 'batch_update_members', **payload)
|
578
|
-
|
579
|
-
@mock.patch('octavia.db.api.get_session')
|
580
|
-
@mock.patch('octavia.db.repositories.PoolRepository.get')
|
581
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
582
|
-
def test_member_batch_update_udp_ipv4_ipv6(self, mock_cast, mock_pool_get,
|
583
|
-
mock_session):
|
584
|
-
|
585
|
-
mock_lb = mock.MagicMock()
|
586
|
-
mock_lb.vip = mock.MagicMock()
|
587
|
-
mock_lb.vip.ip_address = "192.0.1.1"
|
588
|
-
mock_listener = mock.MagicMock()
|
589
|
-
mock_listener.load_balancer = mock_lb
|
590
|
-
mock_pool = mock.MagicMock()
|
591
|
-
mock_pool.protocol = consts.PROTOCOL_UDP
|
592
|
-
mock_pool.listeners = [mock_listener]
|
593
|
-
mock_pool.members = self.sample_data.db_pool1_members
|
594
|
-
mock_pool_get.return_value = mock_pool
|
595
|
-
|
596
|
-
prov_mem_update = driver_dm.Member(
|
597
|
-
member_id=self.sample_data.member2_id,
|
598
|
-
pool_id=self.sample_data.pool1_id, admin_state_up=False,
|
599
|
-
address='fe80::1', monitor_address='fe80::2',
|
600
|
-
protocol_port=80, name='updated-member2')
|
601
|
-
prov_new_member = driver_dm.Member(
|
602
|
-
member_id=self.sample_data.member3_id,
|
603
|
-
pool_id=self.sample_data.pool1_id,
|
604
|
-
address='192.0.2.18', monitor_address='192.0.2.28',
|
605
|
-
protocol_port=80, name='member3')
|
606
|
-
prov_members = [prov_mem_update, prov_new_member]
|
607
|
-
|
608
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
609
|
-
self.amp_driver.member_batch_update,
|
610
|
-
self.sample_data.pool1_id, prov_members)
|
611
|
-
|
612
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
613
|
-
def test_health_monitor_update(self, mock_cast):
|
614
|
-
old_provider_hm = driver_dm.HealthMonitor(
|
615
|
-
healthmonitor_id=self.sample_data.hm1_id)
|
616
|
-
provider_hm = driver_dm.HealthMonitor(
|
617
|
-
healthmonitor_id=self.sample_data.hm1_id, admin_state_up=True,
|
618
|
-
max_retries=1, max_retries_down=2)
|
619
|
-
hm_dict = {'enabled': True, 'rise_threshold': 1, 'fall_threshold': 2}
|
620
|
-
self.amp_driver.health_monitor_update(old_provider_hm, provider_hm)
|
621
|
-
payload = {consts.HEALTH_MONITOR_ID: self.sample_data.hm1_id,
|
622
|
-
consts.HEALTH_MONITOR_UPDATES: hm_dict}
|
623
|
-
mock_cast.assert_called_with({}, 'update_health_monitor', **payload)
|
624
|
-
|
625
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
626
|
-
def test_health_monitor_update_name(self, mock_cast):
|
627
|
-
old_provider_hm = driver_dm.HealthMonitor(
|
628
|
-
healthmonitor_id=self.sample_data.hm1_id)
|
629
|
-
provider_hm = driver_dm.HealthMonitor(
|
630
|
-
healthmonitor_id=self.sample_data.hm1_id, name='Great HM')
|
631
|
-
hm_dict = {'name': 'Great HM'}
|
632
|
-
self.amp_driver.health_monitor_update(old_provider_hm, provider_hm)
|
633
|
-
payload = {consts.HEALTH_MONITOR_ID: self.sample_data.hm1_id,
|
634
|
-
consts.HEALTH_MONITOR_UPDATES: hm_dict}
|
635
|
-
mock_cast.assert_called_with({}, 'update_health_monitor', **payload)
|
636
|
-
|
637
|
-
# L7 Policy
|
638
|
-
@mock.patch('octavia.db.api.get_session')
|
639
|
-
@mock.patch('octavia.db.repositories.ListenerRepository.get')
|
640
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
641
|
-
def test_l7policy_create(self, mock_cast, mock_listener_get, mock_session):
|
642
|
-
mock_listener = mock.MagicMock()
|
643
|
-
mock_listener.protocol = consts.PROTOCOL_HTTP
|
644
|
-
mock_listener_get.return_value = mock_listener
|
645
|
-
provider_l7policy = driver_dm.L7Policy(
|
646
|
-
l7policy_id=self.sample_data.l7policy1_id)
|
647
|
-
self.amp_driver.l7policy_create(provider_l7policy)
|
648
|
-
payload = {consts.L7POLICY_ID: self.sample_data.l7policy1_id}
|
649
|
-
mock_cast.assert_called_with({}, 'create_l7policy', **payload)
|
650
|
-
|
651
|
-
@mock.patch('octavia.db.api.get_session')
|
652
|
-
@mock.patch('octavia.db.repositories.ListenerRepository.get')
|
653
|
-
def test_l7policy_create_invalid_listener_protocol(self, mock_listener_get,
|
654
|
-
mock_session):
|
655
|
-
mock_listener = mock.MagicMock()
|
656
|
-
mock_listener.protocol = consts.PROTOCOL_UDP
|
657
|
-
mock_listener_get.return_value = mock_listener
|
658
|
-
provider_l7policy = driver_dm.L7Policy(
|
659
|
-
l7policy_id=self.sample_data.l7policy1_id)
|
660
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
661
|
-
self.amp_driver.l7policy_create,
|
662
|
-
provider_l7policy)
|
663
|
-
|
664
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
665
|
-
def test_l7policy_delete(self, mock_cast):
|
666
|
-
provider_l7policy = driver_dm.L7Policy(
|
667
|
-
l7policy_id=self.sample_data.l7policy1_id)
|
668
|
-
self.amp_driver.l7policy_delete(provider_l7policy)
|
669
|
-
payload = {consts.L7POLICY_ID: self.sample_data.l7policy1_id}
|
670
|
-
mock_cast.assert_called_with({}, 'delete_l7policy', **payload)
|
671
|
-
|
672
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
673
|
-
def test_l7policy_update(self, mock_cast):
|
674
|
-
old_provider_l7policy = driver_dm.L7Policy(
|
675
|
-
l7policy_id=self.sample_data.l7policy1_id)
|
676
|
-
provider_l7policy = driver_dm.L7Policy(
|
677
|
-
l7policy_id=self.sample_data.l7policy1_id, admin_state_up=True)
|
678
|
-
l7policy_dict = {'enabled': True}
|
679
|
-
self.amp_driver.l7policy_update(old_provider_l7policy,
|
680
|
-
provider_l7policy)
|
681
|
-
payload = {consts.L7POLICY_ID: self.sample_data.l7policy1_id,
|
682
|
-
consts.L7POLICY_UPDATES: l7policy_dict}
|
683
|
-
mock_cast.assert_called_with({}, 'update_l7policy', **payload)
|
684
|
-
|
685
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
686
|
-
def test_l7policy_update_name(self, mock_cast):
|
687
|
-
old_provider_l7policy = driver_dm.L7Policy(
|
688
|
-
l7policy_id=self.sample_data.l7policy1_id)
|
689
|
-
provider_l7policy = driver_dm.L7Policy(
|
690
|
-
l7policy_id=self.sample_data.l7policy1_id, name='Great L7Policy')
|
691
|
-
l7policy_dict = {'name': 'Great L7Policy'}
|
692
|
-
self.amp_driver.l7policy_update(old_provider_l7policy,
|
693
|
-
provider_l7policy)
|
694
|
-
payload = {consts.L7POLICY_ID: self.sample_data.l7policy1_id,
|
695
|
-
consts.L7POLICY_UPDATES: l7policy_dict}
|
696
|
-
mock_cast.assert_called_with({}, 'update_l7policy', **payload)
|
697
|
-
|
698
|
-
# L7 Rules
|
699
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
700
|
-
def test_l7rule_create(self, mock_cast):
|
701
|
-
provider_l7rule = driver_dm.L7Rule(
|
702
|
-
l7rule_id=self.sample_data.l7rule1_id)
|
703
|
-
self.amp_driver.l7rule_create(provider_l7rule)
|
704
|
-
payload = {consts.L7RULE_ID: self.sample_data.l7rule1_id}
|
705
|
-
mock_cast.assert_called_with({}, 'create_l7rule', **payload)
|
706
|
-
|
707
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
708
|
-
def test_l7rule_delete(self, mock_cast):
|
709
|
-
provider_l7rule = driver_dm.L7Rule(
|
710
|
-
l7rule_id=self.sample_data.l7rule1_id)
|
711
|
-
self.amp_driver.l7rule_delete(provider_l7rule)
|
712
|
-
payload = {consts.L7RULE_ID: self.sample_data.l7rule1_id}
|
713
|
-
mock_cast.assert_called_with({}, 'delete_l7rule', **payload)
|
714
|
-
|
715
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
716
|
-
def test_l7rule_update(self, mock_cast):
|
717
|
-
old_provider_l7rule = driver_dm.L7Rule(
|
718
|
-
l7rule_id=self.sample_data.l7rule1_id)
|
719
|
-
provider_l7rule = driver_dm.L7Rule(
|
720
|
-
l7rule_id=self.sample_data.l7rule1_id, admin_state_up=True)
|
721
|
-
l7rule_dict = {'enabled': True}
|
722
|
-
self.amp_driver.l7rule_update(old_provider_l7rule, provider_l7rule)
|
723
|
-
payload = {consts.L7RULE_ID: self.sample_data.l7rule1_id,
|
724
|
-
consts.L7RULE_UPDATES: l7rule_dict}
|
725
|
-
mock_cast.assert_called_with({}, 'update_l7rule', **payload)
|
726
|
-
|
727
|
-
@mock.patch('oslo_messaging.RPCClient.cast')
|
728
|
-
def test_l7rule_update_invert(self, mock_cast):
|
729
|
-
old_provider_l7rule = driver_dm.L7Rule(
|
730
|
-
l7rule_id=self.sample_data.l7rule1_id)
|
731
|
-
provider_l7rule = driver_dm.L7Rule(
|
732
|
-
l7rule_id=self.sample_data.l7rule1_id, invert=True)
|
733
|
-
l7rule_dict = {'invert': True}
|
734
|
-
self.amp_driver.l7rule_update(old_provider_l7rule, provider_l7rule)
|
735
|
-
payload = {consts.L7RULE_ID: self.sample_data.l7rule1_id,
|
736
|
-
consts.L7RULE_UPDATES: l7rule_dict}
|
737
|
-
mock_cast.assert_called_with({}, 'update_l7rule', **payload)
|
738
|
-
|
739
|
-
# Flavor
|
740
|
-
def test_get_supported_flavor_metadata(self):
|
741
|
-
test_schema = {
|
742
|
-
"properties": {
|
743
|
-
"test_name": {"description": "Test description"},
|
744
|
-
"test_name2": {"description": "Another description"}}}
|
745
|
-
ref_dict = {"test_name": "Test description",
|
746
|
-
"test_name2": "Another description"}
|
747
|
-
|
748
|
-
# mock out the supported_flavor_metadata
|
749
|
-
with mock.patch('octavia.api.drivers.amphora_driver.flavor_schema.'
|
750
|
-
'SUPPORTED_FLAVOR_SCHEMA', test_schema):
|
751
|
-
result = self.amp_driver.get_supported_flavor_metadata()
|
752
|
-
self.assertEqual(ref_dict, result)
|
753
|
-
|
754
|
-
# Test for bad schema
|
755
|
-
with mock.patch('octavia.api.drivers.amphora_driver.flavor_schema.'
|
756
|
-
'SUPPORTED_FLAVOR_SCHEMA', 'bogus'):
|
757
|
-
self.assertRaises(exceptions.DriverError,
|
758
|
-
self.amp_driver.get_supported_flavor_metadata)
|
759
|
-
|
760
|
-
def test_validate_flavor(self):
|
761
|
-
ref_dict = {consts.LOADBALANCER_TOPOLOGY: consts.TOPOLOGY_SINGLE}
|
762
|
-
self.amp_driver.validate_flavor(ref_dict)
|
763
|
-
|
764
|
-
# Test bad flavor metadata value is bad
|
765
|
-
ref_dict = {consts.LOADBALANCER_TOPOLOGY: 'bogus'}
|
766
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
767
|
-
self.amp_driver.validate_flavor,
|
768
|
-
ref_dict)
|
769
|
-
|
770
|
-
# Test bad flavor metadata key
|
771
|
-
ref_dict = {'bogus': 'bogus'}
|
772
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
773
|
-
self.amp_driver.validate_flavor,
|
774
|
-
ref_dict)
|
775
|
-
|
776
|
-
# Test for bad schema
|
777
|
-
with mock.patch('octavia.api.drivers.amphora_driver.flavor_schema.'
|
778
|
-
'SUPPORTED_FLAVOR_SCHEMA', 'bogus'):
|
779
|
-
self.assertRaises(exceptions.DriverError,
|
780
|
-
self.amp_driver.validate_flavor, 'bogus')
|
781
|
-
|
782
|
-
# Availability Zone
|
783
|
-
def test_get_supported_availability_zone_metadata(self):
|
784
|
-
test_schema = {
|
785
|
-
"properties": {
|
786
|
-
"test_name": {"description": "Test description"},
|
787
|
-
"test_name2": {"description": "Another description"}}}
|
788
|
-
ref_dict = {"test_name": "Test description",
|
789
|
-
"test_name2": "Another description"}
|
790
|
-
|
791
|
-
# mock out the supported_availability_zone_metadata
|
792
|
-
with mock.patch('octavia.api.drivers.amphora_driver.'
|
793
|
-
'availability_zone_schema.'
|
794
|
-
'SUPPORTED_AVAILABILITY_ZONE_SCHEMA', test_schema):
|
795
|
-
result = self.amp_driver.get_supported_availability_zone_metadata()
|
796
|
-
self.assertEqual(ref_dict, result)
|
797
|
-
|
798
|
-
# Test for bad schema
|
799
|
-
with mock.patch('octavia.api.drivers.amphora_driver.'
|
800
|
-
'availability_zone_schema.'
|
801
|
-
'SUPPORTED_AVAILABILITY_ZONE_SCHEMA', 'bogus'):
|
802
|
-
self.assertRaises(
|
803
|
-
exceptions.DriverError,
|
804
|
-
self.amp_driver.get_supported_availability_zone_metadata)
|
805
|
-
|
806
|
-
def test_validate_availability_zone(self):
|
807
|
-
with mock.patch('stevedore.driver.DriverManager.driver') as m_driver:
|
808
|
-
m_driver.validate_availability_zone.return_value = None
|
809
|
-
ref_dict = {consts.COMPUTE_ZONE: 'my_compute_zone'}
|
810
|
-
self.amp_driver.validate_availability_zone(ref_dict)
|
811
|
-
|
812
|
-
# Test bad availability zone metadata key
|
813
|
-
ref_dict = {'bogus': 'bogus'}
|
814
|
-
self.assertRaises(exceptions.UnsupportedOptionError,
|
815
|
-
self.amp_driver.validate_availability_zone,
|
816
|
-
ref_dict)
|
817
|
-
|
818
|
-
# Test for bad schema
|
819
|
-
with mock.patch('octavia.api.drivers.amphora_driver.'
|
820
|
-
'availability_zone_schema.'
|
821
|
-
'SUPPORTED_AVAILABILITY_ZONE_SCHEMA', 'bogus'):
|
822
|
-
self.assertRaises(exceptions.DriverError,
|
823
|
-
self.amp_driver.validate_availability_zone,
|
824
|
-
'bogus')
|