def test_get_application(self, sample_app, api_service_admin_client):
        """
        <b>Description:</b>
        Tries to retrieve the application by its id

        <b>Input data:</b>
        - Pushed sample application
        - Admin credentials

        <b>Expected results:</b>
        It's possible to retrieve the application by id

        <b>Steps:</b>
        - Pushed the sample app
        - Make sure the application has received id
        - Retrieve the application by it's id
        - Compare the application that was pushed and received by id
        """
        step("Make sure the sample app has updated id")
        sample_app._ensure_has_id()
        step("Get application")
        app = Application.get(app_inst_id=sample_app.id,
                              client=api_service_admin_client)
        step("Check that the apps are the same")
        assert sample_app == app
    def test_restart_application(self, sample_app):
        """
        <b>Description:</b>
        Restarts the application

        <b>Input data:</b>
        - Application that was already pushed to platform

        <b>Expected results:</b>
        - It's possible to restart the application and the application will
          be running after such procedure

        <b>Steps:</b>
        - Download sample app
        - Push the sample app
        - Make sure the application is running
        - Restart the application
        - Verify that application is running
        """
        step("Make sure the application is running so we can restart it")
        sample_app.ensure_running()
        step("Restart application")
        sample_app.restart()
        step("Verify the application is running")
        sample_app.ensure_running()
Esempio n. 3
0
    def test_platform_admin_can_get_org_users(self, admin_user, test_org,
                                              admin_client,
                                              remove_admin_from_test_org):
        """
        <b>Description:</b>
        Checks if platform admin can get user's list.

        <b>Input data:</b>
        1. No input data.

        <b>Expected results:</b>
        Test passes when platform admin can retrieve organization user list.

        <b>Steps:</b>
        1. Check that platform admin can get a list of users in any org.
        """
        # TODO change test case to use test_org_admin_client instead of default client - when DPNG-10987 is done
        step("Check that platform admin can get a list of users in any org")
        expected_users = User.get_list_in_organization(org_guid=test_org.guid,
                                                       client=admin_client)
        user_list = User.get_list_in_organization(org_guid=test_org.guid)
        assert sorted(user_list) == sorted(expected_users)
    def test_cannot_remove_not_existing_service_instance(
            self, api_service_admin_client):
        """
        <b>Description:</b>
        Tries to remove non-existent service instance

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        It's not possible to remove service instance that does not exist

        <b>Steps:</b>
        Remove non-existing service instance
        """
        step("Try delete not existing service instance")
        assertions.assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_NOT_FOUND,
            ApiServiceHttpStatus.MSG_KEY_NOT_FOUND,
            api.delete_service,
            client=api_service_admin_client,
            service_id=Guid.NON_EXISTING_GUID)
Esempio n. 5
0
    def test_cannot_get_service_credentials_without_name(self, tap_cli):
        """
        <b>Description:</b>
        Check that attempt to get service credentials service without providing service name will return proper information.

        <b>Input data:</b>
        1. Command name: service credentials show

        <b>Expected results:</b>
        Attempt to get service credentials service without providing service name will return proper message.

        <b>Steps:</b>
        1. Run TAP CLI with command service credentials show.
        2. Verify that attempt to get service credentials service without providing service name will return proper message.
        """
        step(
            "Check error message when getting service credentialswithout instance name"
        )
        assert_raises_command_execution_exception(3,
                                                  TapMessage.MISSING_PARAMETER,
                                                  tap_cli.service_credentials,
                                                  [])
    def test_delete_user(self, tap_cli, test_org, user):
        """
        <b>Description:</b>
        Delete user.

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

        <b>Expected results:</b>
        User is successfully deleted and no longer visible in users list

        <b>Steps:</b>
        1. Delete user.
        2. Check that user is no longer present in users list.
        """
        step("Deleting user...")
        tap_cli.delete_user(user.username)
        step("Ensuring {} has been removed from user list".format(
            user.username))
        assert_not_in_with_retry(user,
                                 User.get_all_users,
                                 org_guid=test_org.guid)
    def test_cannot_add_model_without_a_required_parameter(self, missing_param, core_org):
        """
        <b>Description:</b>
        Try to add model without required parameter.

        <b>Input data:</b>
        1. Model with missing parameter: name or creation tool.
        2. Organization

        <b>Expected results:</b>
        Test passes when model catalog returns a 400 http status.

        <b>Steps:</b>
        1. Prepare metadata without required parameter.
        2. Try to add new model with prepared metadata.
        """
        step("Check that adding a model without a required parameter ({}) causes an error".format(missing_param))
        metadata = MODEL_METADATA.copy()
        del metadata[missing_param]
        assert_raises_http_exception(HttpStatus.CODE_BAD_REQUEST, HttpStatus.MSG_BAD_REQUEST,
                                     model_catalog_api.insert_model, org_guid=core_org,
                                     **metadata)
    def test_create_and_delete_catalog_template(self, context):
        """
        <b>Description:</b>
        Checks if new template can be created and deleted.

        <b>Input data:</b>
        no input data

        <b>Expected results:</b>
        Test passes when new template can be created and deleted. According to this, template should be available on
        the list of templates after being created and shouldn't be on this list after deletion.

        <b>Steps:</b>
        1. Create catalog template.
        2. Check that the template is on the list of catalog templates.
        3. Delete the template.
        4. Check that the template is no longer on the list of catalog templates.
        5. Check that getting the deleted template returns an error.
        """
        step("Create catalog template")
        catalog_template = CatalogTemplate.create(
            context, state=TapEntityState.IN_PROGRESS)

        step("Check that template is on list of catalog templates")
        templates = CatalogTemplate.get_list()
        assert catalog_template in templates

        step("Delete template")
        catalog_template.delete()
        step("Check that the template was deleted")
        templates = CatalogTemplate.get_list()
        assert catalog_template not in templates

        step("Check that getting the deleted template returns an error")
        # TODO this error message should be different
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     CatalogTemplate.get,
                                     template_id=catalog_template.id)
