/usr/lib/python2.7/dist-packages/neutron_lbaas/tests/unit/services/loadbalancer/drivers/a10networks/test_driver_v1.py is in python-neutron-lbaas 2:8.0.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | # Copyright 2014, Doug Wiegley (dougwig), A10 Networks
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
import mock
from neutron import context
from neutron_lbaas.db.loadbalancer import loadbalancer_db as lb_db
from neutron_lbaas.tests.unit.db.loadbalancer import test_db_loadbalancer
with mock.patch.dict(sys.modules, {'a10_neutron_lbaas': mock.Mock()}):
from neutron_lbaas.services.loadbalancer.drivers.a10networks \
import driver_v1
def fake_model(id):
return {
'id': id,
'tenant_id': "tennant-was-a-great-doctor"
}
def fake_member(id):
return {
'id': id,
'tenant_id': "vippyvip",
'address': '1.1.1.1'
}
class TestA10ThunderDriver(test_db_loadbalancer.LoadBalancerPluginDbTestCase):
def setUp(self):
super(TestA10ThunderDriver, self).setUp()
self.context = context.get_admin_context()
self.plugin = mock.Mock()
self.driver = driver_v1.ThunderDriver(self.plugin)
self.driver.a10 = mock.Mock()
self.m = fake_model('p1')
def test__hm_binding_count(self):
n = self.driver._hm_binding_count(self.context, 'hm01')
self.assertEqual(0, n)
def test__member_count(self):
self.m = fake_member('mem1')
n = self.driver._member_count(self.context, self.m)
self.assertEqual(0, n)
def test__member_get_ip(self):
self.m = fake_member('mem1')
z = self.driver._member_get_ip(self.context, self.m, False)
self.assertEqual('1.1.1.1', z)
z = self.driver._member_get_ip(self.context, self.m, True)
self.assertEqual('1.1.1.1', z)
def test__pool_get_hm(self):
self.driver._pool_get_hm(self.context, 'hm01')
self.plugin.get_health_monitor.assert_called_once_with(
self.context, 'hm01')
def test__pool_get_tenant_id(self):
z = self.driver._pool_get_tenant_id(self.context, 'pool1')
self.assertEqual('', z)
def test__pool_get_vip_id(self):
z = self.driver._pool_get_vip_id(self.context, 'pool1')
self.assertEqual('', z)
def test__pool_total(self):
n = self.driver._pool_total(self.context,
tenant_id='whatareyoudoingdave')
self.assertEqual(0, n)
def test__active(self):
self.driver._active(self.context, 'vip', 'vip1')
self.plugin.update_status.assert_called_once_with(
self.context, lb_db.Vip, 'vip1', 'ACTIVE')
def test__failed(self):
self.driver._failed(self.context, 'vip', 'vip2-1-2')
self.plugin.update_status.assert_called_once_with(
self.context, lb_db.Vip, 'vip2-1-2', 'ERROR')
def test__db_delete(self):
self.driver._db_delete(self.context, 'pool', 'myid0101')
self.plugin._delete_db_pool.assert_called_once_with(
self.context, 'myid0101')
def test__hm_active(self):
self.driver._hm_active(self.context, 'hm01', 'pool1')
self.plugin.update_pool_health_monitor.assert_called_once_with(
self.context, 'hm01', 'pool1', 'ACTIVE')
def test__hm_failed(self):
self.driver._hm_failed(self.context, 'hm01', 'pool1')
self.plugin.update_pool_health_monitor.assert_called_once_with(
self.context, 'hm01', 'pool1', 'ERROR')
def test__hm_db_delete(self):
self.driver._hm_db_delete(self.context, 'hm01', 'pool2')
self.plugin._delete_db_pool_health_monitor.assert_called_once_with(
self.context, 'hm01', 'pool2')
def test_create_vip(self):
self.driver.create_vip(self.context, self.m)
self.driver.a10.vip.create.assert_called_once_with(
self.context, self.m)
def test_update_vip(self):
self.driver.update_vip(self.context, self.m, self.m)
self.driver.a10.vip.update.assert_called_once_with(
self.context, self.m, self.m)
def test_delete_vip(self):
self.driver.delete_vip(self.context, self.m)
self.driver.a10.vip.delete.assert_called_once_with(
self.context, self.m)
def test_create_pool(self):
self.driver.create_pool(self.context, self.m)
self.driver.a10.pool.create.assert_called_once_with(
self.context, self.m)
def test_update_pool(self):
self.driver.update_pool(self.context, self.m, self.m)
self.driver.a10.pool.update.assert_called_once_with(
self.context, self.m, self.m)
def test_delete_pool(self):
self.driver.delete_pool(self.context, self.m)
self.driver.a10.pool.delete.assert_called_once_with(
self.context, self.m)
def test_stats(self):
self.driver.stats(self.context, self.m['id'])
self.driver.a10.pool.stats.assert_called_once_with(
self.context, self.m['id'])
def test_create_member(self):
self.driver.create_member(self.context, self.m)
self.driver.a10.member.create.assert_called_once_with(
self.context, self.m)
def test_update_member(self):
self.driver.update_member(self.context, self.m, self.m)
self.driver.a10.member.update.assert_called_once_with(
self.context, self.m, self.m)
def test_delete_member(self):
self.driver.delete_member(self.context, self.m)
self.driver.a10.member.delete.assert_called_once_with(
self.context, self.m)
def test_update_pool_health_monitor(self):
self.driver.update_pool_health_monitor(self.context, self.m, self.m,
'pool1')
self.driver.a10.hm.update.assert_called_once_with(
self.context, self.m, self.m, 'pool1')
def test_create_pool_health_monitor(self):
self.driver.create_pool_health_monitor(self.context, self.m, 'pool1')
self.driver.a10.hm.create.assert_called_once_with(
self.context, self.m, 'pool1')
def test_delete_pool_health_monitor(self):
self.driver.delete_pool_health_monitor(self.context, self.m, 'pool1')
self.driver.a10.hm.delete.assert_called_once_with(
self.context, self.m, 'pool1')
|