def test_read_request_load_start_stop_start_succeeds(self, _logger): """ ``read_request_load_scenario`` starts, stops and starts without collapsing. """ c = Clock() node1 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.1')) node2 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.2')) cluster = BenchmarkCluster( node1.public_address, lambda reactor: FakeFlockerClient([node1, node2]), {node1.public_address, node2.public_address}, default_volume_size=DEFAULT_VOLUME_SIZE) sample_size = 5 s = read_request_load_scenario(c, cluster, sample_size=sample_size) # Start and stop s.start() c.pump(repeat(1, sample_size)) s.stop() # Start again and verify the scenario succeeds d = s.start() c.pump(repeat(1, sample_size)) s.maintained().addBoth(lambda x: self.fail()) d.addCallback(lambda ignored: s.stop()) c.pump(repeat(1, sample_size)) self.successResultOf(d)
def test_read_request_load_succeeds(self, _logger): """ ``read_request_load_scenario`` starts and stops without collapsing. """ c = Clock() node1 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.1')) node2 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.2')) cluster = BenchmarkCluster( node1.public_address, lambda reactor: FakeFlockerClient([node1, node2]), {node1.public_address, node2.public_address}, default_volume_size=DEFAULT_VOLUME_SIZE) sample_size = 5 s = read_request_load_scenario(c, cluster, sample_size=sample_size) d = s.start() # Request rate samples are recorded every second and we need to # collect enough samples to establish the rate which is defined # by `sample_size`. Therefore, advance the clock by # `sample_size` seconds to obtain enough samples. c.pump(repeat(1, sample_size)) s.maintained().addBoth(lambda x: self.fail()) d.addCallback(lambda ignored: s.stop()) c.pump(repeat(1, sample_size)) self.successResultOf(d)
def make_cluster(self, make_flocker_client): """ Create a cluster that can be used by the scenario tests. """ node1 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.1')) node2 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.2')) return BenchmarkCluster( node1.public_address, lambda reactor: make_flocker_client( FakeFlockerClient([node1, node2]), reactor), {node1.public_address, node2.public_address}, default_volume_size=DEFAULT_VOLUME_SIZE, )
def test_scenario_throws_exception_when_already_started(self, _logger): """ start method in the ``RequestLoadScenario`` throws a ``RequestScenarioAlreadyStarted`` if the scenario is already started. """ c = Clock() node1 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.1')) node2 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.2')) cluster = BenchmarkCluster( node1.public_address, lambda reactor: FakeFlockerClient([node1, node2]), {node1.public_address, node2.public_address}, default_volume_size=DEFAULT_VOLUME_SIZE) sample_size = 5 s = read_request_load_scenario(c, cluster, sample_size=sample_size) s.start() self.assertRaises(RequestScenarioAlreadyStarted, s.start)
def setUp(self): super(WriteRequestLoadScenarioTest, self).setUp() self.node1 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.1')) self.node2 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.2'))
def setUp(self): super(write_request_load_scenarioTest, self).setUp() self.node1 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.1')) self.node2 = Node(uuid=uuid4(), public_address=IPAddress('10.0.0.2'))