Пример #1
0
    def test_scale_application(self, sample_application, api_service_admin_client):
        """
        <b>Description:</b>
        Scales the application and verifies that it was scaled and it is running after that operation

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

        <b>Expected results:</b>
        - It's possible to scale application

        <b>Steps:</b>
        - Download and push sample application
        - scale application and verifies that application was scaled by checking
          the replication amount.
        - check is state of app after scale is RUNNING
        """
        step("Scale application")
        replicas_number = 3
        sample_application.scale(replicas=replicas_number, client=api_service_admin_client)
        step("Check number of application instances")
        app_info = Application.get(sample_application.id, client=api_service_admin_client)
        assert app_info.running_instances == replicas_number
        step("Check application is running after scaling")
        app_info.ensure_running()
    def test_scale_application_with_zero_instances_number(
            self, sample_app, api_service_admin_client):
        """
        <b>Description:</b>
        Tries to scale the application with zero instances number

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

        <b>Expected results:</b>
        - After scaling the application down to zero, it should stop

        <b>Steps:</b>
        - Download the application and push it to platform
        - Scale the app by providing zero amount of replicas
        - Make sure the application has stopped
        - Verify the number of replication and running instances
        """
        step("Scale application with zero replicas number")
        replicas_number = 0
        sample_app.scale(replicas=replicas_number,
                         client=api_service_admin_client)
        step(
            "Check that application is stopped, there are zero replicas and there are no running instances"
        )
        app = Application.get(app_inst_id=sample_app.id,
                              client=api_service_admin_client)
        app.ensure_stopped()
        assert app.replication == replicas_number, "Application does not have expected number of replication. App " \
                                                   "replicas number: {}".format(app.replication)
        assert app.running_instances == replicas_number, "Application does not have expected number of running " \
                                                         "instances. App running instances number: {}"\
                                                         .format(app.running_instances)
    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 check_bindings(self, sample_java_app, service_instance,
                    api_service_admin_client):
     step("Check whether bindings sections is available in application")
     app = Application.get(sample_java_app.id,
                           client=api_service_admin_client)
     assert len(app.bindings) == 1
     step("Check whether bindings section is available in service")
     svc = ServiceInstance.get(service_id=service_instance.id,
                               client=api_service_admin_client)
     assert len(svc.bindings) == 1
    def test_change_app_state_in_catalog_and_delete_it(
            self, context, test_sample_apps, api_service_admin_client):
        """
        <b>Description:</b>
        Change the application state in catalog and later delete it

        <b>Input data:</b>
        - Path to application
        - Admin credentials

        <b>Expected results:</b>
        - Application state can be changed in catalog
        - Application state can be set back via api service

        <b>Steps:</b>
        - Prepare the application and push it
        - Make sure the application is running
        - Change the state of the application via catalog
        - Make sure the state has changed
        - Stop the application via api service client and remove it
        - Verify the application was removed
        """
        log_fixture("sample_application: update manifest")
        p_a = PrepApp(test_sample_apps.tapng_python_app.filepath)
        manifest_params = {"type": TapApplicationType.PYTHON27}
        manifest_path = p_a.update_manifest(params=manifest_params)

        log_fixture("Push sample application and check it's running")
        application = Application.push(
            context,
            app_path=test_sample_apps.tapng_python_app.filepath,
            name=p_a.app_name,
            manifest_path=manifest_path,
            client=api_service_admin_client)
        application.ensure_running()

        step("Check that the application has only one instance")
        instances = CatalogApplicationInstance.get_list_for_application(
            application_id=application.id)
        assert len(instances) == 1
        updated_state = TapEntityState.FAILURE
        step("Update app state to {} using catalog api".format(updated_state))
        catalog_api.update_instance(instance_id=instances[0].id,
                                    field_name="state",
                                    value=updated_state)
        step("Check that the app state was updated")
        app = Application.get(app_inst_id=application.id,
                              client=api_service_admin_client)
        assert app.state == updated_state, "Application is not in the expected state. App state: {}".format(
            app.state)
        step("Check that the application can be deleted")
        application.delete()
        step("Check that application has been removed")
        apps = Application.get_list(client=api_service_admin_client)
        assert application not in apps