Merge "Define routers_client as library interface"
This commit is contained in:
commit
efbe00da61
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- Define routers_client as stable library interface.
|
||||
The routers_client module is defined as library interface,
|
||||
so the other projects can use the module as stable library
|
||||
without any maintenance changes.
|
@ -88,6 +88,7 @@ from tempest.lib.services.network.networks_client import NetworksClient
|
||||
from tempest.lib.services.network.ports_client import PortsClient
|
||||
from tempest.lib.services.network.quotas_client import QuotasClient \
|
||||
as NetworkQuotasClient
|
||||
from tempest.lib.services.network.routers_client import RoutersClient
|
||||
from tempest.lib.services.network.security_group_rules_client import \
|
||||
SecurityGroupRulesClient
|
||||
from tempest.lib.services.network.security_groups_client import \
|
||||
@ -133,7 +134,6 @@ from tempest.services.identity.v3.json.users_clients import \
|
||||
from tempest.services.image.v1.json.images_client import ImagesClient
|
||||
from tempest.services.image.v2.json.images_client import \
|
||||
ImagesClient as ImagesV2Client
|
||||
from tempest.services.network.json.routers_client import RoutersClient
|
||||
from tempest.services.object_storage.account_client import AccountClient
|
||||
from tempest.services.object_storage.container_client import ContainerClient
|
||||
from tempest.services.object_storage.object_client import ObjectClient
|
||||
|
@ -98,12 +98,12 @@ import tempest.lib.auth
|
||||
from tempest.lib.common.utils import data_utils
|
||||
import tempest.lib.exceptions
|
||||
from tempest.lib.services.network import networks_client
|
||||
from tempest.lib.services.network import routers_client
|
||||
from tempest.lib.services.network import subnets_client
|
||||
from tempest.services.identity.v2.json import identity_client
|
||||
from tempest.services.identity.v2.json import roles_client
|
||||
from tempest.services.identity.v2.json import tenants_client
|
||||
from tempest.services.identity.v2.json import users_client
|
||||
from tempest.services.network.json import routers_client
|
||||
|
||||
LOG = None
|
||||
CONF = config.CONF
|
||||
|
@ -128,13 +128,13 @@ from tempest.lib.services.compute import security_groups_client
|
||||
from tempest.lib.services.compute import servers_client
|
||||
from tempest.lib.services.network import networks_client
|
||||
from tempest.lib.services.network import ports_client
|
||||
from tempest.lib.services.network import routers_client
|
||||
from tempest.lib.services.network import subnets_client
|
||||
from tempest.services.identity.v2.json import identity_client
|
||||
from tempest.services.identity.v2.json import roles_client
|
||||
from tempest.services.identity.v2.json import tenants_client
|
||||
from tempest.services.identity.v2.json import users_client
|
||||
from tempest.services.image.v2.json import images_client
|
||||
from tempest.services.network.json import routers_client
|
||||
from tempest.services.object_storage import container_client
|
||||
from tempest.services.object_storage import object_client
|
||||
from tempest.services.volume.v1.json import volumes_client
|
||||
|
@ -2,4 +2,3 @@
|
||||
./tempest/services/volume/base/base_qos_client.py
|
||||
./tempest/services/volume/base/base_backups_client.py
|
||||
./tempest/services/baremetal/base.py
|
||||
./tempest/services/network/json/routers_client.py
|
||||
|
@ -23,6 +23,7 @@ from tempest import exceptions
|
||||
from tempest.lib.common import rest_client
|
||||
from tempest.lib.services.identity.v2 import token_client as v2_token_client
|
||||
from tempest.lib.services.identity.v3 import token_client as v3_token_client
|
||||
from tempest.lib.services.network import routers_client
|
||||
from tempest.services.identity.v2.json import identity_client as v2_iden_client
|
||||
from tempest.services.identity.v2.json import roles_client as v2_roles_client
|
||||
from tempest.services.identity.v2.json import tenants_client as \
|
||||
@ -34,7 +35,6 @@ from tempest.services.identity.v3.json import projects_client as \
|
||||
v3_projects_client
|
||||
from tempest.services.identity.v3.json import roles_client as v3_roles_client
|
||||
from tempest.services.identity.v3.json import users_clients as v3_users_client
|
||||
from tempest.services.network.json import routers_client
|
||||
from tempest.tests import base
|
||||
from tempest.tests import fake_config
|
||||
from tempest.tests.lib import fake_http
|
||||
@ -333,7 +333,7 @@ class TestDynamicCredentialProvider(base.TestCase):
|
||||
self._mock_subnet_create(creds, '1234', 'fake_subnet')
|
||||
self._mock_router_create('1234', 'fake_router')
|
||||
router_interface_mock = self.patch(
|
||||
'tempest.services.network.json.routers_client.RoutersClient.'
|
||||
'tempest.lib.services.network.routers_client.RoutersClient.'
|
||||
'add_router_interface')
|
||||
primary_creds = creds.get_primary_creds()
|
||||
router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
|
||||
@ -365,7 +365,7 @@ class TestDynamicCredentialProvider(base.TestCase):
|
||||
self._mock_subnet_create(creds, '1234', 'fake_subnet')
|
||||
self._mock_router_create('1234', 'fake_router')
|
||||
router_interface_mock = self.patch(
|
||||
'tempest.services.network.json.routers_client.RoutersClient.'
|
||||
'tempest.lib.services.network.routers_client.RoutersClient.'
|
||||
'add_router_interface')
|
||||
creds.get_primary_creds()
|
||||
router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
|
||||
@ -397,7 +397,7 @@ class TestDynamicCredentialProvider(base.TestCase):
|
||||
router = mock.patch.object(creds.routers_admin_client, 'delete_router')
|
||||
router_mock = router.start()
|
||||
remove_router_interface_mock = self.patch(
|
||||
'tempest.services.network.json.routers_client.RoutersClient.'
|
||||
'tempest.lib.services.network.routers_client.RoutersClient.'
|
||||
'remove_router_interface')
|
||||
return_values = ({'status': 200}, {'ports': []})
|
||||
port_list_mock = mock.patch.object(creds.ports_admin_client,
|
||||
@ -468,7 +468,7 @@ class TestDynamicCredentialProvider(base.TestCase):
|
||||
self._mock_subnet_create(creds, '1234', 'fake_alt_subnet')
|
||||
self._mock_router_create('1234', 'fake_alt_router')
|
||||
router_interface_mock = self.patch(
|
||||
'tempest.services.network.json.routers_client.RoutersClient.'
|
||||
'tempest.lib.services.network.routers_client.RoutersClient.'
|
||||
'add_router_interface')
|
||||
alt_creds = creds.get_alt_creds()
|
||||
router_interface_mock.assert_called_once_with('1234', subnet_id='1234')
|
||||
@ -492,7 +492,7 @@ class TestDynamicCredentialProvider(base.TestCase):
|
||||
self._mock_subnet_create(creds, '1234', 'fake_admin_subnet')
|
||||
self._mock_router_create('1234', 'fake_admin_router')
|
||||
router_interface_mock = self.patch(
|
||||
'tempest.services.network.json.routers_client.RoutersClient.'
|
||||
'tempest.lib.services.network.routers_client.RoutersClient.'
|
||||
'add_router_interface')
|
||||
self._mock_list_roles('123456', 'admin')
|
||||
admin_creds = creds.get_admin_creds()
|
||||
|
109
tempest/tests/lib/services/network/test_routers_client.py
Normal file
109
tempest/tests/lib/services/network/test_routers_client.py
Normal file
@ -0,0 +1,109 @@
|
||||
# Copyright 2016 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from tempest.lib.services.network import routers_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
|
||||
class TestRoutersClient(base.BaseServiceTest):
|
||||
FAKE_CREATE_ROUTER = {
|
||||
"router": {
|
||||
"name": u'\u2740(*\xb4\u25e1`*)\u2740',
|
||||
"external_gateway_info": {
|
||||
"network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b",
|
||||
"enable_snat": True,
|
||||
"external_fixed_ips": [
|
||||
{
|
||||
"subnet_id": "255.255.255.0",
|
||||
"ip": "192.168.10.1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"admin_state_up": True,
|
||||
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
|
||||
}
|
||||
}
|
||||
|
||||
FAKE_UPDATE_ROUTER = {
|
||||
"router": {
|
||||
"name": u'\u2740(*\xb4\u25e1`*)\u2740',
|
||||
"external_gateway_info": {
|
||||
"network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b",
|
||||
"enable_snat": True,
|
||||
"external_fixed_ips": [
|
||||
{
|
||||
"subnet_id": "255.255.255.0",
|
||||
"ip": "192.168.10.1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"admin_state_up": False,
|
||||
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
|
||||
}
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestRoutersClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = routers_client.RoutersClient(fake_auth,
|
||||
'network', 'regionOne')
|
||||
|
||||
def _test_list_routers(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_routers,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
{"routers": []},
|
||||
bytes_body)
|
||||
|
||||
def _test_create_router(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.create_router,
|
||||
'tempest.lib.common.rest_client.RestClient.post',
|
||||
self.FAKE_CREATE_ROUTER,
|
||||
bytes_body,
|
||||
name="another_router", admin_state_up="true", status=201)
|
||||
|
||||
def _test_update_router(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_router,
|
||||
'tempest.lib.common.rest_client.RestClient.put',
|
||||
self.FAKE_UPDATE_ROUTER,
|
||||
bytes_body,
|
||||
router_id="8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
|
||||
admin_state_up=False)
|
||||
|
||||
def test_list_routers_with_str_body(self):
|
||||
self._test_list_routers()
|
||||
|
||||
def test_list_routers_with_bytes_body(self):
|
||||
self._test_list_routers(bytes_body=True)
|
||||
|
||||
def test_create_router_with_str_body(self):
|
||||
self._test_create_router()
|
||||
|
||||
def test_create_router_with_bytes_body(self):
|
||||
self._test_create_router(bytes_body=True)
|
||||
|
||||
def test_delete_router(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_router,
|
||||
'tempest.lib.common.rest_client.RestClient.delete',
|
||||
{}, router_id="1", status=204)
|
||||
|
||||
def test_update_router_with_str_body(self):
|
||||
self._test_update_router()
|
||||
|
||||
def test_update_router_with_bytes_body(self):
|
||||
self._test_update_router(bytes_body=True)
|
Loading…
Reference in New Issue
Block a user