diff --git a/neutron_taas/tests/tempest_plugin/tests/api/base.py b/neutron_taas/tests/tempest_plugin/tests/api/base.py index 107d527..66f9b29 100644 --- a/neutron_taas/tests/tempest_plugin/tests/api/base.py +++ b/neutron_taas/tests/tempest_plugin/tests/api/base.py @@ -15,6 +15,8 @@ from tempest.api.network import base +from neutron_taas.tests.tempest_plugin.tests import taas_client -class BaseTaaSTest(base.BaseNetworkTest): - pass + +class BaseTaaSTest(taas_client.TaaSClientMixin, base.BaseNetworkTest): + _delete_wrapper = base.BaseNetworkTest._try_delete_resource diff --git a/neutron_taas/tests/tempest_plugin/tests/api/test_taas.py b/neutron_taas/tests/tempest_plugin/tests/api/test_taas.py index 967c9f1..041136e 100644 --- a/neutron_taas/tests/tempest_plugin/tests/api/test_taas.py +++ b/neutron_taas/tests/tempest_plugin/tests/api/test_taas.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + +from tempest_lib import exceptions as lib_exc + from tempest import config from tempest import test @@ -31,5 +35,16 @@ class TaaSExtensionTestJSON(base.BaseTaaSTest): raise cls.skipException(msg) @test.idempotent_id('b993c14e-797a-4c91-b4da-8cb1a450aa2f') - def test_dummy(self): - pass + def test_create_tap_service_and_flow(self): + network = self.create_network() + port = self.create_port(network) + tap_service = self.create_tap_service(network_id=network['id'], + port_id=port['id']) + self.create_tap_flow(tap_service_id=tap_service['id'], + direction='BOTH', source_port=port['id']) + + @test.attr(type=['negative']) + @test.idempotent_id('2d5024f5-bc80-4a31-a4a5-5bf5b14a8f3e') + def test_create_tap_service_with_wrong_network(self): + with testtools.ExpectedException(lib_exc.BadRequest): + self.create_tap_service(network_id='nonexistent') diff --git a/neutron_taas/tests/tempest_plugin/tests/taas_client.py b/neutron_taas/tests/tempest_plugin/tests/taas_client.py new file mode 100644 index 0000000..e00453e --- /dev/null +++ b/neutron_taas/tests/tempest_plugin/tests/taas_client.py @@ -0,0 +1,66 @@ +# Copyright (c) 2015 Midokura SARL +# 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.common.utils import data_utils + +from tempest import config + +from neutron_taas.tests.tempest_plugin.services import client + +CONF = config.CONF + + +class TaaSClientMixin(object): + + @classmethod + def resource_setup(cls): + super(TaaSClientMixin, cls).resource_setup() + manager = cls.manager + cls.tap_services_client = client.TapServicesClient( + manager.auth_provider, + CONF.network.catalog_type, + CONF.network.region or CONF.identity.region, + endpoint_type=CONF.network.endpoint_type, + build_interval=CONF.network.build_interval, + build_timeout=CONF.network.build_timeout, + **manager.default_params) + cls.tap_flows_client = client.TapFlowsClient( + manager.auth_provider, + CONF.network.catalog_type, + CONF.network.region or CONF.identity.region, + endpoint_type=CONF.network.endpoint_type, + build_interval=CONF.network.build_interval, + build_timeout=CONF.network.build_timeout, + **manager.default_params) + + def create_tap_service(self, **kwargs): + body = self.tap_services_client.create_tap_service( + name=data_utils.rand_name("tap-service"), + **kwargs) + tap_service = body['tap_service'] + self.addCleanup(self._delete_wrapper, + self.tap_services_client.delete_tap_service, + tap_service['id']) + return tap_service + + def create_tap_flow(self, **kwargs): + body = self.tap_flows_client.create_tap_flow( + name=data_utils.rand_name("tap-service"), + **kwargs) + tap_flow = body['tap_flow'] + self.addCleanup(self._delete_wrapper, + self.tap_flows_client.delete_tap_flow, + tap_flow['id']) + return tap_flow