Esempio n. 9
0
    def test_get_metadata_of_model(self, sample_model, test_user_clients,
                                   role):
        """
        <b>Description:</b>
        Get metadata of model from model catalog using user client with user/admin role.

        <b>Input data:</b>
        1. Example model existing on models list in model catalog.
        2. User
        3. User role (user or admin)

        <b>Expected results:</b>
        Test passes when user client get list of models successfully.

        <b>Steps:</b>
        1. Get metadata of model using tested user client.
        2. Verify that metadata has expected values.
        """
        step("Get model using {}".format(role))
        client = test_user_clients[role]
        model = ScoringEngineModel.get(model_id=sample_model.id, client=client)
        assert model == sample_model
    def setup_kafka_zookeeper_hdfs_instances(self, request, test_org, test_space):
        step("Create instances for kafka, zookeeper, hdfs and kerberos")

        kafka = ServiceInstance.api_create_with_plan_name(org_guid=test_org.guid, space_guid=test_space.guid,
                                                          service_label=ServiceLabels.KAFKA,
                                                          name=self.KAFKA_INSTANCE_NAME,
                                                          service_plan_name=ServicePlan.SHARED)
        zookeeper = ServiceInstance.api_create_with_plan_name(org_guid=test_org.guid, space_guid=test_space.guid,
                                                              service_label=ServiceLabels.ZOOKEEPER,
                                                              name=self.ZOOKEEPER_INSTANCE_NAME,
                                                              service_plan_name=ServicePlan.SHARED)
        hdfs = ServiceInstance.api_create_with_plan_name(org_guid=test_org.guid, space_guid=test_space.guid,
                                                         service_label=ServiceLabels.HDFS,
                                                         name=self.HDFS_INSTANCE_NAME,
                                                         service_plan_name=ServicePlan.SHARED)
        kerberos = ServiceInstance.api_create_with_plan_name(org_guid=test_org.guid, space_guid=test_space.guid,
                                                             service_label=ServiceLabels.KERBEROS,
                                                             name=self.KERBEROS_INSTANCE_NAME,
                                                             service_plan_name=ServicePlan.SHARED)

        instances = [kafka, zookeeper, hdfs, kerberos]
        request.addfinalizer(lambda: fixtures.tear_down_test_objects(instances))
Esempio n. 11
0
    def test_memory_usage(self, org_metrics):
        """
        <b>Description:</b>
        Checks if metrics on Dashboard show correct value of memory usage.

        <b>Input data:</b>
        No input data.

        <b>Expected results:</b>
        Test passes when metric of memory usage on Dashboard shows correct value within error margin.

        <b>Steps:</b>
        1. Gather metrics from grafana and reference sources.
        2. Check that metric of memory usage on Dashboard shows correct value within error margin.
        """
        step("Get memory and check that memory usage metrics is correct")
        ref_metrics, grafana_metrics = org_metrics
        memory_metrics_ref = ref_metrics.memory_usage_org
        memory_metrics_dashboard = grafana_metrics.memory_usage_org
        assert abs(memory_metrics_ref == memory_metrics_dashboard) < self.MARGIN_ERROR, \
            "\nMemory in dashboard received from grafana: {}, expected from reference: " \
            "{}".format(memory_metrics_dashboard, memory_metrics_ref)
