示例#1
0
def app_bound_psql(module_context, psql_instance, api_service_admin_client):
    log_fixture("psql_app: Download libraries")
    app_src = AppSources.from_local_path(ApplicationPath.SQL_API_EXAMPLE)
    p_a = PrepApp(app_src.path)
    log_fixture("psql_app: package sample application")
    if os.path.exists(ApplicationPath.SQL_API_EXAMPLE_TAR):
        gzipped_app_path = ApplicationPath.SQL_API_EXAMPLE_TAR
    else:
        gzipped_app_path = p_a.package_app(module_context)

    log_fixture("psql_app: update manifest")
    manifest_params = {"type": TapApplicationType.PYTHON27, "bindings": [psql_instance.name]}
    manifest_path = p_a.update_manifest(params=manifest_params)

    log_fixture("psql_app: push sample application")
    db_app = Application.push(module_context, app_path=gzipped_app_path,
                              name=p_a.app_name, manifest_path=manifest_path,
                              client=api_service_admin_client)

    log_fixture("psql_app: Check the application is running")
    db_app.ensure_running()

    log_fixture("psq_app: Check the application is responding")
    db_app.ensure_responding()
    return db_app
示例#2
0
def sample_python_app(class_context):
    log_fixture("sample_python_app: push sample application")
    if not os.path.exists(ApplicationPath.SAMPLE_PYTHON_APP_TAR):
        test_app_sources = AppSources.from_local_path(sources_directory=ApplicationPath.SAMPLE_PYTHON_APP)
        test_app_sources.run_build_sh()

    app = push_app_from_tar(class_context, ApplicationPath.SAMPLE_PYTHON_APP)

    log_fixture("sample_python_app: Check the application is running")
    app.ensure_running()
    log_fixture("sample_python_app: Check the application is responding")
    app.ensure_responding()
    return app
示例#3
0
 def test_app(self, context, test_space, instance):
     test_app_sources = AppSources.from_local_path(
         sources_directory=ApplicationPath.SAMPLE_JAVA_APP)
     step("Compile the sources")
     test_app_sources.compile_mvn()
     step("Push application to cf")
     application = Application.push(
         context,
         source_directory=ApplicationPath.SAMPLE_JAVA_APP,
         space_guid=test_space.guid,
         bound_services=(instance.name, ))
     step("Check the application is running")
     application.ensure_started()
     return application
示例#4
0
    def test_cascade_app_delete(self, context, instance, admin_client):
        """
        <b>Description:</b>
        Checks if cascade removal of an application removes bound service instance too.

        <b>Input data:</b>
        1. Sample service instance.
        2. Sample java application.
        3. Admin client

        <b>Expected results:</b>
        The application and the service instance are deleted.

        <b>Steps:</b>
        1. Push an application with bound service instance.
        2. Verify the application is running.
        3. Delete the application with cascade flag.
        4. Verify the application is deleted.
        5. Verify the service instance is deleted.
        """
        step("Compile the app")
        test_app_sources = AppSources.from_local_path(sources_directory=ApplicationPath.SAMPLE_JAVA_APP)
        test_app_sources.compile_mvn()

        step("Package the app")
        p_a = PrepApp(ApplicationPath.SAMPLE_JAVA_APP)
        gzipped_app_path = p_a.package_app(context)

        step("Update manifest")
        manifest_params = {"type" : TapApplicationType.JAVA,
                           "bindings" : instance.id}
        manifest_path = p_a.update_manifest(params=manifest_params)

        step("Push app to tap")
        app = Application.push(context, app_path=gzipped_app_path,
                               name=p_a.app_name, manifest_path=manifest_path,
                               client=admin_client)
        step("Check the application is running")
        app.ensure_running()

        app.api_delete(cascade=True)
        assertions.assert_not_in_by_id_with_retry(app.id, Application.get_list)
        assertions.assert_not_in_by_id_with_retry(instance.id, ServiceInstance.get_list)
