Esempio n. 1
0
def create_application():
    ereporter2.register_formatter()
    # App that serves HTML pages and old API.
    a = handlers_frontend.create_application(False)
    # App that serves new endpoints API.
    api = endpoints.api_server([handlers_endpoints.swarming_api])
    return a, api
Esempio n. 2
0
 def setUp(self):
     super(FrontendHandlersTest, self).setUp()
     self.mock(replication, 'trigger_replication',
               lambda *_args, **_kws: None)
     self.app = webtest.TestApp(
         handlers_frontend.create_application(debug=True),
         extra_environ={'REMOTE_ADDR': '127.0.0.1'})
    def setUp(self):
        """Creates a new app instance for every test case."""
        super(MainTest, self).setUp()
        self.testbed.init_user_stub()

        self.source_ip = '192.168.0.1'
        self.app = webtest.TestApp(
            handlers_frontend.create_application(debug=True),
            extra_environ={'REMOTE_ADDR': self.source_ip})

        self.auth_app = webtest.TestApp(
            auth.create_wsgi_application(debug=True),
            extra_environ={
                'REMOTE_ADDR': self.source_ip,
                'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
            })

        full_access_group = config.settings().auth.full_access_group
        readonly_access_group = config.settings().auth.readonly_access_group

        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            readonly_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            full_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        self.set_as_anonymous()
Esempio n. 4
0
def create_application():
    ereporter2.register_formatter()

    # Zap out the ndb in-process cache by default.
    # This cache causes excessive memory usage in in handler where a lot of
    # entities are fetched in one query. When coupled with high concurrency
    # as specified via max_concurrent_requests in app.yaml, this may cause out of
    # memory errors.
    ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
    ndb.Context._cache_policy = staticmethod(lambda _key: False)

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
    # App that serves new endpoints API.
    endpoints_api = endpoints_webapp2.api_server([
        handlers_endpoints_v1.IsolateService,
        # components.config endpoints for validation and configuring of
        # luci-config service URL.
        config.ConfigApi,
    ])
    gae_ts_mon.instrument_wsgi_application(endpoints_api)

    prpc_api = webapp2.WSGIApplication(handlers_prpc.get_routes())
    return frontend, endpoints_api, prpc_api
Esempio n. 5
0
 def setUp(self):
   super(FrontendHandlersTest, self).setUp()
   self.mock(replication, 'trigger_replication', lambda *_args, **_kws: None)
   self.app = webtest.TestApp(
       handlers_frontend.create_application(debug=True),
       extra_environ={'REMOTE_ADDR': '127.0.0.1'})
   auth_testing.mock_is_admin(self, True)
   auth_testing.mock_get_current_identity(self)
Esempio n. 6
0
def create_applications():
    ereporter2.register_formatter()

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)
    # App that serves endpoints APIs.
    api = endpoints.api_server([auth.AuthService, config.ConfigApi])
    return frontend, api
Esempio n. 7
0
def create_applications():
  ereporter2.register_formatter()

  # App that serves HTML pages and old API.
  frontend = handlers_frontend.create_application(False)
  # App that serves endpoints APIs.
  api = endpoints.api_server([auth.AuthService, config.ConfigApi])
  return frontend, api
Esempio n. 8
0
def create_application():
  ereporter2.register_formatter()

  # App that serves HTML pages and old API.
  frontend = handlers_frontend.create_application(False)
  # App that serves new endpoints API.
  api = endpoints.api_server([handlers_endpoints.IsolateService])
  return frontend, api
Esempio n. 9
0
def create_application():
    ereporter2.register_formatter()

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)
    # App that serves new endpoints API.
    api = endpoints.api_server([handlers_endpoints_v1.IsolateService, handlers_endpoints_v2.IsolateServiceV2])
    return frontend, api
Esempio n. 10
0
def create_applications():
    ereporter2.register_formatter()

    # App that serves HTML pages and the main API.
    frontend = monitoring.wrap_webapp2_app(
        handlers_frontend.create_application(False))

    api = monitoring.wrap_webapp2_app(
        endpoints_webapp2.api_server([auth.AuthService, config.ConfigApi]))

    return frontend, api
Esempio n. 11
0
 def setUp(self):
   super(AppTestBase, self).setUp()
   # By default requests in tests are coming from bot with fake IP.
   app = handlers_frontend.create_application(True)
   app.router.add(('/_ah/queue/deferred', deferred.TaskHandler))
   self.app = webtest.TestApp(
       app,
       extra_environ={
         'REMOTE_ADDR': self.source_ip,
         'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
       })
 def setUp(self):
     super(FrontendTest, self).setUp()
     template.bootstrap()
     # By default requests in tests are coming from bot with fake IP.
     self.app = webtest.TestApp(handlers_frontend.create_application(True),
                                extra_environ={
                                    'REMOTE_ADDR':
                                    self.source_ip,
                                    'SERVER_SOFTWARE':
                                    os.environ['SERVER_SOFTWARE'],
                                })
