Update unit tests for mock changes
Change-Id: I22a5c59788add39e25f266d1fd129a806fd0d10e Closes-Bug: 1474481
This commit is contained in:
parent
296a194008
commit
17193a0dde
@ -22,6 +22,7 @@ import subprocess
|
||||
|
||||
import flask
|
||||
import jinja2
|
||||
import six
|
||||
from werkzeug import exceptions
|
||||
|
||||
from octavia.amphorae.backends.agent.api_server import util
|
||||
@ -71,7 +72,7 @@ def get_haproxy_config(listener_id):
|
||||
with open(util.config_path(listener_id), 'r') as file:
|
||||
cfg = file.read()
|
||||
resp = flask.Response(cfg, mimetype='text/plain', )
|
||||
resp.headers['ETag'] = hashlib.md5(cfg).hexdigest()
|
||||
resp.headers['ETag'] = hashlib.md5(six.b(cfg)).hexdigest()
|
||||
return resp
|
||||
|
||||
|
||||
@ -280,15 +281,17 @@ def get_certificate_md5(listener_id, filename):
|
||||
_check_listener_exists(listener_id)
|
||||
_check_ssl_filename_format(filename)
|
||||
|
||||
if not os.path.exists(_cert_file_path(listener_id, filename)):
|
||||
cert_path = _cert_file_path(listener_id, filename)
|
||||
path_exists = os.path.exists(cert_path)
|
||||
if not path_exists:
|
||||
return flask.make_response(flask.jsonify(dict(
|
||||
message='Certificate Not Found',
|
||||
details="No certificate with filename: {f}".format(
|
||||
f=filename))), 404)
|
||||
|
||||
with open(_cert_file_path(listener_id, filename), 'r') as crt_file:
|
||||
with open(cert_path, 'r') as crt_file:
|
||||
cert = crt_file.read()
|
||||
md5 = hashlib.md5(cert).hexdigest()
|
||||
md5 = hashlib.md5(six.b(cert)).hexdigest()
|
||||
resp = flask.jsonify(dict(md5sum=md5))
|
||||
resp.headers['ETag'] = md5
|
||||
return resp
|
||||
|
@ -44,13 +44,13 @@ for code in six.iterkeys(exceptions.default_exceptions):
|
||||
# https://127.0.0.1:8443/0.5/listeners/123/haproxy
|
||||
@app.route('/' + api_server.VERSION + '/listeners/<listener_id>/haproxy',
|
||||
methods=['PUT'])
|
||||
def upload_happroxy_config(listener_id):
|
||||
def upload_haproxy_config(listener_id):
|
||||
return listener.upload_haproxy_config(listener_id)
|
||||
|
||||
|
||||
@app.route('/' + api_server.VERSION + '/listeners/<listener_id>/haproxy',
|
||||
methods=['GET'])
|
||||
def get_happroxy_config(listener_id):
|
||||
def get_haproxy_config(listener_id):
|
||||
return listener.get_haproxy_config(listener_id)
|
||||
|
||||
|
||||
|
@ -35,6 +35,8 @@ if six.PY3:
|
||||
|
||||
|
||||
class ServerTestCase(base.TestCase):
|
||||
app = None
|
||||
|
||||
def setUp(self):
|
||||
self.app = server.app.test_client()
|
||||
super(ServerTestCase, self).setUp()
|
||||
@ -200,7 +202,7 @@ class ServerTestCase(base.TestCase):
|
||||
json.loads(rv.data.decode('utf-8')))
|
||||
mock_rmtree.assert_called_with('/var/lib/octavia/123')
|
||||
mock_exists.assert_called_with('/etc/init/haproxy-123.conf')
|
||||
mock_exists.assert_any_called_with('/var/lib/octavia/123/haproxy.pid')
|
||||
mock_exists.assert_any_call('/var/lib/octavia/123/haproxy.pid')
|
||||
|
||||
# service is stopped + upstart script
|
||||
mock_exists.side_effect = [True, False, True]
|
||||
@ -235,7 +237,7 @@ class ServerTestCase(base.TestCase):
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
def test_get_haproxy(self, mock_exists):
|
||||
CONTENT = six.b("bibble\nbibble")
|
||||
CONTENT = "bibble\nbibble"
|
||||
mock_exists.side_effect = [False]
|
||||
rv = self.app.get('/' + api_server.VERSION + '/listeners/123/haproxy')
|
||||
self.assertEqual(404, rv.status_code)
|
||||
@ -247,7 +249,7 @@ class ServerTestCase(base.TestCase):
|
||||
rv = self.app.get('/' + api_server.VERSION +
|
||||
'/listeners/123/haproxy')
|
||||
self.assertEqual(200, rv.status_code)
|
||||
self.assertEqual(CONTENT, rv.data)
|
||||
self.assertEqual(six.b(CONTENT), rv.data)
|
||||
self.assertEqual('text/plain; charset=utf-8',
|
||||
rv.headers['Content-Type'])
|
||||
|
||||
@ -374,7 +376,7 @@ class ServerTestCase(base.TestCase):
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
def test_get_certificate_md5(self, mock_exists):
|
||||
CONTENT = six.b("TestTest")
|
||||
CONTENT = "TestTest"
|
||||
mock_exists.side_effect = [False]
|
||||
rv = self.app.get('/' + api_server.VERSION +
|
||||
'/listeners/123/certificates/test.pem')
|
||||
@ -397,14 +399,14 @@ class ServerTestCase(base.TestCase):
|
||||
data='TestTest')
|
||||
self.assertEqual(400, rv.status_code)
|
||||
|
||||
mock_exists.side_effect = [True, True]
|
||||
m = mock.mock_open(read_data=CONTENT)
|
||||
|
||||
mock_exists.return_value = True
|
||||
mock_exists.side_effect = None
|
||||
with mock.patch('%s.open' % BUILTINS, m, create=True):
|
||||
rv = self.app.get('/' + api_server.VERSION +
|
||||
'/listeners/123/certificates/test.pem')
|
||||
self.assertEqual(200, rv.status_code)
|
||||
self.assertEqual(dict(md5sum=hashlib.md5(CONTENT).hexdigest()),
|
||||
self.assertEqual(dict(md5sum=hashlib.md5(six.b(CONTENT)).hexdigest()),
|
||||
json.loads(rv.data.decode('utf-8')))
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
|
@ -75,11 +75,21 @@ class TestSshDriver(base.TestCase):
|
||||
build_conf.assert_called_once_with(
|
||||
listener, listener.default_tls_container,
|
||||
listener.sni_containers)
|
||||
self.driver.client.connect.assert_called_once()
|
||||
self.driver.client.open_sftp().assert_called_once()
|
||||
self.driver.client.open_sftp().put().assert_called_once()
|
||||
self.driver.client.exec_command.assert_called_once()
|
||||
self.driver.client.close.assert_called_once()
|
||||
self.driver.client.connect.assert_called_once_with(
|
||||
hostname=listener.load_balancer.amphorae[0].lb_network_ip,
|
||||
key_filename=self.driver.amp_config.key_path,
|
||||
username=self.driver.amp_config.username)
|
||||
self.driver.client.open_sftp.assert_called_once_with()
|
||||
self.driver.client.open_sftp().put.assert_called_once_with(
|
||||
mock.ANY, mock.ANY
|
||||
)
|
||||
self.driver.client.exec_command.assert_has_calls([
|
||||
mock.call(mock.ANY),
|
||||
mock.call(mock.ANY),
|
||||
mock.call(mock.ANY),
|
||||
mock.call(mock.ANY)
|
||||
])
|
||||
self.driver.client.close.assert_called_once_with()
|
||||
|
||||
def test_stop(self):
|
||||
# Build sample Listener and VIP configs
|
||||
@ -89,9 +99,14 @@ class TestSshDriver(base.TestCase):
|
||||
|
||||
# Execute driver method
|
||||
self.driver.start(listener, vip)
|
||||
self.driver.client.connect.assert_called_once()
|
||||
self.driver.client.exec_command.assert_called_once()
|
||||
self.driver.client.close.assert_called_once()
|
||||
self.driver.client.connect.assert_called_once_with(
|
||||
hostname=listener.load_balancer.amphorae[0].lb_network_ip,
|
||||
key_filename=self.driver.amp_config.key_path,
|
||||
username=self.driver.amp_config.username)
|
||||
self.driver.client.exec_command.assert_called_once_with(
|
||||
'sudo haproxy -f {0}/{1}/haproxy.cfg -p {0}/{1}/{1}.pid'.format(
|
||||
self.driver.amp_config.base_path, listener.id))
|
||||
self.driver.client.close.assert_called_once_with()
|
||||
|
||||
def test_start(self):
|
||||
# Build sample Listener and VIP configs
|
||||
@ -101,11 +116,17 @@ class TestSshDriver(base.TestCase):
|
||||
|
||||
# Execute driver method
|
||||
self.driver.start(listener, vip)
|
||||
self.driver.client.connect.assert_called_once()
|
||||
self.driver.client.exec_command.assert_called_once()
|
||||
self.driver.client.close.assert_called_once()
|
||||
self.driver.client.connect.assert_called_once_with(
|
||||
hostname=listener.load_balancer.amphorae[0].lb_network_ip,
|
||||
key_filename=self.driver.amp_config.key_path,
|
||||
username=self.driver.amp_config.username)
|
||||
self.driver.client.exec_command.assert_called_once_with(
|
||||
'sudo haproxy -f {0}/{1}/haproxy.cfg -p {0}/{1}/{1}.pid'.format(
|
||||
self.driver.amp_config.base_path, listener.id))
|
||||
self.driver.client.close.assert_called_once_with()
|
||||
|
||||
def test_delete(self):
|
||||
|
||||
# Build sample Listener and VIP configs
|
||||
listener = sample_configs.sample_listener_tuple(
|
||||
tls=True, sni=True)
|
||||
@ -115,9 +136,18 @@ class TestSshDriver(base.TestCase):
|
||||
self.driver.delete(listener, vip)
|
||||
|
||||
# Verify call
|
||||
self.driver.client.connect.assert_called_once()
|
||||
self.driver.client.exec_command.assert_called_once()
|
||||
self.driver.client.close.assert_called_once()
|
||||
self.driver.client.connect.assert_called_once_with(
|
||||
hostname=listener.load_balancer.amphorae[0].lb_network_ip,
|
||||
key_filename=self.driver.amp_config.key_path,
|
||||
username=self.driver.amp_config.username)
|
||||
exec_command_calls = [
|
||||
mock.call('sudo kill -9 $(cat {0}/sample_listener_id_1'
|
||||
'/sample_listener_id_1.pid)'
|
||||
.format(self.driver.amp_config.base_path)),
|
||||
mock.call('sudo rm -rf {0}/sample_listener_id_1'.format(
|
||||
self.driver.amp_config.base_path))]
|
||||
self.driver.client.exec_command.assert_has_calls(exec_command_calls)
|
||||
self.driver.client.close.assert_called_once_with()
|
||||
|
||||
def test_get_info(self):
|
||||
pass
|
||||
@ -157,10 +187,11 @@ class TestSshDriver(base.TestCase):
|
||||
mock.call().get_intermediates()]
|
||||
bbq.assert_has_calls(calls_bbq)
|
||||
|
||||
self.driver.client.open_sftp().put(
|
||||
mock.ANY, '{0}/{1}/certificates/{2}'.format(
|
||||
self.driver.amp_config.base_path, listener.id,
|
||||
pem)).assert_called_once()
|
||||
self.driver.client.open_sftp().put.assert_has_calls([
|
||||
mock.call(mock.ANY, mock.ANY),
|
||||
mock.call(mock.ANY, mock.ANY),
|
||||
mock.call(mock.ANY, mock.ANY),
|
||||
])
|
||||
|
||||
def test_get_primary_cn(self):
|
||||
cert = mock.MagicMock()
|
||||
@ -200,4 +231,4 @@ class TestSshDriver(base.TestCase):
|
||||
tls_tupe = sample_configs.sample_tls_container_tuple(
|
||||
certificate='imacert', private_key='imakey',
|
||||
intermediates=['imainter', 'imainter2'])
|
||||
self.assertEqual(expected, self.driver._build_pem(tls_tupe))
|
||||
self.assertEqual(expected, self.driver._build_pem(tls_tupe))
|
||||
|
@ -65,5 +65,5 @@ class TestBaseTaskFlowEngine(base.TestCase):
|
||||
engine_conf='TESTENGINE',
|
||||
executor='TESTEXECUTOR')
|
||||
|
||||
_engine_mock.compile.assert_called_once()
|
||||
_engine_mock.prepare.assert_called_once()
|
||||
_engine_mock.compile.assert_called_once_with()
|
||||
_engine_mock.prepare.assert_called_once_with()
|
||||
|
@ -38,7 +38,7 @@ class TestObjectUpdateTasks(base.TestCase):
|
||||
delete_object = model_tasks.DeleteModelObject()
|
||||
delete_object.execute(self.listener_mock)
|
||||
|
||||
self.listener_mock.delete.assert_called_once()
|
||||
self.listener_mock.delete.assert_called_once_with()
|
||||
|
||||
def test_update_listener(self):
|
||||
|
||||
|
@ -102,15 +102,17 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
amp = cw.create_amphora()
|
||||
|
||||
(base_taskflow.BaseTaskFlowEngine._taskflow_load.
|
||||
assert_called_once_with('TEST'))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
_flow_mock.storage.fetch.assert_called_once()
|
||||
_flow_mock.storage.fetch.assert_called_once_with('amphora')
|
||||
|
||||
assert (amp == AMP_ID)
|
||||
|
||||
@ -129,6 +131,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.delete_amphora(AMP_ID)
|
||||
|
||||
@ -140,7 +144,7 @@ class TestControllerWorker(base.TestCase):
|
||||
assert_called_once_with('TEST',
|
||||
store={'amphora': _amphora_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'health_monitor_flows.HealthMonitorFlows.'
|
||||
@ -158,6 +162,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.create_health_monitor(_health_mon_mock)
|
||||
|
||||
@ -168,7 +174,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer': _load_balancer_mock,
|
||||
'vip': _vip_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'health_monitor_flows.HealthMonitorFlows.'
|
||||
@ -186,6 +192,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.delete_health_monitor(HM_ID)
|
||||
|
||||
@ -197,7 +205,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer': _load_balancer_mock,
|
||||
'vip': _vip_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'health_monitor_flows.HealthMonitorFlows.'
|
||||
@ -215,6 +223,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.update_health_monitor(_health_mon_mock.id,
|
||||
HEALTH_UPDATE_DICT)
|
||||
@ -227,7 +237,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'vip': _vip_mock,
|
||||
'update_dict': HEALTH_UPDATE_DICT}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'listener_flows.ListenerFlows.get_create_listener_flow',
|
||||
@ -244,6 +254,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.create_listener(LB_ID)
|
||||
|
||||
@ -253,7 +265,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer': _load_balancer_mock,
|
||||
'vip': _vip_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'listener_flows.ListenerFlows.get_delete_listener_flow',
|
||||
@ -270,6 +282,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.delete_listener(LB_ID)
|
||||
|
||||
@ -279,7 +293,7 @@ class TestControllerWorker(base.TestCase):
|
||||
constants.VIP: _vip_mock,
|
||||
constants.LOADBALANCER: _load_balancer_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'listener_flows.ListenerFlows.get_update_listener_flow',
|
||||
@ -296,6 +310,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.update_listener(LB_ID, LISTENER_UPDATE_DICT)
|
||||
|
||||
@ -307,7 +323,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'update_dict':
|
||||
LISTENER_UPDATE_DICT}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.load_balancer_flows.'
|
||||
'LoadBalancerFlows.get_create_load_balancer_flow',
|
||||
@ -333,6 +349,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_amp_repo_get):
|
||||
|
||||
# Test code path with an existing READY amphora
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
store = {constants.LOADBALANCER_ID: LB_ID}
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.create_load_balancer(LB_ID)
|
||||
@ -340,7 +358,7 @@ class TestControllerWorker(base.TestCase):
|
||||
(base_taskflow.BaseTaskFlowEngine._taskflow_load.
|
||||
assert_called_once_with(_flow_mock, store=store))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
self.assertFalse(mock_get_create_amp_for_lb_flow.called)
|
||||
|
||||
@ -390,6 +408,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.delete_load_balancer(LB_ID)
|
||||
|
||||
@ -402,7 +422,7 @@ class TestControllerWorker(base.TestCase):
|
||||
store={'loadbalancer':
|
||||
_load_balancer_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.load_balancer_flows.'
|
||||
'LoadBalancerFlows.get_update_load_balancer_flow',
|
||||
@ -419,6 +439,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
change = 'TEST2'
|
||||
cw.update_load_balancer(LB_ID, change)
|
||||
@ -433,7 +455,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer':
|
||||
_load_balancer_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'member_flows.MemberFlows.get_create_member_flow',
|
||||
@ -450,6 +472,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.create_member(MEMBER_ID)
|
||||
|
||||
@ -460,7 +484,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer': _load_balancer_mock,
|
||||
'vip': _vip_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'member_flows.MemberFlows.get_delete_member_flow',
|
||||
@ -477,6 +501,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.delete_member(MEMBER_ID)
|
||||
|
||||
@ -488,7 +514,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'vip': _vip_mock,
|
||||
'loadbalancer': _load_balancer_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'member_flows.MemberFlows.get_update_member_flow',
|
||||
@ -505,6 +531,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.update_member(MEMBER_ID, MEMBER_UPDATE_DICT)
|
||||
|
||||
@ -516,7 +544,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'vip': _vip_mock,
|
||||
'update_dict': MEMBER_UPDATE_DICT}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'pool_flows.PoolFlows.get_create_pool_flow',
|
||||
@ -533,6 +561,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.create_pool(POOL_ID)
|
||||
|
||||
@ -543,7 +573,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer': _load_balancer_mock,
|
||||
'vip': _vip_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'pool_flows.PoolFlows.get_delete_pool_flow',
|
||||
@ -560,6 +590,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.delete_pool(POOL_ID)
|
||||
|
||||
@ -570,7 +602,7 @@ class TestControllerWorker(base.TestCase):
|
||||
'loadbalancer': _load_balancer_mock,
|
||||
'vip': _vip_mock}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
||||
@mock.patch('octavia.controller.worker.flows.'
|
||||
'pool_flows.PoolFlows.get_update_pool_flow',
|
||||
@ -587,6 +619,8 @@ class TestControllerWorker(base.TestCase):
|
||||
mock_health_mon_repo_get,
|
||||
mock_amp_repo_get):
|
||||
|
||||
_flow_mock.reset_mock()
|
||||
|
||||
cw = controller_worker.ControllerWorker()
|
||||
cw.update_pool(POOL_ID, POOL_UPDATE_DICT)
|
||||
|
||||
@ -598,4 +632,4 @@ class TestControllerWorker(base.TestCase):
|
||||
'vip': _vip_mock,
|
||||
'update_dict': POOL_UPDATE_DICT}))
|
||||
|
||||
_flow_mock.run.assert_called_once()
|
||||
_flow_mock.run.assert_called_once_with()
|
||||
|
@ -43,20 +43,24 @@ MOCK_NEUTRON_PORT = {'port': {'network_id': '1',
|
||||
|
||||
|
||||
class TestAllowedAddressPairsDriver(base.TestCase):
|
||||
k_session = None
|
||||
driver = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestAllowedAddressPairsDriver, self).setUp()
|
||||
neutron_patcher = mock.patch('neutronclient.neutron.client.Client',
|
||||
autospec=True)
|
||||
mock.patch('novaclient.client.Client', autospec=True).start()
|
||||
neutron_client = neutron_patcher.start()
|
||||
client = neutron_client(allowed_address_pairs.NEUTRON_VERSION)
|
||||
client.list_extensions.return_value = {
|
||||
'extensions': [{'alias': allowed_address_pairs.AAP_EXT_ALIAS},
|
||||
{'alias': allowed_address_pairs.SEC_GRP_EXT_ALIAS}]}
|
||||
self.k_session = mock.patch(
|
||||
'octavia.common.keystone.get_session').start()
|
||||
self.driver = allowed_address_pairs.AllowedAddressPairsDriver()
|
||||
with mock.patch('neutronclient.neutron.client.Client',
|
||||
autospec=True) as neutron_client:
|
||||
with mock.patch('novaclient.client.Client', autospec=True):
|
||||
client = neutron_client(allowed_address_pairs.NEUTRON_VERSION)
|
||||
client.list_extensions.return_value = {
|
||||
'extensions': [
|
||||
{'alias': allowed_address_pairs.AAP_EXT_ALIAS},
|
||||
{'alias': allowed_address_pairs.SEC_GRP_EXT_ALIAS}
|
||||
]
|
||||
}
|
||||
self.k_session = mock.patch(
|
||||
'octavia.common.keystone.get_session').start()
|
||||
self.driver = allowed_address_pairs.AllowedAddressPairsDriver()
|
||||
|
||||
def test_check_extensions_loaded(self):
|
||||
list_extensions = self.driver.neutron_client.list_extensions
|
||||
|
Loading…
Reference in New Issue
Block a user