From 67ca362ee792f4ca07fd9b94fdf8a621091adc68 Mon Sep 17 00:00:00 2001 From: gmega Date: Wed, 16 Apr 2025 12:56:34 -0300 Subject: [PATCH] misc: minor refactor, add simple network perf test deploy --- .../codex/client/tests/test_async_client.py | 15 +++-- k8s/clusters/devnet/perf-measurements.yaml | 55 +++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/benchmarks/codex/client/tests/test_async_client.py b/benchmarks/codex/client/tests/test_async_client.py index 76f23bb..7ea83ad 100644 --- a/benchmarks/codex/client/tests/test_async_client.py +++ b/benchmarks/codex/client/tests/test_async_client.py @@ -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() diff --git a/k8s/clusters/devnet/perf-measurements.yaml b/k8s/clusters/devnet/perf-measurements.yaml index e69de29..f2e4986 100644 --- a/k8s/clusters/devnet/perf-measurements.yaml +++ b/k8s/clusters/devnet/perf-measurements.yaml @@ -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