misc: minor refactor, add simple network perf test deploy

This commit is contained in:
gmega 2025-04-16 12:56:34 -03:00
parent e5fa036e98
commit 67ca362ee7
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
2 changed files with 64 additions and 6 deletions

View File

@ -16,7 +16,9 @@ async def test_should_upload_file(codex_node_1_url: str):
data = BytesIO()
random_data(megabytes(1), data)
cid = client.upload("test.txt", "application/octet-stream", data)
cid = client.upload(
"test.txt", "application/octet-stream", BytesIO(data.getvalue())
)
assert cid is not None
@ -25,14 +27,15 @@ async def test_should_upload_file(codex_node_1_url: str):
async def test_should_download_file(codex_node_1_url: str):
client = AsyncCodexClientImpl(parse_url(codex_node_1_url))
buff = BytesIO()
random_data(megabytes(1), buff)
data = buff.getvalue()
data = BytesIO()
random_data(megabytes(1), data)
cid = await client.upload("test.txt", "application/octet-stream", BytesIO(data))
cid = await client.upload(
"test.txt", "application/octet-stream", BytesIO(data.getvalue())
)
assert cid is not None
async with client.download(cid) as content:
downloaded = await content.readexactly(megabytes(1))
assert downloaded == data
assert downloaded == data.getvalue()

View File

@ -0,0 +1,55 @@
# Ad hoc deployment for measuring network performance semi-manually. You'll have to log
# into the iperf3-client pod, fire the test, and look at the results.
apiVersion: v1
kind: Pod
metadata:
name: iperf3-server
namespace: codex-benchmarks
labels:
app: iperf-server
spec:
nodeSelector:
workload-type: "benchmarks"
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- iperf-client
topologyKey: "kubernetes.io/hostname"
containers:
- name: iperf3
image: networkstatic/iperf3
command: ["iperf3", "-s"]
ports:
- containerPort: 5201
restartPolicy: Never
---
apiVersion: v1
kind: Pod
metadata:
name: iperf3-client
namespace: codex-benchmarks
labels:
app: iperf-client
spec:
nodeSelector:
workload-type: "benchmarks"
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- iperf-server
topologyKey: "kubernetes.io/hostname"
containers:
- name: iperf3
image: networkstatic/iperf3
command: ["sleep", "50000"]
restartPolicy: Never