Exemplo n.º 1
0
    def test_batch_size(self):
        def assert_batch(instances, batch_size):
            self.group.instances.count.return_value = instances
            self.assertEquals(self.group.batch_size, batch_size)

        with patch_settings('STRETCH_BATCH_SIZE', 5):
            assert_batch(1, 1)
            assert_batch(2, 1)
            assert_batch(3, 2)
            assert_batch(4, 2)
            assert_batch(5, 3)
            assert_batch(20, 5)
Exemplo n.º 2
0
def test_node_get_image():
    node = Node(name='node')
    node.system = Mock()
    node.system.pk = 1

    eq_(node.get_image(local=True), 'stretch_agent/sys1/node')

    location = UrlLocation('public_url', private='private_url')

    with patch_settings('STRETCH_REGISTRY', location):
        eq_(node.get_image(local=False, private=True), 'private_url/sys1/node')
        eq_(node.get_image(local=False, private=False), 'public_url/sys1/node')
Exemplo n.º 3
0
    def test_batch_size(self):
        def assert_batch(instances, batch_size):
            self.group.instances.count.return_value = instances
            self.assertEquals(self.group.batch_size, batch_size)

        with patch_settings("STRETCH_BATCH_SIZE", 5):
            assert_batch(1, 1)
            assert_batch(2, 1)
            assert_batch(3, 2)
            assert_batch(4, 2)
            assert_batch(5, 3)
            assert_batch(20, 5)
Exemplo n.º 4
0
    def setUp(self):
        patcher = patch('stretch.agent.client.requests')
        self.requests = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = patch_settings('STRETCH_AGENT_CERT', '/cert.pem')
        patcher.start()
        self.addCleanup(patcher.stop)

        self.host = mock_attr(address='127.0.0.1')
        self.host.environment = mock_attr(name='env', pk=2)
        self.host.environment.app_paths = {'node': '/path'}
        self.client = AgentClient(self.host)
Exemplo n.º 5
0
    def setUp(self):
        patcher = patch("stretch.agent.client.requests")
        self.requests = patcher.start()
        self.addCleanup(patcher.stop)

        patcher = patch_settings("STRETCH_AGENT_CERT", "/cert.pem")
        patcher.start()
        self.addCleanup(patcher.stop)

        self.host = mock_attr(address="127.0.0.1")
        self.host.environment = mock_attr(name="env", pk=2)
        self.host.environment.app_paths = {"node": "/path"}
        self.client = AgentClient(self.host)