def test_create_dataset(self, logger): """ CreateDataset probe waits for cluster to converge. """ clock = Clock() node_id = uuid4() node = Node(uuid=node_id, public_address=IPAddress('10.0.0.1')) control_service = FakeFlockerClient([node], node_id) cluster = BenchmarkCluster( IPAddress('10.0.0.1'), lambda reactor: control_service, {}, None, ) operation = CreateDataset(clock, cluster) d = operation.get_probe() def run_probe(probe): def cleanup(result): cleaned_up = probe.cleanup() cleaned_up.addCallback(lambda _ignored: result) return cleaned_up d = probe.run() d.addCallback(cleanup) return d d.addCallback(run_probe) # Advance the clock because probe periodically polls the state. # The Deferred does not fire before the dataset has been created. clock.advance(1) self.assertNoResult(d) # Trigger convergence of the fake Flocker cluster. control_service.synchronize_state() # The Deferred fires once the dataset has been created. clock.advance(1) self.successResultOf(d)
def test_create_dataset(self, logger): """ CreateDataset probe waits for cluster to converge. """ clock = Clock() node_id = uuid4() node = Node(uuid=node_id, public_address=IPAddress("10.0.0.1")) control_service = FakeFlockerClient([node], node_id) cluster = BenchmarkCluster(IPAddress("10.0.0.1"), lambda reactor: control_service, {}, None) operation = CreateDataset(clock, cluster) d = operation.get_probe() def run_probe(probe): def cleanup(result): cleaned_up = probe.cleanup() cleaned_up.addCallback(lambda _ignored: result) return cleaned_up d = probe.run() d.addCallback(cleanup) return d d.addCallback(run_probe) # Advance the clock because probe periodically polls the state. # The Deferred does not fire before the dataset has been created. clock.advance(1) self.assertNoResult(d) # Trigger convergence of the fake Flocker cluster. control_service.synchronize_state() # The Deferred fires once the dataset has been created. clock.advance(1) self.successResultOf(d)
def test_run_probe_timeout(self): """ CreateContainer probe times-out if probe.run runs too long. """ clock = Clock() node_id = uuid4() node = Node(uuid=node_id, public_address=IPAddress('10.0.0.1')) control_service = FakeFlockerClient([node], node_id) cluster = BenchmarkCluster( IPAddress('10.0.0.1'), lambda reactor: control_service, {}, None, ) operation = CreateContainer(clock, cluster) d = operation.get_probe() control_service.synchronize_state() # creation of pull container clock.advance(1) control_service.synchronize_state() # deletion of pull container clock.advance(1) # get_probe has completed successfully probe = self.successResultOf(d) d = probe.run() clock.advance(DEFAULT_TIMEOUT.total_seconds()) # No control_service.synchronize_state() call, so cluster state # never shows container is created. # The Deferred fails if container not created within 10 minutes. self.failureResultOf(d)
def test_create_container(self, _logger): """ CreateContainer probe waits for cluster to converge. """ clock = Clock() node_id = uuid4() node = Node(uuid=node_id, public_address=IPAddress('10.0.0.1')) control_service = FakeFlockerClient([node], node_id) cluster = BenchmarkCluster( IPAddress('10.0.0.1'), lambda reactor: control_service, {}, None, ) operation = CreateContainer(clock, cluster) d = operation.get_probe() def run_probe(probe): def cleanup(result): cleaned_up = probe.cleanup() cleaned_up.addCallback(lambda _ignored: result) return cleaned_up d = probe.run() d.addCallback(cleanup) return d d.addCallback(run_probe) # Advance the clock because probe periodically polls the state. # Due to multiple steps, need to synchronize state a few times. control_service.synchronize_state() # creation of pull container clock.advance(1) control_service.synchronize_state() # deletion of pull container clock.advance(1) # The Deferred does not fire before the container has been created. self.assertNoResult(d) control_service.synchronize_state() # creation of test container clock.advance(1) # The Deferred fires once the container has been created. self.successResultOf(d)