コード例 #1
0
    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
コード例 #2
0
    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)
コード例 #3
0
    def test_delete_pending_invitation(self, context, test_org):
        """
        <b>Description:</b>
        Checks if user cannot use obtained invitation after it was removed from pending invitations list.

        <b>Input data:</b>
        1. Email address.

        <b>Expected results:</b>
        Test passes when registering user fails returning HTTP status code 403 FORBIDDEN.

        <b>Steps:</b>
        1. Invite new user
        2. Delete pending user invitation.
        3. Check that the user cannot register after deletion of pending invitation.
        """
        step("Invite new user")
        invitation = Invitation.api_send(context)
        assert_in_with_retry(invitation, Invitation.api_get_list)
        step("Delete pending user invitation")
        invitation.api_delete()
        assert_not_in_with_retry(invitation, Invitation.api_get_list)
        step(
            "Check that the user cannot register after deletion of pending invitation"
        )
        assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                     HttpStatus.MSG_EMPTY,
                                     onboarding.register,
                                     context=context,
                                     org_guid=test_org.guid,
                                     code=invitation.code,
                                     username=invitation.username)
コード例 #4
0
    def test_create_image_in_image_factory(self, context, blob_store_artifact):
        """
        <b>Description:</b>
        Create image in image factory

        <b>Input data:</b>
        Catalog image
        Image id

        <b>Expected results:</b>
        - It's possible to create image and later remove it

        <b>Steps:</b>
        - Create image in image factory
        - Verify it's ready
        - Remove the image and verify it was removed
        """
        catalog_image = blob_store_artifact

        step("CATALOG: Update image state on PENDING")
        catalog_image.update(field_name="state", value=TapEntityState.PENDING)

        step(
            "IMAGE-REPOSITORY: Wait until the image id appears in image-repository"
        )
        assertions.assert_in_with_retry(catalog_image.id,
                                        ImageRepository.get_repository_ids)

        step("CATALOG: Check application state")
        catalog_image.ensure_in_state(TapEntityState.READY)

        step("BLOB-STORE: Wait until blob is successfully removed")
        self.assert_blob_deleted(blob_id=catalog_image.id)
コード例 #5
0
 def test_3_create_job(self, test_org, add_admin_to_test_org):
     step("Get PSQL credentials")
     psql_credentials = self.psql_app.get_credentials(
         service_name=ServiceLabels.PSQL)
     step("Create job")
     self.__class__.test_job = HdfsJob.api_create(
         org_guid=test_org.guid,
         name=None,
         frequency_amount=self.JOB_FREQUENCY_AMOUNT,
         frequency_unit=self.JOB_FREQUENCY_UNIT,
         zone_id=self.ZONE_ID,
         check_column="",
         import_mode=self.IMPORT_MODE,
         db_hostname=psql_credentials["hostname"],
         db_name=psql_credentials["dbname"],
         port=psql_credentials["port"],
         last_value="",
         password=psql_credentials["password"],
         table=self.test_table_name,
         target_dir="",
         username=psql_credentials["username"],
         end_job_minutes_later=self.END_JOB_MINUTES_LATER)
     step("Check job is on the list")
     assertions.assert_in_with_retry(self.test_job, HdfsJob.api_get_list,
                                     test_org.guid)
     step("Check job succeded")
     self.test_job.ensure_successful(test_org.guid)
     assert self.test_job.status == JobStatus.SUCCEEDED.value
     self.__class__.hdfs_output_dir = self.test_job.target_dirs[0].split(
         "nameservice1/")[1]
コード例 #6
0
 def user(self, context, test_org, cli_login):
     new_user = onboard(context=context,
                        org_guid=test_org.guid,
                        check_email=False)
     assert_in_with_retry(new_user,
                          User.get_all_users,
                          org_guid=test_org.guid)
     return new_user
