Beispiel #1
0
    def test_base(self):
        service = Service(name='test service')
        service.flush_nginx_config()

        config_file = service.get_nginx_config_path()
        self.assertNotEqual(service.read_nginx_config_file().find('server 127.0.0.1:6666'), -1,
                            'config written and has backup 503')
        self.assertTrue(service.validate(), 'nginx config is valid')
        service.delete()

        with self.assertRaises(IOError):
            open(config_file, 'r')
Beispiel #2
0
    def test_port_allocate(self):
        service = Service(name='test service')

        service.check_port()
        self.assertEqual(service.port, 7000)
        consul_port_data = consul.kv.get('vergilius/ports/test service')
        self.assertIsNotNone(consul_port_data)
        self.assertEqual('7000', consul_port_data[1][u'Value'])

        service.delete()
        self.assertFalse(7000 in port_allocator.allocated)
        consul_port_data = consul.kv.get('vergilius/ports/test service')
        self.assertIsNotNone(consul_port_data)
Beispiel #3
0
    def test_base(self):
        service = Service(name='test service')
        service.flush_nginx_config()

        config_file = service.get_nginx_config_path('upstream')
        self.assertNotEqual(
            service.read_nginx_config_file('upstream').find(
                'server 127.0.0.1:6666'), -1,
            'config written and has backup 503')
        self.assertTrue(service.validate(), 'nginx config is valid')
        service.delete()

        with self.assertRaises(IOError):
            open(config_file, 'r')