Beispiel #1
0
 def setUp(self, mocked):
     instance = mocked.return_value
     instance.create_container.return_value = {'Id': 'mocked'}
     instance.port.return_value = [{
         'HostIp': '127.0.0.1',
         'HostPort': 1234
     }]
     instance.containers.return_value = [{
         u'Command':
         u'/entrypoint.sh redis-server',
         u'Created':
         1443632967,
         u'Id':
         u'mocked',
         u'Image':
         u'redis',
         u'Labels': {},
         u'Names': [u'/livetest-redis-tLJpZ'],
         u'Ports': [{
             u'PrivatePort': 6379,
             u'Type': u'tcp'
         }],
         u'Status':
         u'Up About a minute'
     }]
     self.instance = instance
     self.builder = RedisDockerRunner(network_mode="host")
Beispiel #2
0
class TestRedisDockerRunner(unittest.TestCase):
    """
    Test the docker runner
    """
    @mock.patch('mc.builders.Client')
    def setUp(self, mocked):
        instance = mocked.return_value
        instance.create_container.return_value = {'Id': 'mocked'}
        instance.port.return_value = [{
            'HostIp': '127.0.0.1',
            'HostPort': 1234
        }]
        instance.containers.return_value = [{
            u'Command':
            u'/entrypoint.sh redis-server',
            u'Created':
            1443632967,
            u'Id':
            u'mocked',
            u'Image':
            u'redis',
            u'Labels': {},
            u'Names': [u'/livetest-redis-tLJpZ'],
            u'Ports': [{
                u'PrivatePort': 6379,
                u'Type': u'tcp'
            }],
            u'Status':
            u'Up About a minute'
        }]
        self.instance = instance
        self.builder = RedisDockerRunner(network_mode="host")

    @mock.patch('mc.builders.Redis')
    def test_ready(self, mocked):
        """
        Tests the health check of the service
        """

        instance = mocked.return_value

        # Fail then pass
        instance.client_list.side_effect = [redis.ConnectionError, None]

        self.assertFalse(self.builder.ready)
        self.assertTrue(self.builder.ready)

    def test_can_provision(self):
        """
        Tests that there is a method that allows provisioning
        """
        try:
            self.builder.provision(services=['adsaws'])
        except Exception as e:
            self.fail('Provisioning failed: {}'.format(e))
class TestRedisDockerRunner(unittest.TestCase):
    """
    Test the docker runner
    """

    @mock.patch('mc.builders.Client')
    def setUp(self, mocked):
        instance = mocked.return_value
        instance.create_container.return_value = {'Id': 'mocked'}
        instance.port.return_value = [{'HostIp': '127.0.0.1', 'HostPort': 1234}]
        instance.containers.return_value = [
            {
                u'Command': u'/entrypoint.sh redis-server',
                u'Created': 1443632967,
                u'Id': u'mocked',
                u'Image': u'redis',
                u'Labels': {},
                u'Names': [u'/livetest-redis-tLJpZ'],
                u'Ports': [{u'PrivatePort': 6379, u'Type': u'tcp'}],
                u'Status': u'Up About a minute'
            }
        ]
        self.instance = instance
        self.builder = RedisDockerRunner(network_mode="host")

    @mock.patch('mc.builders.Redis')
    def test_ready(self, mocked):
        """
        Tests the health check of the service
        """

        instance = mocked.return_value

        # Fail then pass
        instance.client_list.side_effect = [redis.ConnectionError, None]

        self.assertFalse(self.builder.ready)
        self.assertTrue(self.builder.ready)

    def test_can_provision(self):
        """
        Tests that there is a method that allows provisioning
        """
        try:
            self.builder.provision(services=['adsaws'])
        except Exception as e:
            self.fail('Provisioning failed: {}'.format(e))
Beispiel #4
0
class TestRedisDockerRunner(unittest.TestCase):
    """
    Test the docker runner for the Redis cache
    """
    def setUp(self):
        self.name = 'livetest-redis-{}'.format(gen_salt(5))
        self.builder = RedisDockerRunner(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 TestRedisDockerRunner(unittest.TestCase):
    """
    Test the docker runner for the Redis cache
    """

    def setUp(self):
        self.name = 'livetest-redis-{}'.format(gen_salt(5))
        self.builder = RedisDockerRunner(
            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)
 def setUp(self, mocked):
     instance = mocked.return_value
     instance.create_container.return_value = {'Id': 'mocked'}
     instance.port.return_value = [{'HostIp': '127.0.0.1', 'HostPort': 1234}]
     instance.containers.return_value = [
         {
             u'Command': u'/entrypoint.sh redis-server',
             u'Created': 1443632967,
             u'Id': u'mocked',
             u'Image': u'redis',
             u'Labels': {},
             u'Names': [u'/livetest-redis-tLJpZ'],
             u'Ports': [{u'PrivatePort': 6379, u'Type': u'tcp'}],
             u'Status': u'Up About a minute'
         }
     ]
     self.instance = instance
     self.builder = RedisDockerRunner(network_mode="host")
Beispiel #7
0
 def setUp(self):
     self.name = 'livetest-redis-{}'.format(gen_salt(5))
     self.builder = RedisDockerRunner(name=self.name, )
 def setUp(self):
     self.name = 'livetest-redis-{}'.format(gen_salt(5))
     self.builder = RedisDockerRunner(
         name=self.name,
     )