Example #1
0
  def test_proxy_updater(self):
    arg_sets = []
    for add_s_a in [True, False]:
      config, scope = build_proxy_configuration(include_route_server=True,
                                                include_stream_server=False,
                                                include_route_share_adjusters=add_s_a,
                                                include_stream_share_adjusters=False)
      arg_sets.append((config, scope, add_s_a))

    try:
      ProxyBackendProvider.register(TstProxyBackend)
      for config, scope, add_share_adjusters in arg_sets:
        config, scope = build_proxy_configuration(include_route_server=True,
                                                  include_stream_server=False,
                                                  include_route_share_adjusters=True,
                                                  include_stream_share_adjusters=False)
        now = datetime.now()

        proxy_updater = ProxyUpdater(backend=TstProxyBackend.NAME,
                                     config=config,
                                     update_period=0,
                                     max_update_frequency=0)
        # Newly initialized proxy updater should need to update
        self.assertTrue(proxy_updater._should_update(now))
        proxy_updater._try_update(now)
        self.assertFalse(proxy_updater._should_update(now))

        # Newly started proxy updater should need to update
        proxy_updater.start(weight_adjustment_delay_seconds=0)
        self.assertTrue(proxy_updater._should_update(now))
        proxy_updater._try_update(now)
        self.assertFalse(proxy_updater._should_update(now))

        # Proxy updater that has been signaled by a source should need to
        # update
        scope.route_source.add(SourceEndpoint('127.0.0.1', 8080))
        self.assertTrue(proxy_updater._should_update(now))
        proxy_updater._try_update(now)
        self.assertFalse(proxy_updater._should_update(now))

        if add_share_adjusters:
          # Proxy updater that has been signaled by a share_adjuster should
          # need to update
          scope.route_share_adjuster.set_share(.5)
          self.assertTrue(proxy_updater._should_update(now))
          proxy_updater._try_update(now)
          self.assertFalse(proxy_updater._should_update(now))
    finally:
      ProxyBackendProvider.unregister(TstProxyBackend)
Example #2
0
  def test_nginx_proxy_backend(self):
    config, scope = build_proxy_configuration(include_route_server=True,
                                              include_stream_server=False,
                                              include_route_share_adjusters=True,
                                              include_stream_share_adjusters=False)

    backend = NginxProxyBackend(configuration=config,
                                signal_update_fn=scope.signal_update_fn)
    self.tst_proxy_backend(backend, scope)
Example #3
0
    def test_nginx_proxy_backend(self):
        config, scope = build_proxy_configuration(
            include_route_server=True,
            include_stream_server=False,
            include_route_share_adjusters=True,
            include_stream_share_adjusters=False)

        backend = NginxProxyBackend(configuration=config,
                                    signal_update_fn=scope.signal_update_fn)
        self.tst_proxy_backend(backend, scope)
Example #4
0
  def test_nginx_proxy_backend(self):
    config, scope = build_proxy_configuration(add_share_adjusters=True)

    backend = NginxProxyBackend(configuration=config,
                                signal_update_fn=scope.signal_update_fn)
    self.tst_proxy_backend(backend, scope)