Пример #1
0
    def test_loadbalancing_update_all_weight(self):
        post1_response = self.client.post(
            '/v1/registration/myservice',
            data=self._generate_registration_data('10.10.10.10', lb_weight=10),
            environ_base={
                'REMOTE_ADDR': '127.0.0.1',
                'X-FORWARDED-FOR': '192.168.216.186'
            })
        self.assertEquals(200, post1_response.status_code)
        post2_response = self.client.post(
            '/v1/registration/myservice',
            data=self._generate_registration_data('10.10.10.11', lb_weight=10),
            environ_base={
                'REMOTE_ADDR': '127.0.0.1',
                'X-FORWARDED-FOR': '192.168.216.186'
            })
        self.assertEquals(200, post2_response.status_code)

        loadbalancing_response = self.client.post(
            '/v1/loadbalancing/myservice',
            data={'load_balancing_weight': '50'})
        self.assertEquals(204, loadbalancing_response.status_code)

        hosts = list(Host.scan())
        self.assertEquals(2, len(hosts))
        for host in hosts:
            self.assertEquals(50, host.tags['load_balancing_weight'])
Пример #2
0
 def test_post_auto_ip_one_hop(self):
     response = self.client.post(
         '/v1/registration/myservice',
         data={
             'auto_ip': True,
             'service_repo_name': 'bar',
             'port': 1000,
             'revision': 'bjkc7y8cebyyuide2uincbyu',
             'tags': '{"az":"foo", "instance_id":"bar", "region":"baz"}',
         },
         environ_base={
             'REMOTE_ADDR': '127.0.0.1',
             'HTTP_X_FORWARDED_FOR': '192.168.216.186'
         })
     self.assertEquals(200, response.status_code)
     hosts = list(Host.scan())
     self.assertEquals(1, len(hosts))
     self.assertEquals('192.168.216.186', hosts[0].ip_address)
Пример #3
0
 def setUp(self):
     self.debug = app.app.debug
     app.app.debug = True
     self.client = app.app.test_client()
     for item in Host.scan():
         item.delete()
Пример #4
0
 def assert_one_host_with_load_balancing_weight(self, weight):
     hosts = list(Host.scan())
     self.assertEquals(1, len(hosts))
     self.assertEquals(weight, hosts[0].tags['load_balancing_weight'])
Пример #5
0
def clear():
    for item in Host.scan():
        item.delete()