コード例 #7
0
    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_0_create_job(self, test_org):
     self.__class__.TEST_JOB = HdfsJob.api_create(
         test_org.guid, frequency_amount=self.JOB_FREQUENCY_AMOUNT,
         frequency_unit=self.JOB_FREQUENCY_UNIT, zone_id=self.ZONE_ID, check_column="col1",
         import_mode=self.IMPORT_MODE, db_hostname=self.db_hostname, db_name=self.db_name, port=self.port,
         last_value=0, password=self.password, table=self.test_table_name, target_dir="", username=self.username,
         end_job_minutes_later=15)
     assertions.assert_in_with_retry(self.TEST_JOB, HdfsJob.api_get_list, test_org.guid)
     self.TEST_JOB.ensure_successful(test_org.guid)
     self.__class__.HDFS_CONFIG_DIR = self.TEST_JOB.app_path
     self.__class__.HDFS_OUTPUT_DIR = self.TEST_JOB.target_dirs[0]
コード例 #9
0
 def _create_jupyter_instance_and_login(self, context, param_key,
                                        param_value):
     param = {param_key: param_value}
     step("Create service instance and check it exist in list")
     jupyter = Jupyter(context, params=param)
     assert_in_with_retry(jupyter.instance, ServiceInstance.get_list)
     step("Get credentials for the new jupyter service instance")
     jupyter.get_credentials()
     jupyter.login()
     terminal = jupyter.connect_to_terminal(terminal_no=0)
     _ = terminal.get_output()
     return terminal
コード例 #10
0
    def test_add_user(self, test_org, user):
        """
        <b>Description:</b>
        Add user.

        <b>Input data:</b>
        1. User

        <b>Expected results:</b>
        User is successfully added and visible in users list

        <b>Steps:</b>
        1. Delete user.
        2. Check that user is present on users list.
        """
        assert_in_with_retry(user, User.get_all_users, org_guid=test_org.guid)
コード例 #11
0
def test_create_service_with_icon(test_org, test_space, sample_python_app,
                                  example_image):
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        image=example_image)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Check that images are the same")
    assert example_image == bytes(service.image, "utf8")
    step("Delete service")
    service.api_delete()
コード例 #12
0
def test_create_and_delete_service(test_org, test_space, sample_python_app):
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Delete service")
    service.api_delete()
    step("Check that service isn't in marketplace")
    assert_not_in_with_retry(service,
                             ServiceType.api_get_list_from_marketplace,
                             test_space.guid)
コード例 #13
0
def test_create_service_with_tag(test_org, test_space, sample_python_app):
    tags = [generate_test_object_name(short=True)]
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        tags=tags)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Check that tags names are the same")
    assert tags == service.tags
    step("Delete service")
    service.api_delete()
コード例 #14
0
 def test_1_change_dataset_to_public_and_import_it_to_arcadia(
         self, test_org, dataset, arcadia):
     step("Change dataset to public")
     dataset.api_update(is_public=True)
     dataset = DataSet.api_get(dataset.id)
     assert dataset.is_public, "Dataset was not updated"
     step("Publish updated dataset")
     dataset.api_publish()
     step(
         "Check that dataset name is visible on the public table list in arcadia"
     )
     table_list = arcadia.get_table_list("public")
     assert dataset.title in table_list, "Dataset not found in table list in arcadia"
     step("Create new dataset in arcadia")
     arcadia_dataset = arcadia.create_dataset("public", dataset.title)
     assertions.assert_in_with_retry(arcadia_dataset,
                                     arcadia.get_dataset_list)
コード例 #15
0
def test_create_service_with_display_name(test_org, test_space,
                                          sample_python_app):
    display_name = generate_test_object_name()
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        display_name=display_name)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Check that display names are the same")
    assert display_name == service.display_name
    step("Delete service")
    service.api_delete()
コード例 #16
0
    def create_service_and_instance(self, request, test_org, test_space,
                                    sample_service):
        step("Create an instance")
        instance = ServiceInstance.api_create(
            test_org.guid,
            test_space.guid,
            sample_service.label,
            service_plan_guid=sample_service.service_plans[0]["guid"])
        step("Check that service instance is present")
        assert_in_with_retry(instance, ServiceInstance.api_get_list,
                             test_space.guid, sample_service.guid)

        def fin():
            step("Delete instance")
            instance.api_delete()

        request.addfinalizer(fin)
