Skip to content

Commit 0ed3195

Browse files
committed
test: add stream delivery integ tests and TESTING.md
1 parent a77f13a commit 0ed3195

2 files changed

Lines changed: 138 additions & 0 deletions

File tree

TESTING.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Integration Tests
2+
3+
See [CONTRIBUTING.md](CONTRIBUTING.md) for initial setup (Python, `uv sync`, etc).
4+
5+
All integration tests require AWS credentials with `bedrock-agentcore:*` and `bedrock-agentcore-control:*` permissions.
6+
7+
```bash
8+
export AWS_PROFILE=<your-profile>
9+
export BEDROCK_TEST_REGION=us-west-2
10+
```
11+
12+
## Runtime
13+
14+
```bash
15+
uv run pytest tests_integ/runtime -xvs --log-cli-level=INFO
16+
```
17+
18+
## Memory
19+
20+
```bash
21+
# Control plane (CRUD on memories/strategies, 5-10 min due to provisioning)
22+
uv run pytest tests_integ/memory/test_controlplane.py -xvs -k "integration"
23+
24+
# Stream delivery (requires env vars below, skips if unset)
25+
export BEDROCK_TEST_KINESIS_STREAM_ARN=<Kinesis Data Stream ARN>
26+
export BEDROCK_TEST_EXECUTION_ROLE_ARN=<IAM role ARN trusted by bedrock-agentcore.amazonaws.com with kinesis:PutRecord/PutRecords permissions>
27+
uv run pytest tests_integ/memory/test_controlplane.py -xvs -k "TestStreamDeliveryResources"
28+
29+
# Client and developer experience
30+
uv run pytest tests_integ/memory/test_memory_client.py -xvs
31+
uv run pytest tests_integ/memory/test_devex.py -xvs
32+
```
33+
34+
## Identity
35+
36+
```bash
37+
uv run pytest tests_integ/identity -xvs
38+
```
39+
40+
## Tools (Code Interpreter, Browser)
41+
42+
```bash
43+
uv run pytest tests_integ/tools -xvs
44+
```
45+
46+
## CI
47+
48+
| Workflow | Tests | Required |
49+
|---|---|---|
50+
| `integration-testing.yml` | `tests_integ/runtime` | Yes |
51+
52+
Memory integration tests are not yet run in CI. They require pre-provisioned infrastructure (Kinesis stream, IAM role), take 5-10 minutes per run due to service provisioning times, and include LLM-dependent assertions that can be flaky. Run them locally for now — CI support is planned once infrastructure and test stability are addressed.

tests_integ/memory/test_controlplane.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,92 @@ def test_workflow_3_list_and_delete_memories(self):
211211
assert len(remaining_test_memories) == 0, f"Expected 0 test memories, found {len(remaining_test_memories)}"
212212

213213

214+
@pytest.mark.integration
215+
class TestStreamDeliveryResources:
216+
"""Integration tests for streamDeliveryResources.
217+
218+
Requires environment variables:
219+
BEDROCK_TEST_KINESIS_STREAM_ARN: ARN of a pre-existing Kinesis stream
220+
BEDROCK_TEST_EXECUTION_ROLE_ARN: ARN of an IAM role the memory service can assume
221+
"""
222+
223+
@classmethod
224+
def setup_class(cls):
225+
cls.kinesis_stream_arn = os.environ.get("BEDROCK_TEST_KINESIS_STREAM_ARN")
226+
cls.execution_role_arn = os.environ.get("BEDROCK_TEST_EXECUTION_ROLE_ARN")
227+
228+
if not cls.kinesis_stream_arn or not cls.execution_role_arn:
229+
pytest.skip("BEDROCK_TEST_KINESIS_STREAM_ARN and BEDROCK_TEST_EXECUTION_ROLE_ARN required")
230+
231+
cls.region = os.environ.get("BEDROCK_TEST_REGION", "us-west-2")
232+
cls.client = MemoryControlPlaneClient(region_name=cls.region)
233+
cls.test_prefix = f"test_stream_{int(time.time())}"
234+
cls.memory_ids = []
235+
236+
@classmethod
237+
def teardown_class(cls):
238+
for memory_id in cls.memory_ids:
239+
try:
240+
cls.client.delete_memory(
241+
memory_id=memory_id,
242+
wait_for_deletion=True,
243+
wait_for_strategies=False,
244+
max_wait=120,
245+
poll_interval=5,
246+
)
247+
except Exception as e:
248+
print(f"Failed to delete memory {memory_id}: {e}")
249+
250+
def _make_delivery_config(self, level="FULL_CONTENT"):
251+
return {
252+
"resources": [
253+
{
254+
"kinesis": {
255+
"dataStreamArn": self.kinesis_stream_arn,
256+
"contentConfigurations": [{"type": "MEMORY_RECORDS", "level": level}],
257+
}
258+
}
259+
]
260+
}
261+
262+
def test_stream_delivery_create_and_update(self):
263+
"""Create memory with FULL_CONTENT delivery, update to METADATA_ONLY, verify both."""
264+
# Create with FULL_CONTENT
265+
delivery_config = self._make_delivery_config("FULL_CONTENT")
266+
267+
memory = self.client.create_memory(
268+
name=f"{self.test_prefix}_stream",
269+
memory_execution_role_arn=self.execution_role_arn,
270+
stream_delivery_resources=delivery_config,
271+
wait_for_active=True,
272+
max_wait=300,
273+
poll_interval=10,
274+
)
275+
276+
memory_id = memory["id"]
277+
self.__class__.memory_ids.append(memory_id)
278+
279+
assert memory["status"] == "ACTIVE"
280+
assert memory["streamDeliveryResources"] == delivery_config
281+
282+
# Verify via get_memory
283+
details = self.client.get_memory(memory_id)
284+
assert details["streamDeliveryResources"] == delivery_config
285+
286+
# Update to METADATA_ONLY (update_memory returns the updated state synchronously)
287+
updated_config = self._make_delivery_config("METADATA_ONLY")
288+
updated = self.client.update_memory(
289+
memory_id=memory_id,
290+
stream_delivery_resources=updated_config,
291+
)
292+
293+
assert updated["streamDeliveryResources"] == updated_config
294+
295+
# Verify update via get_memory
296+
details = self.client.get_memory(memory_id)
297+
assert details["streamDeliveryResources"] == updated_config
298+
299+
214300
@pytest.mark.unit
215301
class TestMemoryControlPlaneClientUnit:
216302
"""Unit tests for MemoryControlPlaneClient using mocks."""

0 commit comments

Comments
 (0)