Exemplo n.º 1
0
class TestConsulDockerRunner(unittest.TestCase):
    """
    Test the docker runner for the Consul service
    """
    def setUp(self):
        self.name = 'livetest-consul-{}'.format(gen_salt(5))
        self.builder = ConsulDockerRunner(name=self.name, )

    def tearDown(self):
        """
        teardown the containers
        """
        try:
            self.builder.teardown()
        except:
            pass

    def test_is_ready(self):
        """
        Check if the instance is ready
        """

        self.builder.start()
        while not self.builder.ready:
            time.sleep(1)
        self.assertTrue(self.builder.running)
        self.assertTrue(self.builder.ready)

        self.builder.teardown()
        self.assertFalse(self.builder.ready)
        self.assertFalse(self.builder.running)
Exemplo n.º 2
0
class TestConsulDockerRunner(unittest.TestCase):
    """
    Test the docker runner for the Consul service
    """

    def setUp(self):
        self.name = 'livetest-consul-{}'.format(gen_salt(5))
        self.builder = ConsulDockerRunner(
            name=self.name,
        )

    def tearDown(self):
        """
        teardown the containers
        """
        try:
            self.builder.teardown()
        except:
            pass

    def test_is_ready(self):
        """
        Check if the instance is ready
        """

        self.builder.start()
        while not self.builder.ready:
            time.sleep(1)
        self.assertTrue(self.builder.running)
        self.assertTrue(self.builder.ready)

        self.builder.teardown()
        self.assertFalse(self.builder.ready)
        self.assertFalse(self.builder.running)
class TestConsulProvisioner(unittest.TestCase):
    """
    Test the ConsulProvisioner. Use the Docker builder to create the key/value
    store
    """

    def setUp(self):
        """
        Starts a consul node for all the tests
        """
        self.name = 'livetest-consul-{}'.format(gen_salt(5))
        self.builder = ConsulDockerRunner(
            name=self.name,
        )

        self.builder.start()
        self.port = self.builder.client.port(
            self.builder.container['Id'],
            8500
        )[0]['HostPort']

    def tearDown(self):
        """
        Tears down the consul node used by the tests
        """
        self.builder.teardown()

    def test_running_consul(self):
        """
        Checks that consul is started correctly via docker
        """

        while True:
            response = requests.get('http://*****:*****@localhost:5432/adsws"',
            msg='Provisioning is not working: {} != '
                'postgresql+psycopg2://postgres:@localhost:5432/adsws'.format(db_uri)
        )