Skip to content

Commit 16244f5

Browse files
committed
feat: add data plane, extraction, and lifecycle integ tests to TestMemoryClient
1 parent 11e2ac5 commit 16244f5

4 files changed

Lines changed: 362 additions & 27 deletions

File tree

TESTING.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,49 @@ uv run pytest tests_integ/runtime -xvs --log-cli-level=INFO
1818
## Memory
1919

2020
```bash
21+
# Required env vars for all memory tests
22+
export MEMORY_KINESIS_ARN=<Kinesis Data Stream ARN>
23+
export MEMORY_ROLE_ARN=<IAM role ARN trusted by bedrock-agentcore.amazonaws.com with kinesis:PutRecord/PutRecords permissions>
24+
export MEMORY_PREPOPULATED_ID=<ID of a memory with pre-extracted data for retrieval tests>
25+
2126
# Control plane (CRUD on memories/strategies, 5-10 min due to provisioning)
2227
uv run pytest tests_integ/memory/test_controlplane.py -xvs -k "integration"
2328

24-
# Stream delivery (requires env vars below, fails if unset)
25-
export MEMORY_KINESIS_ARN=<Kinesis Data Stream ARN>
26-
export MEMORY_ROLE_ARN=<IAM role ARN trusted by bedrock-agentcore.amazonaws.com with kinesis:PutRecord/PutRecords permissions>
29+
# Client (data plane, retrieval, stream delivery, lifecycle)
2730
uv run pytest tests_integ/memory/test_memory_client.py -xvs
31+
```
2832

29-
# Client and developer experience
30-
uv run pytest tests_integ/memory/test_memory_client.py -xvs
33+
### Pre-populated memory setup
34+
35+
Retrieval tests require a memory with data already extracted into `/facts/`, `/preferences/`, and `/summaries/` namespaces. Create one once per account:
36+
37+
```python
38+
from bedrock_agentcore.memory import MemoryClient
39+
40+
client = MemoryClient(region_name="us-west-2")
41+
memory = client.create_memory_and_wait(
42+
name="integ_test_prepopulated",
43+
strategies=[
44+
{"semanticMemoryStrategy": {"name": "Semantic", "namespaces": ["/facts/{actorId}/"]}},
45+
{"userPreferenceMemoryStrategy": {"name": "Preferences", "namespaces": ["/preferences/{actorId}/"]}},
46+
{"summaryMemoryStrategy": {"name": "Summary", "namespaces": ["/summaries/{actorId}/{sessionId}/"]}},
47+
],
48+
event_expiry_days=90,
49+
)
50+
client.save_conversation(
51+
memory_id=memory["memoryId"],
52+
actor_id="integ-test-actor",
53+
session_id="integ-test-session",
54+
messages=[
55+
("I prefer dark mode, Python over Java, and vim over emacs", "USER"),
56+
("Noted! Those are solid developer preferences.", "ASSISTANT"),
57+
("I work on distributed systems at a startup in Seattle", "USER"),
58+
("Interesting! Distributed systems is a great field.", "ASSISTANT"),
59+
],
60+
)
61+
# Wait a few minutes for extraction, then verify:
62+
# client.retrieve_memories(memory_id=memory["memoryId"], namespace="/facts/integ-test-actor/", query="developer")
63+
print(f"MEMORY_PREPOPULATED_ID={memory['memoryId']}")
3164
```
3265

3366
## Identity

pyproject.toml

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

0 commit comments

Comments
 (0)