예제 #1
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
예제 #2
0
 def setUp(self):
     super(PRPCTest, self).setUp()
     self.app = webtest.TestApp(
         webapp2.WSGIApplication(handlers_prpc.get_routes(), debug=True),
         extra_environ={'REMOTE_ADDR': '::ffff:127.0.0.1'},
     )
     self._headers = {
         'Content-Type': encoding.Encoding.JSON[1],
         'Accept': encoding.Encoding.JSON[1],
     }
     self.now = datetime.datetime(2010, 1, 2, 3, 4, 5, 6)
예제 #3
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
 def setUp(self):
   super(PRPCTest, self).setUp()
   # handlers_bot is necessary to run fake tasks.
   routes = handlers_prpc.get_routes() + handlers_bot.get_routes()
   self.app = webtest.TestApp(
       webapp2.WSGIApplication(routes, debug=True),
       extra_environ={
         'REMOTE_ADDR': self.source_ip,
         'SERVER_SOFTWARE': os.environ['SERVER_SOFTWARE'],
       },
   )
   self._headers = {
     'Content-Type': encoding.Encoding.JSON[1],
     'Accept': encoding.Encoding.JSON[1],
   }
   self._enqueue_task_orig = self.mock(
       utils, 'enqueue_task', self._enqueue_task)
   self.now = datetime.datetime(2010, 1, 2, 3, 4, 5)
   self.mock_now(self.now)
   self.mock_default_pool_acl([])