Esempio n. 13
0
 def setUp(self):
     super(AppTestBase, self).setUp()
     # By default requests in tests are coming from bot with fake IP.
     app = handlers_frontend.create_application(True)
     app.router.add(('/_ah/queue/deferred', deferred.TaskHandler))
     self.app = webtest.TestApp(app,
                                extra_environ={
                                    'REMOTE_ADDR':
                                    self.source_ip,
                                    'SERVER_SOFTWARE':
                                    os.environ['SERVER_SOFTWARE'],
                                })
Esempio n. 14
0
def create_application():
    ereporter2.register_formatter()
    # Task queues must be sent to the backend.
    utils.set_task_queue_module('backend')
    template.bootstrap()

    # Zap out the ndb in-process cache by default.
    # This cache causes excessive memory usage in in handler where a lot of
    # entities are fetched in one query. When coupled with high concurrency
    # as specified via max_concurrent_requests in app.yaml, this may cause out of
    # memory errors.
    ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
    ndb.Context._cache_policy = staticmethod(lambda _key: False)

    # If running on a local dev server, allow bots to connect without prior
    # groups configuration. Useful when running smoke test.
    if utils.is_local_dev_server():
        acl.bootstrap_dev_server_acls()
        pools_config.bootstrap_dev_server_acls()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)

    endpoints_api = endpoints_webapp2.api_server([
        handlers_endpoints.SwarmingServerService,
        handlers_endpoints.SwarmingTaskService,
        handlers_endpoints.SwarmingTasksService,
        handlers_endpoints.SwarmingQueuesService,
        handlers_endpoints.SwarmingBotService,
        handlers_endpoints.SwarmingBotsService,
        # components.config endpoints for validation and configuring of luci-config
        # service URL.
        config.ConfigApi,
    ])

    prpc_api = webapp2.WSGIApplication(handlers_prpc.get_routes())

    # Local import, because it instantiates the mapreduce app.
    # This is for the Web UI.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

    event_mon_metrics.initialize()
    ts_mon_metrics.initialize()
    utils.report_memory(frontend_app)
    utils.report_memory(endpoints_api)
    utils.report_memory(prpc_api)
    return frontend_app, endpoints_api, prpc_api, main.APP
Esempio n. 15
0
def create_applications():
    ereporter2.register_formatter()

    # App that serves HTML pages and the main API.
    frontend = monitoring.wrap_webapp2_app(
        handlers_frontend.create_application(False))

    # App that serves endpoints APIs. Note: monitoring.wrap_webapp2_app doesn't
    # support Endpoints server. This is fine, we don't host any important APIs
    # there.
    api = endpoints.api_server([auth.AuthService, config.ConfigApi])

    return frontend, api
Esempio n. 16
0
def create_application():
  ereporter2.register_formatter()

  # App that serves HTML pages and old API.
  frontend = handlers_frontend.create_application(False)

  def is_enabled_callback():
    return config.settings().enable_ts_monitoring

  gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
  # App that serves new endpoints API.
  api = endpoints.api_server([handlers_endpoints_v1.IsolateService])
  return frontend, api
Esempio n. 17
0
def create_application():
    ereporter2.register_formatter()

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
    # App that serves new endpoints API.
    api = endpoints.api_server([handlers_endpoints_v1.IsolateService])
    return frontend, api