コード例 #17
0
    def test_add_new_pending_invitation(self, context):
        """
        <b>Description:</b>
        Checks if new pending invitations can be added.

        <b>Input data:</b>
        1. Email address.

        <b>Expected results:</b>
        Test passes when new pending invitation appears on pending invitations list.

        <b>Steps:</b>
        1. Invite new user.
        2. Check that the user is in the pending invitation list.
        """
        step("Invite new user")
        invitation = Invitation.api_send(context)
        step("Check that the user is in the pending invitation list")
        assert_in_with_retry(invitation, Invitation.api_get_list)
コード例 #18
0
    def test_cannot_remove_service_with_instance(self, context, sample_service,
                                                 test_user_clients, role):
        """
        <b>Description:</b>
        Try to delete a service offering with created service instance.

        <b>Input data:</b>
        1. user client
        2. sample service offering

        <b>Expected results:</b>
        Test passes when service offering cannot be deleted.

        <b>Steps:</b>
        1. Create service instance.
        2. Ensure that instance is running.
        3. Try to delete service offering.
        4. Check that platform returns a 405 http status code
        and message that service offering with instance cannot be deleted.
        """
        client = test_user_clients[role]
        offering_id = sample_service.id
        plan_id = sample_service.service_plans[0].id

        step("Create an instance")
        instance = ServiceInstance.create(context,
                                          offering_id=offering_id,
                                          plan_id=plan_id,
                                          client=client)

        step("Ensure that instance is running")
        instance.ensure_running()

        step("Check that service instance is present")
        assert_in_with_retry(instance,
                             ServiceInstance.get_list,
                             name=instance.name)

        step("Attempt to delete public service with instance")
        assert_raises_http_exception(
            HttpStatus.CODE_FORBIDDEN,
            HttpStatus.MSG_CANNOT_REMOVE_SERVICE_WITH_INSTANCE,
            sample_service.delete)
コード例 #19
0
def test_create_instance_as_authorized_user(space_users_clients, role,
                                            test_org, test_space,
                                            sample_service):
    client = space_users_clients[role]
    step("Create an instance")
    instance = ServiceInstance.api_create(
        test_org.guid,
        test_space.guid,
        sample_service.label,
        service_plan_guid=sample_service.service_plans[0]["guid"],
        client=client)
    step("Check that service instance is present")
    assert_in_with_retry(instance,
                         ServiceInstance.api_get_list,
                         test_space.guid,
                         sample_service.guid,
                         client=client)
    step("Delete instance")
    instance.api_delete()
コード例 #20
0
 def test_0_create_new_dataset_and_import_it_to_arcadia(
         self, test_org, dataset, arcadia):
     step("Publish created dataset")
     dataset.api_publish()
     step(
         "Check that organization guid is visible on the database list in arcadia"
     )
     expected_db_name = escape_hive_name(test_org.guid)
     db_list = arcadia.get_database_list()
     assert expected_db_name in db_list, "{} was not found in db list".format(
         expected_db_name)
     step("Check that dataset name is visible on the table list in arcadia")
     assertions.assert_in_with_retry(escape_hive_name(dataset.title),
                                     arcadia.get_table_list,
                                     expected_db_name)
     step("Create new dataset in arcadia")
     arcadia_dataset = arcadia.create_dataset(test_org.name, dataset.title)
     assertions.assert_in_with_retry(arcadia_dataset,
                                     arcadia.get_dataset_list)
