Skip to content

Commit 62fdc9a

Browse files
authored
feat: add data plane, extraction, and lifecycle integ tests to TestMemoryClient (#334)
1 parent 11e2ac5 commit 62fdc9a

5 files changed

Lines changed: 384 additions & 8 deletions

File tree

.github/workflows/integration-testing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ jobs:
159159
PYTHONUNBUFFERED: 1
160160
MEMORY_KINESIS_ARN: ${{ secrets.MEMORY_KINESIS_ARN }}
161161
MEMORY_ROLE_ARN: ${{ secrets.MEMORY_ROLE_ARN }}
162+
MEMORY_PREPOPULATED_ID: ${{ secrets.MEMORY_PREPOPULATED_ID }}
162163
id: tests
163164
timeout-minutes: ${{ matrix.timeout }}
164165
run: |

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ignore_missing_imports = false
6868

6969
[tool.ruff]
7070
line-length = 120
71-
include = ["examples/**/*.py", "src/**/*.py", "tests/**/*.py", "tests-integ/**/*.py"]
71+
include = ["examples/**/*.py", "src/**/*.py", "tests/**/*.py", "tests_integ/**/*.py"]
7272
exclude = ["**/*.md"]
7373

7474
[tool.ruff.lint]

0 commit comments

Comments
 (0)