Esempio n. 12
0
    def test_0_create_platform_snapshot_before_changes(self):
        """
        <b>Description:</b>
        Save number of snapshots and trigger new platform snapshot before tests execution.

        <b>Input data:</b>
        -

        <b>Expected results:</b>
        1. Number of snapshots before changes is saved.
        2. New snapshot is triggered.

        <b>Steps:</b>
        1. Retrieve platform snapshots.
        2. Save number of snapshots.
        3. Trigger new snapshot.
        """
        step("Save number of snapshots")
        self.__class__.number_of_snapshots = len(
            platform_snapshot.api_get_snapshots())
        step("Trigger new platform snapshot before changes in platform")
        platform_snapshot.api_trigger_snapshots()
    def test_components_root_endpoint(self, component):
        """
        <b>Description:</b>
        Checks if console root endpoint returns OK status to HTTP GET request.

        <b>Input data:</b>
        Component root endpoint.

        <b>Expected results:</b>
        Test passes when console root endpoint returns OK status to HTTP GET request.

        <b>Steps:</b>
        1. Check console root endpoint.
        2. Verify that HTTP response status code is 200.
        """
        step("Check get / endpoint")
        url = "http://{}.{}".format(component, config.tap_domain)
        client = HttpClientFactory.get(ServiceConfigurationProvider.get(url))
        response = client.request(method=HttpMethod.GET,
                                  path="",
                                  raw_response=True)
        assert response.status_code == HttpStatus.CODE_OK
    def test_try_scale_non_existing_app(self, tap_cli):
        """
        <b>Description:</b>
        Try to scale non existing application.

        <b>Input data:</b>
        1. Command scale: application scale --name <non_existing_name> --replicas <number_of_replicas>
        2. Name of non existing application
        3. Number of replicas

        <b>Expected results:</b>
        Test passes when attempt to scale non existing application returns proper message.

        <b>Steps:</b>
        1. Run TAP CLI with command: application scale --name <non_existing_name> --replicas <number_of_replicas>.
        2. Verify that attempt to scale non existing application return expected error message.
        """
        scaled_instances = '3'
        step("Try to scale app with non existing name")
        assert_raises_command_execution_exception(1, self.CANNOT_FIND_MSG, tap_cli.app_scale,
                                                  application_name=self.NON_EXISTING_APP_NAME,
                                                  instances=scaled_instances)
Esempio n. 15
0
    def test_info(self, tap_cli, cli_login):
        """
        <b>Description:</b>
        Check that command 'info' prints proper credentials

        <b>Input data:</b>
        1. Command name: info
        2. TAP domain api address
        3. Username

        <b>Expected results:</b>
        Test passes when Tap CLI 'info' command returns proper credentials.

        <b>Steps:</b>
        1. Run TAP CLI with command 'info'.
        2. Verify response contains expected address.
        3. Verify response contains expected username.
        """
        step("Run tap info")
        output = tap_cli.info()
        assert config.cf_api_url in output
        assert config.admin_username in output
Esempio n. 16
0
    def test_2_check_request_to_se_application(self, se_instance):
        """
        <b>Description:</b>
        Send request to scoring engine application.

        <b>Input data:</b>
        No input data.

        <b>Expected results:</b>
        Test passes if scoring engine application returns correct response.

        <b>Steps:</b>
        1. Check that Scoring Engine app responds to an HTTP request
        """
        step("Check that Scoring Engine app responds to an HTTP request")
        url = "{}/v1/score?data=1,2,3,4,5,6,7,8,9".format(se_instance.url)
        headers = {
            "Accept": "text/plain",
            "Content-Types": "text/plain; charset=UTF-8"
        }
        response = requests.post(url, data="", headers=headers)
        assert response.text == ScoringEngineHttpStatus.MSG_SCORING_ENGINE_RESULT, "Scoring engine response was wrong"
    def test_3_check_table_content(self, test_data_urls):
        """
        <b>Description:</b>
        Check that table content is correct.

        <b>Input data:</b>
        1. transfer title
        2. database name

        <b>Expected results:</b>
        Test passes when table content, number of rows and columns are equal with source file.

        <b>Steps:</b>
        1. Compare all values from hue table with values in source file.
        2. Check that number of rows in hue table is equal to rows in csv file.
        3. Check that number of columns in hue table is equal to columns in csv file.
        """
        step("Check table content against submitted transfer")
        table_response = hue.get_table(database_name=self.database_name,
                                       table_name=self.transfer.title)
        assert table_response["rows"] == get_csv_data(
            test_data_urls.test_transfer.filepath)
    def test_delete_not_existing_service_plan(self, catalog_service):
        """
        <b>Description:</b>
        Checks if there is no possibility of deleting not existing service plan.

        <b>Input data:</b>
        1. sample catalog template
        2. sample catalog service
        3. plan_id: generated test object name

        <b>Expected results:</b>
        Test passes when plan is not deleted and status code 404 with error message '100: Key not found' is returned.

        <b>Steps:</b>
        1. Delete plan using invalid plan id.
        """
        step("Delete not existing service plan")
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     ServicePlan.delete_plan,
                                     service_id=catalog_service.id,
                                     plan_id=generate_test_object_name())
    def test_cannot_get_template_with_wrong_template_id(self):
        """
        <b>Description:</b>
        Checks if there is no possibility of getting template using wrong template id.

        <b>Input data:</b>
        1. invalid id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'

        <b>Expected results:</b>
        Test passes when template is not returned and status code 404 with error message: '100: Key not found' is
        returned.

        <b>Steps:</b>
        1. Get template using wrong template id.
        """
        step(
            "Check that it's not possible to get template with wrong template_id"
        )
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     CatalogTemplate.get,
                                     template_id=Guid.NON_EXISTING_GUID)
