Merge "[cfapi] Add multiple tests for cfapi service"

This commit is contained in:
Jenkins 2015-12-01 15:05:49 +00:00 committed by Gerrit Code Review
commit ce6a29d6a2
2 changed files with 89 additions and 4 deletions

View File

@ -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)

View File

@ -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)