Skip to content

Commit 65af895

Browse files
committed
feat: rewrite controlplane integration tests with pytest
1 parent 2afa155 commit 65af895

4 files changed

Lines changed: 86 additions & 363 deletions

File tree

.github/workflows/integration-testing.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
ignore: ""
120120
# TODO: expand to full tests_integ/memory once test stability is addressed
121121
- group: memory
122-
path: tests_integ/memory/test_memory_client.py
122+
path: tests_integ/memory/test_controlplane.py tests_integ/memory/test_memory_client.py
123123
timeout: 10
124124
extra-deps: ""
125125
ignore: ""
@@ -151,7 +151,7 @@ jobs:
151151
- name: Install dependencies
152152
run: |
153153
pip install -e .
154-
pip install --no-cache-dir pytest requests strands-agents uvicorn httpx starlette websockets ${{ matrix.extra-deps }}
154+
pip install --no-cache-dir pytest pytest-xdist pytest-order requests strands-agents uvicorn httpx starlette websockets ${{ matrix.extra-deps }}
155155
156156
- name: Run integration tests
157157
env:
@@ -162,7 +162,7 @@ jobs:
162162
id: tests
163163
timeout-minutes: ${{ matrix.timeout }}
164164
run: |
165-
pytest ${{ matrix.path }} ${{ matrix.ignore }} -s --log-cli-level=INFO
165+
pytest ${{ matrix.path }} ${{ matrix.ignore }} -n auto --dist=loadscope -s --log-cli-level=INFO
166166
167167
safety-gate:
168168
runs-on: ubuntu-latest

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ dev = [
144144
"pytest>=8.4.1",
145145
"pytest-asyncio>=0.24.0",
146146
"pytest-cov>=6.0.0",
147+
"pytest-order>=1.3.0",
147148
"ruff>=0.12.0",
148149
"websockets>=14.1",
149150
"wheel>=0.45.1",

tests_integ/memory/helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import time
2+
3+
import pytest
4+
5+
6+
def poll_until(fn, predicate, max_wait=180, poll_interval=10, fail_if=None):
7+
"""Poll fn() until predicate(result) is True or max_wait exceeded."""
8+
deadline = time.time() + max_wait
9+
while time.time() < deadline:
10+
result = fn()
11+
if fail_if and fail_if(result):
12+
pytest.fail(f"poll_until hit terminal state: {result}")
13+
if predicate(result):
14+
return result
15+
time.sleep(poll_interval)
16+
pytest.fail(f"poll_until timed out after {max_wait}s")

0 commit comments

Comments
 (0)