Example #1
0
def multi_host_stress_test(stress=5, messages=1000, ports=[8080, 8081, 8082]):
    hosts = []
    for port in ports:
        hosts.append(host(timeout=TIMEOUT, port=port).start())
    clients = []
    for i in range(stress):
        for port in ports:
            c = client(timeout=TIMEOUT, port=port).start()
            c.write("connected", True)
            clients.append(c)
    report("All sockets connected")
    s()
    for i in range(messages):
        for c in clients:
            c.write("Test{}".format(i), text)
        for h in hosts:
            h.write_ALL("Test{}".format(i), text)
    report("All data written")
    s()
    for i in range(messages):
        for h in hosts:
            assert (h.get_ALL("Test{}".format(i)) == [text] * stress)
    for i in range(messages):
        for c in clients:
            assert (c.get("Test{}".format(i)) == text)
    report("All data asserted")
    for c in clients:
        c.close()
    for h in hosts:
        h.close()
Example #2
0
def stress_test(stress=5, messages=1000):
    h = host(timeout=TIMEOUT)
    h.start()
    clients = []
    for i in range(stress):
        c = client(timeout=TIMEOUT).start()
        c.write("connected", True)
        clients.append(c)
    report("All sockets connected")
    s()
    for i in range(messages):
        for c in clients:
            c.write("Test{}".format(i), text)
        h.write_ALL("Test{}".format(i), text)
    report("All data written")
    s()
    for i in range(messages):
        assert (h.get_ALL("Test{}".format(i)) == [text] * stress)
    for i in range(messages):
        for c in clients:
            assert (c.get("Test{}".format(i)) == text)
    report("All data asserted")
    for c in clients:
        c.close()
    h.close()
Example #3
0
def initialize():
    h = host(timeout=TIMEOUT)
    c = client(timeout=TIMEOUT)
    report("Sockets initialized")
    h.start()
    c.start()
    report("Sockets started")
    return h, c
def test_connection_BOTH():
    start = time.time()
    h = host(timeout=TIMEOUT)
    h.start()
    c = client(timeout=TIMEOUT)
    c.start()
    report("Sockets opened and started")
    assert h.opened
    assert c.opened
    s(TIMEOUT)
    assert len(h.getClients()) is 1
    report("Open state verified")
    c.close()
    assert not c.opened and c.stopped
    h.close()
    report("Closed state verified")
    assert not h.opened and h.stopped
    success("Connection test Passed ({:.5f} sec)".format(time.time() - start))
Example #5
0
def test_async_ordering():
    start = time.time()
    h = host(timeout=TIMEOUT, open=False)
    c = client(timeout=TIMEOUT, open=False)
    assert (not h.opened)
    h.open()
    h.start()
    assert (h.opened)
    report("Host started")
    c.open()
    c.start()
    assert (c.opened)
    report("Client started")
    h.close()
    assert (h.stopped)
    report("Host closed")
    c.close()
    assert (c.stopped)
    report("Client closed")
    success("Async Ordering test Passed ({:.5f} sec)".format(time.time() -
                                                             start))
Example #6
0
 def start(self):
     self.startTime = time.time()
     self.socket = client(self.address, self.port).start()
     self.socket.write("connected", True)
     Thread(target=self._update, args=()).start()
     return self
Example #7
0
    c = client(timeout=TIMEOUT)
    report("Sockets initialized")
    h.start()
    c.start()
    report("Sockets started")
    return h, c