Esempio n. 18
0
    def setUp(self):
        """Creates a new app instance for every test case."""
        super(MainTest, self).setUp()
        self.testbed.init_user_stub()

        # When called during a taskqueue, the call to get_app_version() may fail so
        # pre-fetch it.
        version = utils.get_app_version()
        self.mock(utils, 'get_task_queue_host', lambda: version)
        self.source_ip = '192.168.0.1'
        self.app_frontend = webtest.TestApp(
            handlers_frontend.create_application(debug=True),
            extra_environ={'REMOTE_ADDR': self.source_ip})
        # This is awkward but both the frontend and backend applications uses the
        # same template variables.
        template.reset()
        self.app_backend = webtest.TestApp(
            handlers_backend.create_application(debug=True),
            extra_environ={'REMOTE_ADDR': self.source_ip})
        # Tasks are enqueued on the backend.
        self.app = self.app_backend

        self.auth_app = webtest.TestApp(
            auth.create_wsgi_application(debug=True),
            extra_environ={
                'REMOTE_ADDR': self.source_ip,
                'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
            })

        full_access_group = config.settings().auth.full_access_group
        readonly_access_group = config.settings().auth.readonly_access_group

        auth.bootstrap_group(
            auth.ADMIN_GROUP,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            readonly_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        auth.bootstrap_group(
            full_access_group,
            [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
        # TODO(maruel): Create a BOTS_GROUP.

        self.set_as_anonymous()
Esempio n. 19
0
def create_application():
    ereporter2.register_formatter()
    utils.set_task_queue_module('backend')
    template.bootstrap()

    # If running on a local dev server, allow bots to connect without prior
    # groups configuration. Useful when running smoke test.
    if utils.is_local_dev_server():
        acl.bootstrap_dev_server_acls()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)

    # App that contains crons and task queues.
    backend_app = handlers_backend.create_application(False)
    gae_ts_mon.initialize(backend_app, is_enabled_fn=is_enabled_callback)

    # Local import, because it instantiates the mapreduce app.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

    # TODO(maruel): Remove this once there is no known client anymore.
    api = webapp2.WSGIApplication(
        endpoints_webapp2.api_server(
            [
                handlers_endpoints.SwarmingServerService,
                handlers_endpoints.SwarmingTaskService,
                handlers_endpoints.SwarmingTasksService,
                handlers_endpoints.SwarmingQueuesService,
                handlers_endpoints.SwarmingBotService,
                handlers_endpoints.SwarmingBotsService,
                # components.config endpoints for validation and configuring of luci-config
                # service URL.
                config.ConfigApi,
            ],
            base_path='/_ah/api'))

    event_mon_metrics.initialize()
    ts_mon_metrics.initialize()
    return frontend_app, api, backend_app, main.APP
Esempio n. 20
0
def create_application():
    ereporter2.register_formatter()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)
    # Local import, because it instantiates the mapreduce app.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)
    api = endpoints.api_server([
        handlers_endpoints.swarming_api,
        # components.config endpoints for validation and configuring of luci-config
        # service URL.
        config.ConfigApi,
    ])
    ts_mon_metrics.initialize()
    return frontend_app, api, main.APP
Esempio n. 21
0
def create_application():
  ereporter2.register_formatter()

  def is_enabled_callback():
    return config.settings().enable_ts_monitoring

  # App that serves HTML pages and old API.
  frontend_app = handlers_frontend.create_application(False)
  gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)
  # Local import, because it instantiates the mapreduce app.
  from mapreduce import main
  gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)
  api = endpoints.api_server([
    handlers_endpoints.swarming_api,
    # components.config endpoints for validation and configuring of luci-config
    # service URL.
    config.ConfigApi,
  ])
  ts_mon_metrics.initialize()
  return frontend_app, api, main.APP
Esempio n. 22
0
  def setUp(self):
    """Creates a new app instance for every test case."""
    super(MainTest, self).setUp()
    self.testbed.init_user_stub()

    # When called during a taskqueue, the call to get_app_version() may fail so
    # pre-fetch it.
    version = utils.get_app_version()
    self.mock(utils, 'get_task_queue_host', lambda: version)
    self.source_ip = '192.168.0.1'
    self.app_frontend = webtest.TestApp(
        handlers_frontend.create_application(debug=True),
        extra_environ={'REMOTE_ADDR': self.source_ip})
    # This is awkward but both the frontend and backend applications uses the
    # same template variables.
    template.reset()
    self.app_backend = webtest.TestApp(
        handlers_backend.create_application(debug=True),
        extra_environ={'REMOTE_ADDR': self.source_ip})
    # Tasks are enqueued on the backend.
    self.app = self.app_backend

    self.auth_app = webtest.TestApp(
        auth.create_wsgi_application(debug=True),
        extra_environ={
          'REMOTE_ADDR': self.source_ip,
          'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
        })

    auth.bootstrap_group(
        auth.ADMIN_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.READONLY_ACCESS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    auth.bootstrap_group(
        acl.FULL_ACCESS_GROUP,
        [auth.Identity(auth.IDENTITY_USER, '*****@*****.**')])
    # TODO(maruel): Create a BOTS_GROUP.

    self.set_as_anonymous()
Esempio n. 23
0
def create_application():
    ereporter2.register_formatter()

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
    # App that serves new endpoints API.
    api = webapp2.WSGIApplication(
        endpoints_webapp2.api_server(
            [
                handlers_endpoints_v1.IsolateService,
                # components.config endpoints for validation and configuring of
                # luci-config service URL.
                config.ConfigApi,
            ],
            base_path='/_ah/api'))
    return frontend, api
Esempio n. 24
0
 def wsgi_app():
     return handlers_frontend.create_application(True)