コード例 #21
0
    def test_create_and_delete_service_instance(self, context,
                                                test_org_user_client,
                                                offering_name, plan_name,
                                                open_tunnel):
        """
        <b>Description:</b>
        Check service instance creation and deletion.

        <b>Input data:</b>
        1. non parametized marketplace services

        <b>Expected results:</b>
        Test passes when service instance is created and deleted successfully.

        <b>Steps:</b>
        1. Create service instance.
        2. Ensure that instance is running.
        3. Check that service instance is present on instances list.
        4. Stop service instance.
        5. Delete service instance.
        """
        step("Create an instance")
        instance = ServiceInstance.create_with_name(
            context,
            offering_label=offering_name,
            plan_name=plan_name,
            client=test_org_user_client)
        step("Ensure that instance is running")
        instance.ensure_running()
        step("Check that service instance is present")
        assert_in_with_retry(instance,
                             ServiceInstance.get_list,
                             name=instance.name)
        step("Validate resources")
        self.validate_resources(instance, offering_name, plan_name,
                                open_tunnel)
        step("Stop service instance")
        instance.stop()
        instance.ensure_stopped()
        step("Delete an instance")
        instance.delete()
        instance.ensure_deleted()
コード例 #22
0
def test_connect_to_atk_from_jupyter_using_default_atk_client(
        context, request, core_space, test_space, test_org, admin_user):
    """Connect to Atk from Jupyter using Default Atk Client"""
    step("Get atk app from core space")
    atk_app = next(
        (app for app in Application.get_list() if app.name == "atk"), None)
    if atk_app is None:
        raise AssertionError("Atk app not found in core space")
    atk_url = atk_app.urls[0]
    step("Add admin to test space")
    admin_user.api_add_to_space(space_guid=test_space.guid,
                                org_guid=test_org.guid,
                                roles=User.SPACE_ROLES["developer"])
    step("Create instance of Jupyter service")
    jupyter = Jupyter(context=context)
    assertions.assert_in_with_retry(jupyter.instance,
                                    ServiceInstance.api_get_list,
                                    space_guid=test_space.guid)
    step("Get credentials for the new jupyter service instance")
    jupyter.get_credentials()
    step("Login into Jupyter")
    jupyter.login()
    request.addfinalizer(lambda: jupyter.instance.api_delete())
    step("Create new Jupyter notebook")
    notebook = jupyter.create_notebook()
    step("import atk client in the notebook")
    notebook.send_input("import trustedanalytics as ta")
    assert notebook.check_command_status() == "ok"
    step("Create credentials file using atk client")
    notebook.send_input("ta.create_credentials_file('./cred_file')")
    assert "URI of the ATK server" in notebook.get_prompt_text()
    notebook.send_input(atk_url, reply=True)
    assert "User name" in notebook.get_prompt_text()
    notebook.send_input(config.admin_username, reply=True)
    assert "" in notebook.get_prompt_text()
    notebook.send_input(config.admin_password,
                        reply=True,
                        obscure_from_log=True)
    assert "Connect now?" in notebook.get_prompt_text()
    notebook.send_input("y", reply=True)
    assert "Connected." in str(notebook.get_stream_result())
    notebook.ws.close()
コード例 #23
0
    def test_cancel_to_delete_service_instance(self, tap_cli, service):
        """
        <b>Description:</b>
        Check deleting service with interactive mode.

        <b>Input data:</b>
        1. Service instance

        <b>Expected results:</b>
        Canceled.

        <b>Steps:</b>
        1. Canceled.
        """
        step("Cancelling service delete...")
        result = tap_cli.run_command_with_prompt(
            ['service', 'delete', '--name', service.name],
            prompt_answers=['N'])
        assert "Canceled" in result
        assert_in_with_retry(service.name, tap_cli.service_list)
コード例 #24
0
    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")
コード例 #25
0
    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
コード例 #26
0
 def _validate_instance_created(self):
     """Check if service instance has been properly created."""
     step("Check that service instance has been created")
     assert_in_with_retry(self.__service, ServiceInstance.get_list)
コード例 #27
0
 def invitation(self, class_context, tap_cli):
     log_fixture("Send invitation")
     invitation = CliInvitation.send(class_context, tap_cli=tap_cli)
     assert_in_with_retry(invitation, CliInvitation.get_list, tap_cli)
     return invitation
コード例 #28
0
 def jupyter_instance(class_context, admin_user):
     step("Create instance of Jupyter service")
     jupyter = Jupyter(class_context)
     assertions.assert_in_with_retry(jupyter.instance,
                                     ServiceInstance.get_list)
     return jupyter