From 0383bc09d9afcaa233ddf7a82ba419d3d8880cd3 Mon Sep 17 00:00:00 2001 From: Victor Ryzhenkin Date: Mon, 30 Nov 2015 18:06:00 +0300 Subject: [PATCH] [cfapi] Add multiple tests for cfapi service - Add test for multiple provision action for one space id - Add test for check purge '?' section during provision Change-Id: Ic0abefdbd677cd1c906640346a72e4d1423a9183 Implements: blueprint murano-cfapi-func-tests --- .../service_broker/service_broker_client.py | 4 +- .../test_service_broker_actions.py | 89 ++++++++++++++++++- 2 files changed, 89 insertions(+), 4 deletions(-) diff --git a/murano_tempest_tests/services/service_broker/service_broker_client.py b/murano_tempest_tests/services/service_broker/service_broker_client.py index f7b33604..0f615936 100644 --- a/murano_tempest_tests/services/service_broker/service_broker_client.py +++ b/murano_tempest_tests/services/service_broker/service_broker_client.py @@ -59,7 +59,7 @@ class ServiceBrokerClient(rest_client.RestClient): self.expected_success(200, resp.status) return self._parse_resp(body) - def provision(self, instance_id, service_id, plan_id, post_json): + def provision(self, instance_id, service_id, plan_id, space_id, post_json): """Create new service resources for developer""" uri = '/v2/service_instances/{0}?accepts_incomplete=true'.\ format(instance_id) @@ -67,7 +67,7 @@ class ServiceBrokerClient(rest_client.RestClient): 'service_id': service_id, 'plan_id': plan_id, 'organization_guid': self.tenant_id, - 'space_guid': utils.generate_uuid(), + 'space_guid': space_id, 'parameters': post_json } body = json.dumps(body) diff --git a/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py b/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py index 4bc3ec5e..0e7de182 100644 --- a/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py +++ b/murano_tempest_tests/tests/api/service_broker/test_service_broker_actions.py @@ -45,8 +45,10 @@ class ServiceBrokerActionsTest(base.BaseServiceBrokerAdminTest): app_list) post_json = {} instance_id = utils.generate_uuid() + space_id = utils.generate_uuid() service = self.service_broker_client.provision( - instance_id, app['id'], app['plans'][0]['id'], post_json) + instance_id, app['id'], app['plans'][0]['id'], + space_id, post_json) self.wait_for_result(instance_id, 30) self.addCleanup(self.perform_deprovision, instance_id) self.assertIsInstance(json.loads(service), dict) @@ -69,11 +71,94 @@ class ServiceBrokerActionsTest(base.BaseServiceBrokerAdminTest): "userName": application_name } instance_id = utils.generate_uuid() + space_id = utils.generate_uuid() service = self.service_broker_client.provision( - instance_id, app['id'], app['plans'][0]['id'], post_json) + instance_id, app['id'], app['plans'][0]['id'], + space_id, post_json) self.wait_for_result(instance_id, 30) self.addCleanup(self.perform_deprovision, instance_id) self.assertIsInstance(json.loads(service), dict) binding = self.service_broker_client.create_binding(instance_id) self.assertIsInstance(binding, dict) self.assertEqual(application_name, binding['userName']) + + @test.attr(type=["smoke", "gate"]) + def test_provision_with_incorrect_input(self): + """Test provision with resticted items in object model + + Test will fail on deprovision, if parameters from '?' section + will passed through service-broker. + """ + application_name = utils.generate_name('cfapi') + abs_archive_path, dir_with_archive, archive_name = \ + utils.prepare_package(application_name) + self.addCleanup(os.remove, abs_archive_path) + package = self.application_catalog_client.upload_package( + application_name, archive_name, dir_with_archive, + {"categories": [], "tags": [], 'is_public': True}) + self.addCleanup(self.application_catalog_client.delete_package, + package['id']) + app_list = self.service_broker_client.get_applications_list() + app = self.service_broker_client.get_application(application_name, + app_list) + + # NOTE(freerunner): The '?' section should be cutted off during + # provision action. + post_json = { + '?': { + 'type': 'io.murano.apps.{0}'.format(application_name), + 'id': utils.generate_uuid() + } + } + instance_id = utils.generate_uuid() + space_id = utils.generate_uuid() + service = self.service_broker_client.provision( + instance_id, app['id'], app['plans'][0]['id'], + space_id, post_json) + self.wait_for_result(instance_id, 30) + self.addCleanup(self.perform_deprovision, instance_id) + self.assertIsInstance(json.loads(service), dict) + + @test.attr(type=["smoke", "gate"]) + def test_double_provision_to_the_same_space(self): + application_name = utils.generate_name('cfapi') + abs_archive_path, dir_with_archive, archive_name = \ + utils.prepare_package(application_name) + self.addCleanup(os.remove, abs_archive_path) + package = self.application_catalog_client.upload_package( + application_name, archive_name, dir_with_archive, + {"categories": [], "tags": [], 'is_public': True}) + self.addCleanup(self.application_catalog_client.delete_package, + package['id']) + app_list = self.service_broker_client.get_applications_list() + app = self.service_broker_client.get_application(application_name, + app_list) + post_json = {} + instance_id = utils.generate_uuid() + space_id = utils.generate_uuid() + service = self.service_broker_client.provision( + instance_id, app['id'], app['plans'][0]['id'], + space_id, post_json) + self.wait_for_result(instance_id, 30) + self.addCleanup(self.perform_deprovision, instance_id) + self.assertIsInstance(json.loads(service), dict) + application_name = utils.generate_name('cfapi') + abs_archive_path, dir_with_archive, archive_name = \ + utils.prepare_package(application_name) + self.addCleanup(os.remove, abs_archive_path) + package = self.application_catalog_client.upload_package( + application_name, archive_name, dir_with_archive, + {"categories": [], "tags": [], 'is_public': True}) + self.addCleanup(self.application_catalog_client.delete_package, + package['id']) + app_list = self.service_broker_client.get_applications_list() + app = self.service_broker_client.get_application(application_name, + app_list) + post_json = {} + instance_id = utils.generate_uuid() + service = self.service_broker_client.provision( + instance_id, app['id'], app['plans'][0]['id'], + space_id, post_json) + self.wait_for_result(instance_id, 30) + self.addCleanup(self.perform_deprovision, instance_id) + self.assertIsInstance(json.loads(service), dict)