Esempio n. 20
0
    def test_cannot_update_non_existing_application(self):
        """
        <b>Description:</b>
        Checks if there is no possibility of updating application giving invalid application id.

        <b>Input data:</b>
        1. invalid id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'

        <b>Expected results:</b>
        Test passes when application is not updated and status code 404 with error message: '100: Key not found' is
        returned.

        <b>Steps:</b>
        1. Update application giving invalid application id.
        """
        step("Check that it's not possible to update non-existing application")
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     catalog_api.update_application,
                                     application_id=Guid.NON_EXISTING_GUID,
                                     field_name="replication",
                                     value=2)
    def test_user_change_passwd_to_valid(self, tap_cli, current_username,
                                         current_password):
        """
        <b>Description:</b>
        Changes password to valid one

        <b>Input data:</b>
        1. New password

        <b>Expected results:</b>
        Password is successfully changed

        <b>Steps:</b>
        1. Change password.
        2. Login again with new password.
        """
        new_passwd = 'NewSecurePassword'
        step("Changing password...")
        tap_cli.change_password(current=current_password, new=new_passwd)
        step("New user logs in with changed password...")
        result = tap_cli.login(tap_auth=[current_username, new_passwd])
        assert TapMessage.AUTHENTICATION_SUCCEEDED in result
    def test_non_admin_cannot_access_platform_operations(self, context, test_org):
        """
        <b>Description:</b>
        Checks if non-admin user cannot reach summary operations page /app/platformdashboard/summary.

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

        <b>Expected results:</b>
        Test passes when non-admin user was not able to reach summary operations page.

        <b>Steps:</b>
        1. Create non-admin user.
        2. Verify that the user cannot reach summary operations page.
        """
        step("Create non-admin user")
        test_user = User.create_by_adding_to_organization(context=context, org_guid=test_org.guid)
        client = test_user.login(rest_prefix="")
        step("Checking if non-admin user cannot request admin-only data")
        assertions.assert_raises_http_exception(HttpStatus.CODE_UNAUTHORIZED, HttpStatus.MSG_UNAUTHORIZED,
                                                client.request, method=HttpMethod.GET, url=console_url,
                                                path=self.PLATFORM_SUMMARY_PATH)
Esempio n. 23
0
    def test_cannot_create_service_instance_without_offering(
            self, offering, tap_cli):
        """
        <b>Description:</b>
        Check that attempt to create service instance without offering name will proper information.

        <b>Input data:</b>
        1. Command name: service create
        2. Service offering

        <b>Expected results:</b>
        Attempt to create service without offering name will return proper message.

        <b>Steps:</b>
        1. Run TAP CLI with command create-service.
        2. Verify that attempt to create service without offering name return expected message.
        """
        step(
            "Check error message when creating instance without offering name")
        assert_raises_command_execution_exception(
            3, TapMessage.MISSING_PARAMETER, tap_cli.create_service,
            ["--plan", offering.service_plans[0].name, "--name", "test"])