示例#5
0
def sample_java_app(request, test_org, test_space):
    context = Context()
    test_app_sources = AppSources.from_local_path(
        sources_directory=ApplicationPath.SAMPLE_JAVA_APP)
    log_fixture("sample_java_app: Compile the sources")
    test_app_sources.compile_mvn()
    log_fixture("sample_java_app: Push app to cf")
    cf.cf_login(test_org.name, test_space.name)
    app = Application.push(context=context,
                           space_guid=test_space.guid,
                           source_directory=ApplicationPath.SAMPLE_JAVA_APP)
    app.ensure_started()
    log_fixture("Check the application is running")

    def fin():
        log_fixture("sample_java_app: Delete sample app")
        context.cleanup()

    request.addfinalizer(fin)

    return app
示例#6
0
def app_bound_orientdb(module_context, orientdb_instance, api_service_admin_client):
    log_fixture("orientdb_app: download libraries")
    app_src = AppSources.from_local_path(ApplicationPath.ORIENTDB_API)
    app_src.run_build_sh()

    log_fixture("orientdb_app: package sample application")
    p_a = PrepApp(app_src.path)
    gzipped_app_path = p_a.package_app(module_context)

    log_fixture("orientdb_app: update manifest")
    manifest_params = {"type": TapApplicationType.PYTHON27, "bindings": [orientdb_instance.name]}
    manifest_path = p_a.update_manifest(params=manifest_params)

    log_fixture("orientdb_app: push orientdb-api application")
    application = Application.push(module_context,
                                   app_path=gzipped_app_path,
                                   name=p_a.app_name,
                                   manifest_path=manifest_path,
                                   client=api_service_admin_client)
    log_fixture("orientdb_app: Ensure app is running")
    application.ensure_running()
    log_fixture("orientdb_app: Ensure app is responding")
    application.ensure_responding()
    return application
示例#7
0
    def test_user_can_do_app_flow(self, test_user_clients, role, context):
        """
        <b>Description:</b>
        Checks if different type of users can do the application flow.

        <b>Input data:</b>
        1. Username.
        2. User password.
        3. Sample java application.

        <b>Expected results:</b>
        Different users can do an application flow.

        <b>Steps:</b>
        1. Push an application.
        2. Verify is running.
        3. Verify can be stopped.
        4. Verify can be started.
        5. Verify can be restarted.
        6. Verify can be deleted.
        7. Verify is doesn't exist.
        """
        client = test_user_clients[role]

        step("Compile the app")
        test_app_sources = AppSources.from_local_path(
            sources_directory=ApplicationPath.SAMPLE_JAVA_APP)
        test_app_sources.compile_mvn()

        step("Package the app")
        p_a = PrepApp(ApplicationPath.SAMPLE_JAVA_APP)
        gzipped_app_path = p_a.package_app(context)

        step("Update manifest")
        manifest_params = {"type": TapApplicationType.JAVA}
        manifest_path = p_a.update_manifest(params=manifest_params)

        step("Push app to tap")
        app = Application.push(context,
                               app_path=gzipped_app_path,
                               name=p_a.app_name,
                               manifest_path=manifest_path,
                               client=client)

        step("Check the application is running")
        app.ensure_running()
        step("Stop the application and check that it is stopped")
        app.stop()
        app.ensure_stopped()
        step("Start the application and check that it has started")
        app.start()
        app.ensure_running()
        step("Restart the application and check that it's running")
        app.restart()
        app.ensure_running()
        step("Stop application before delete")
        app.stop()
        app.ensure_stopped()
        step("Delete the application and check that it doesn't exist")
        app.delete()
        assertions.assert_not_in_by_id_with_retry(app.id, Application.get_list)
示例#8
0
def compiled_sample_go_app():
    log_fixture("compiled_sample_go_app: download libraries")
    test_app_sources = AppSources.from_local_path(sources_directory=ApplicationPath.SAMPLE_GO_APP)
    test_app_sources.run_build_sh()
    return test_app_sources.path