text = "Consulted he eagerness unfeeling deficient existence of. Calling nothing end fertile for venture way boy. Esteem spirit temper too say adieus who direct esteem. It esteems luckily mr or picture placing drawing no. Apartments frequently or motionless on reasonable projecting expression. Way mrs end gave tall walk fact bed. \
Left till here away at to whom past. Feelings laughing at no wondered repeated provided finished. It acceptance thoroughly my advantages everything as. Are projecting inquietude affronting preference saw who. Marry of am do avoid ample as. Old disposal followed she ignorant desirous two has. Called played entire roused though for one too. He into walk roof made tall cold he. Feelings way likewise addition wandered contempt bed indulged. \
Same an quit most an. Admitting an mr disposing sportsmen. Tried on cause no spoil arise plate. Longer ladies valley get esteem use led six. Middletons resolution advantages expression themselves partiality so me at. West none hope if sing oh sent tell is. \
Death weeks early had their and folly timed put. Hearted forbade on an village ye in fifteen. Age attended betrayed her man raptures laughter. Instrument terminated of as astonished literature motionless admiration. The affection are determine how performed intention discourse but. On merits on so valley indeed assure of. Has add particular boisterous uncommonly are. Early wrong as so manor match. Him necessary shameless discovery consulted one but. \
Yet remarkably appearance get him his projection. Diverted endeavor bed peculiar men the not desirous. Acuteness abilities ask can offending furnished fulfilled sex. Warrant fifteen exposed ye at mistake. Blush since so in noisy still built up an again. As young ye hopes no he place means. Partiality diminution gay yet entreaties admiration. In mr it he mention perhaps attempt pointed suppose. Unknown ye chamber of warrant of norland arrived. \
Luckily friends do ashamed to do suppose. Tried meant mr smile so. Exquisite behaviour as to middleton perfectly. Chicken no wishing waiting am. Say concerns dwelling graceful six humoured. Whether mr up savings talking an. Active mutual nor father mother exeter change six did all. "

RUNS = 10

for i in range(10):
    c = client(addr="127.0.0.1", port=8080)
    c.start()
    c.write("test", text)
    c.close()

print("Wrote test")
c = client(addr="127.0.0.1", port=8080)
c.start()
c.write("verify", RUNS)
print("Wrote verify")

c.close()
Example #8
0
    h = host(timeout=TIMEOUT)
    c = client(timeout=TIMEOUT)
    report("Sockets initialized")
    h.start()
    c.start()
    report("Sockets started")
    return h, c


text = "Consulted he eagerness unfeeling deficient existence of. Calling nothing end fertile for venture way boy. Esteem spirit temper too say adieus who direct esteem. It esteems luckily mr or picture placing drawing no. Apartments frequently or motionless on reasonable projecting expression. Way mrs end gave tall walk fact bed. \
Left till here away at to whom past. Feelings laughing at no wondered repeated provided finished. It acceptance thoroughly my advantages everything as. Are projecting inquietude affronting preference saw who. Marry of am do avoid ample as. Old disposal followed she ignorant desirous two has. Called played entire roused though for one too. He into walk roof made tall cold he. Feelings way likewise addition wandered contempt bed indulged. \
Same an quit most an. Admitting an mr disposing sportsmen. Tried on cause no spoil arise plate. Longer ladies valley get esteem use led six. Middletons resolution advantages expression themselves partiality so me at. West none hope if sing oh sent tell is. \
Death weeks early had their and folly timed put. Hearted forbade on an village ye in fifteen. Age attended betrayed her man raptures laughter. Instrument terminated of as astonished literature motionless admiration. The affection are determine how performed intention discourse but. On merits on so valley indeed assure of. Has add particular boisterous uncommonly are. Early wrong as so manor match. Him necessary shameless discovery consulted one but. \
Yet remarkably appearance get him his projection. Diverted endeavor bed peculiar men the not desirous. Acuteness abilities ask can offending furnished fulfilled sex. Warrant fifteen exposed ye at mistake. Blush since so in noisy still built up an again. As young ye hopes no he place means. Partiality diminution gay yet entreaties admiration. In mr it he mention perhaps attempt pointed suppose. Unknown ye chamber of warrant of norland arrived. \
Luckily friends do ashamed to do suppose. Tried meant mr smile so. Exquisite behaviour as to middleton perfectly. Chicken no wishing waiting am. Say concerns dwelling graceful six humoured. Whether mr up savings talking an. Active mutual nor father mother exeter change six did all. "

RUNS = 10

for i in range(10):
    c = client(addr='127.0.0.1', port=8080)
    c.start()
    c.write("test", text)
    c.close()

print("Wrote test")
c = client(addr='127.0.0.1', port=8080)
c.start()
c.write("verify", RUNS)
print("Wrote verify")

c.close()