Esempio n. 24
0
 def test_add_new_user(self, client, is_authorized):
     step("Try to add new user with each client type.")
     user_list = User.api_get_list_via_space(TestData.test_space.guid)
     if is_authorized:
         test_user = User.api_create_by_adding_to_space(
             self.context,
             TestData.test_org.guid,
             TestData.test_space.guid,
             inviting_client=self.user_clients[client])
         self._assert_user_in_space_with_roles(test_user,
                                               TestData.test_space.guid)
     else:
         assert_raises_http_exception(
             HttpStatus.CODE_FORBIDDEN,
             HttpStatus.MSG_FORBIDDEN,
             User.api_create_by_adding_to_space,
             self.context,
             TestData.test_org.guid,
             TestData.test_space.guid,
             inviting_client=self.user_clients[client])
         assert User.api_get_list_via_space(
             TestData.test_space.guid) == user_list, "User was added"
    def test_cannot_retrieve_logs_with_invalid_id(self,
                                                  api_service_admin_client):
        """
        <b>Description:</b>
        Retrieve logs from non-existent service instance

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        It's not possible to retrieve any logs

        <b>Steps:</b>
        Retrieve the logs from non-existing service instance
        """
        step("Try to retrieve service instance logs with invalid id")
        assertions.assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_NOT_FOUND,
            "{}",
            api.get_service_logs,
            client=api_service_admin_client,
            service_id=Guid.INVALID_GUID)
Esempio n. 26
0
    def test_2_get_table_column_content(self, expected_transfer_content):
        """
        <b>Description:</b>
        Check that content of table column is correct.

        <b>Input data:</b>
        1. hdfs hive demo application client

        <b>Expected results:</b>
        Test passes when table column contains expected content.

        <b>Steps:</b>
        1. Retrieve hive column content.
        2. Check that column content is the same as expected.
        """
        step("Get hive table column content")
        path = "{}/{}".format(self.TABLE_NAME, self.COLUMN_NAME)
        hive_table_column_content = self.hive_client.request(method=HttpMethod.GET, path=path)
        hive_table_column_content = [i.strip() for i in hive_table_column_content.split("\n") if i]
        step("Check both columns are the same")
        expected_column_0 = [i[0] for i in expected_transfer_content]
        assert hive_table_column_content == expected_column_0
    def test_0_check_instance_on_the_list(self, instance,
                                          api_service_admin_client):
        """
        <b>Description:</b>
        Verify the service instance is on the list

        <b>Input data:</b>
        - service instance
        - Admin credentials

        <b>Expected results:</b>
        Instance is on the list

        <b>Steps:</b>
        - Retrieve the list of instances
        - Verify the instance is on the list
        """
        step("Get service instances list from ApiService")
        api_service_instances_list = ServiceInstance.get_list(
            client=api_service_admin_client)
        step("Check if instance is on the list")
        assert instance in api_service_instances_list
Esempio n. 28
0
    def test_cannot_get_non_existent_service(self):
        """
        <b>Description:</b>
        Checks if there is no possibility of getting service using not existing service id.

        <b>Input data:</b>
        1. invalid id: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'

        <b>Expected results:</b>
        Test passes when service is not found on the list of services and status code: 404 with message: '100: Key not
        found' is returned.

        <b>Steps:</b>
        1. Get service using not existing service id.
        """
        step(
            "Check that it's not possible to get service with non-existent service_id"
        )
        assert_raises_http_exception(CatalogHttpStatus.CODE_NOT_FOUND,
                                     CatalogHttpStatus.MSG_KEY_NOT_FOUND,
                                     CatalogService.get,
                                     service_id=Guid.NON_EXISTING_GUID)
Esempio n. 29
0
    def test_org_user_cannot_get_org_users(self, test_org_user_client,
                                           test_org):
        """
        <b>Description:</b>
        Checks if non-admin cannot get user's list.

        <b>Input data:</b>
        1. Email address.
        2. User password.

        <b>Expected results:</b>
        Test passes when non-admin cannot get user's list.

        <b>Steps:</b>
        1. Check that user cannot get list of users in org.
        """
        step("Check that user cannot get list of users in org")
        assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                     HttpStatus.MSG_FORBIDDEN,
                                     User.get_list_in_organization,
                                     org_guid=test_org.guid,
                                     client=test_org_user_client)
    def test_0_create_gearpump_instance(self, class_context):
        """
        <b>Description:</b>
        Checks if gearpump instance can be created.

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

        <b>Expected results:</b>
        Gearpump instance was created.

        <b>Steps:</b>
        1. Create instance.
        2. Verify the instance exists.
        """
        step("Create gearpump instance with plan {} ".format(
            self.GEARPUMP_PLAN_NAME))
        self.__class__.gearpump = Gearpump(
            class_context, service_plan_name=self.GEARPUMP_PLAN_NAME)
        step("Ensure that instance is running")
        self.gearpump.instance.ensure_running()
        self.gearpump.get_credentials()