def test_createArrivalPolicy(self): """ L{LoadSimulator.createArrivalPolicy} creates an arrival policy based on the L{Arrival} passed to its initializer. """ class FakeArrival(object): def __init__(self, reactor, x, y): self.reactor = reactor self.x = x self.y = y reactor = object() sim = LoadSimulator(None, None, None, None, Arrival(FakeArrival, { 'x': 3, 'y': 2 }), None, reactor=reactor) arrival = sim.createArrivalPolicy() self.assertIsInstance(arrival, FakeArrival) self.assertIdentical(arrival.reactor, sim.reactor) self.assertEquals(arrival.x, 3) self.assertEquals(arrival.y, 2)
def test_observeRunReport(self): """ Each log observer is added to the log publisher before the simulation run is started and has its C{report} method called after the simulation run completes. """ observers = [Observer()] sim = LoadSimulator( { "PodA": { "enabled": True, "uri": 'http://example.org:1234/', "stats": { "enabled": False }, }, }, "/principals/users/%s/", None, None, Arrival(lambda reactor: NullArrival(), {}), None, observers, reactor=Reactor()) io = StringIO() sim.run(io) self.assertEquals(io.getvalue(), "\n*** PASS\n") self.assertTrue(observers[0].reported) self.assertEquals([e for e in observers[0].events if "thingo" in e][0]["thingo"], Reactor.message)
def test_loadArrivalConfig(self): """ The arrival policy type and arguments are loaded from the [arrival] section of the configuration file specified. """ config = FilePath(self.mktemp()) config.setContent( writePlistToString({ "arrival": { "factory": "contrib.performance.loadtest.population.SmoothRampUp", "params": { "groups": 10, "groupSize": 1, "interval": 3, }, }, })) sim = LoadSimulator.fromCommandLine(['--config', config.path]) self.assertEquals( sim.arrival, Arrival(SmoothRampUp, dict(groups=10, groupSize=1, interval=3)))