-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
234 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import asyncio | ||
import json | ||
import logging | ||
|
||
from websockets.asyncio.client import connect | ||
from websockets.exceptions import WebSocketException | ||
|
||
|
||
logging.basicConfig(level=logging.WARNING) | ||
|
||
SERVER = "ws://127.0.0.1:9001" | ||
|
||
|
||
async def get_case_count(): | ||
async with connect(f"{SERVER}/getCaseCount") as ws: | ||
return json.loads(await ws.recv()) | ||
|
||
|
||
async def run_case(case): | ||
async with connect( | ||
f"{SERVER}/runCase?case={case}", | ||
user_agent_header="websockets.asyncio", | ||
max_size=2**25, | ||
) as ws: | ||
async for msg in ws: | ||
await ws.send(msg) | ||
|
||
|
||
async def update_reports(): | ||
async with connect(f"{SERVER}/updateReports", open_timeout=60): | ||
pass | ||
|
||
|
||
async def main(): | ||
cases = await get_case_count() | ||
for case in range(1, cases + 1): | ||
print(f"Running test case {case:03d} / {cases}... ", end="\t") | ||
try: | ||
await run_case(case) | ||
except WebSocketException as exc: | ||
print(f"ERROR: {type(exc).__name__}: {exc}") | ||
except Exception as exc: | ||
print(f"FAIL: {type(exc).__name__}: {exc}") | ||
else: | ||
print("OK") | ||
print("Ran {cases} test cases") | ||
await update_reports() | ||
print("Updated reports") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import asyncio | ||
import logging | ||
|
||
from websockets.asyncio.server import serve | ||
|
||
|
||
logging.basicConfig(level=logging.WARNING) | ||
|
||
HOST, PORT = "0.0.0.0", 9002 | ||
|
||
|
||
async def echo(ws): | ||
async for msg in ws: | ||
await ws.send(msg) | ||
|
||
|
||
async def main(): | ||
async with serve( | ||
echo, | ||
HOST, | ||
PORT, | ||
server_header="websockets.sync", | ||
max_size=2**25, | ||
) as server: | ||
try: | ||
await server.serve_forever() | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
{ | ||
"servers": [{ | ||
"url": "ws://host.docker.internal:9002" | ||
}, { | ||
"url": "ws://host.docker.internal:9003" | ||
}], | ||
"outdir": "./reports/servers", | ||
"cases": ["*"], | ||
"exclude-cases": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
{ | ||
"url": "ws://localhost:9001", | ||
"outdir": "./reports/clients", | ||
"cases": ["*"], | ||
"exclude-cases": [] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import json | ||
import logging | ||
|
||
from websockets.exceptions import WebSocketException | ||
from websockets.sync.client import connect | ||
|
||
|
||
logging.basicConfig(level=logging.WARNING) | ||
|
||
SERVER = "ws://127.0.0.1:9001" | ||
|
||
|
||
def get_case_count(): | ||
with connect(f"{SERVER}/getCaseCount") as ws: | ||
return json.loads(ws.recv()) | ||
|
||
|
||
def run_case(case): | ||
with connect( | ||
f"{SERVER}/runCase?case={case}", | ||
user_agent_header="websockets.sync", | ||
max_size=2**25, | ||
) as ws: | ||
for msg in ws: | ||
ws.send(msg) | ||
|
||
|
||
def update_reports(): | ||
with connect(f"{SERVER}/updateReports", open_timeout=60): | ||
pass | ||
|
||
|
||
def main(): | ||
cases = get_case_count() | ||
for case in range(1, cases + 1): | ||
print(f"Running test case {case:03d} / {cases}... ", end="\t") | ||
try: | ||
run_case(case) | ||
except WebSocketException as exc: | ||
print(f"ERROR: {type(exc).__name__}: {exc}") | ||
except Exception as exc: | ||
print(f"FAIL: {type(exc).__name__}: {exc}") | ||
else: | ||
print("OK") | ||
print("Ran {cases} test cases") | ||
update_reports() | ||
print("Updated reports") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import logging | ||
|
||
from websockets.sync.server import serve | ||
|
||
|
||
logging.basicConfig(level=logging.WARNING) | ||
|
||
HOST, PORT = "0.0.0.0", 9003 | ||
|
||
|
||
def echo(ws): | ||
for msg in ws: | ||
ws.send(msg) | ||
|
||
|
||
def main(): | ||
with serve( | ||
echo, | ||
HOST, | ||
PORT, | ||
server_header="websockets.asyncio", | ||
max_size=2**25, | ||
) as server: | ||
try: | ||
server.serve_forever() | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.