def test_create_service_with_tag(self, context, app_jar, manifest_json): """ <b>Description:</b> Create new service offering with tag. <b>Input data:</b> 1. application jar file 2. manifest.json file <b>Expected results:</b> Test passes when new offering is created with tags. <b>Steps:</b> 1. Prepare offering json file with tags. 2. Create service offering. 3. Check that created offering is present on the offering list. 4. Check that offering has custom tags. """ step("Prepare offering json") tags = [generate_test_object_name(short=True)] offering_file = ServiceOffering.create_offering_json(tags=tags) step("Register in marketplace") service = ServiceOffering.create_from_binary( context, jar_path=app_jar, manifest_path=manifest_json, offering_path=offering_file) step("Check that service is in marketplace") assert_in_with_retry(service, ServiceOffering.get_list) step("Check that tags names are the same") assert tags == service.tags
def test_app_register_as_offering_as_admin(self, context, app_jar, offering_json, manifest_json, test_user_clients): """ <b>Description:</b> Checks if an offering can be created from an application. <b>Input data:</b> 1. Sample application. 2. Organization id <b>Expected results:</b> An offering can be created from an application as admin <b>Steps:</b> 1. Create offering. 2. Verify is on the offerings list. """ client = test_user_clients["admin"] step("Register in marketplace as admin") offering = ServiceOffering.create_from_binary( context, jar_path=app_jar, manifest_path=manifest_json, offering_path=offering_json, client=client) offering.ensure_ready() assertions.assert_in_with_retry(offering, ServiceOffering.get_list)
def sample_service(class_context, sample_app_jar): log_fixture("Prepare mainfest and offering json") offering_json = ServiceOffering.create_offering_json() manifest_json = ServiceOffering.create_manifest_json(app_type=TapApplicationType.JAVA) log_fixture("Create new example service from binary") sample_service = ServiceOffering.create_from_binary(class_context, jar_path=sample_app_jar, manifest_path=manifest_json, offering_path=offering_json) log_fixture("Check the service is ready") sample_service.ensure_ready() return sample_service
def test_create_and_delete_service_offering_admin( self, context, app_jar, offering_json, manifest_json, api_service_admin_client): """ <b>Description:</b> Create service offering, create an instance of it, delete instance and delete offering. <b>Input data:</b> 1. application jar file 2. manifest.json file 3. offering.json file 4. admin client <b>Expected results:</b> Test passes when: - New offering is created from application jar file. - Instance of newly created offering is created. - Instance can be deleted. - New offering can be deleted from marketplace. <b>Steps:</b> 1. Create service offering from a application jar file. 2. Create service instance. 3. Stop service instance. 4. Delete service instance. 5. Delete service offering. """ step("Register in marketplace") service = ServiceOffering.create_from_binary( context, jar_path=app_jar, manifest_path=manifest_json, offering_path=offering_json, client=api_service_admin_client) step("Check that service is in marketplace") assert_in_with_retry(service, ServiceOffering.get_list) step("Check that service is in state 'READY'") service.ensure_ready() step("Create service instance") instance = ServiceInstance.create_with_name( context, offering_label=service.label, plan_name=ServicePlan.FREE) step("Check created instance") instance.ensure_running() assert instance.offering_id == service.id assert instance.offering_label == service.label step("Stop service instance") instance.stop() instance.ensure_stopped() step("Delete service instance") instance.delete() instance.ensure_deleted() step("Delete service") service.delete(client=api_service_admin_client) step("Check that service isn't in marketplace") assert_not_in_with_retry(service, ServiceOffering.get_list)
def test_create_from_binary(self): context = Context() self.mock_api_service.create_offering_from_binary.return_value = POST_RESPONSE_ONE_PLAN offering = ServiceOffering.create_from_binary(context, jar_path=JAR_PATH, manifest_path=MANIFEST_PATH, offering_path=OFFERING_PATH) assert type(offering) == ServiceOffering assert offering.label == OFFERING_LABEL self.mock_api_service.create_offering_from_binary.assert_called_with(jar_path=JAR_PATH, manifest_path=MANIFEST_PATH, offering_path=OFFERING_PATH, client=offering._client)
def test_create_service_with_display_name(self, context, app_jar, manifest_json): """ <b>Description:</b> Create new service offering with display name. <b>Input data:</b> 1. application jar file 2. manifest.json file <b>Expected results:</b> Test passes when new offering is created with display name. <b>Steps:</b> 1. Prepare offering json file with display name. 2. Create service offering. 3. Check that created offering is present on the offering list. 4. Check that offering has custom display name. """ step("Prepare offering json") display_name = generate_test_object_name() metadata = [ { "key": "displayName", "value": display_name }, ] offering_file = ServiceOffering.create_offering_json(metadata=metadata) step("Register in marketplace") service = ServiceOffering.create_from_binary( context, jar_path=app_jar, manifest_path=manifest_json, offering_path=offering_file) step("Check that service is in marketplace") assert_in_with_retry(service, ServiceOffering.get_list) step("Check that display names are the same") assert display_name == service.display_name
def test_create_service_with_icon(self, context, app_jar, manifest_json, example_image): """ <b>Description:</b> Create new service offering with custom icon. <b>Input data:</b> 1. application jar file 2. manifest.json file 3. example image <b>Expected results:</b> Test passes when new offering is created with custom icon. <b>Steps:</b> 1. Prepare offering json file with custom icon. 2. Create service offering. 3. Check that created offering is present on the offering list. 4. Check that offering has a custom icon. """ step("Prepare offering json") metadata = [ { "key": "imageUrl", "value": example_image.decode() }, ] offering_file = ServiceOffering.create_offering_json(metadata=metadata) step("Register in marketplace") service = ServiceOffering.create_from_binary( context, jar_path=app_jar, manifest_path=manifest_json, offering_path=offering_file) step("Check that service is in marketplace") assert_in_with_retry(service, ServiceOffering.get_list) step("Check that images are the same") assert example_image == bytes(service.image, "utf8")