Skip to content

Commit 660bc1d

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

3 files changed

Lines changed: 366 additions & 11 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ dev = [
150150
"wheel>=0.45.1",
151151
"strands-agents>=1.18.0",
152152
"strands-agents-evals>=0.1.0",
153+
"pytest-xdist>=3.5.0",
154+
"pytest-order>=1.2.0",
153155
]
154156

155157
[project.optional-dependencies]

0 commit comments

Comments
 (0)