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_createSimulator(self): """ L{LoadSimulator.createSimulator} creates a L{CalendarClientSimulator} with its own reactor and host and port information from the configuration file. """ servers = { "PodA": { "enabled": True, "uri": 'http://example.org:1234/', "stats": { "enabled": False }, }, } reactor = object() sim = LoadSimulator(servers, None, None, None, None, None, None, reactor=reactor) calsim = sim.createSimulator() self.assertIsInstance(calsim, CalendarClientSimulator) self.assertIsInstance(calsim.reactor, LagTrackingReactor) self.assertIdentical(calsim.reactor._reactor, reactor) self.assertEquals(calsim.servers, servers)
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_createSimulator(self): """ L{LoadSimulator.createSimulator} creates a L{CalendarClientSimulator} with its own reactor and host and port information from the configuration file. """ server = 'http://127.0.0.7:1243/' reactor = object() sim = LoadSimulator(server, None, None, None, None, None, None, reactor=reactor) calsim = sim.createSimulator() self.assertIsInstance(calsim, CalendarClientSimulator) self.assertIsInstance(calsim.reactor, LagTrackingReactor) self.assertIdentical(calsim.reactor._reactor, reactor) self.assertEquals(calsim.server, server)