Skip to content

Commit 668d524

Browse files
committed
test: add stream delivery integ tests and TESTING.md
1 parent 98100d7 commit 668d524

3 files changed

Lines changed: 132 additions & 0 deletions

File tree

.github/workflows/integration-testing.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ jobs:
117117
timeout: 10
118118
extra-deps: ""
119119
ignore: ""
120+
# TODO: expand to full tests_integ/memory once test stability is addressed
121+
- group: memory
122+
path: tests_integ/memory/test_stream_delivery.py
123+
timeout: 10
124+
extra-deps: ""
125+
ignore: ""
120126
- group: evaluation
121127
path: tests_integ/evaluation
122128
timeout: 15
@@ -151,6 +157,8 @@ jobs:
151157
env:
152158
AWS_REGION: us-west-2
153159
PYTHONUNBUFFERED: 1
160+
BEDROCK_TEST_KINESIS_STREAM_ARN: ${{ secrets.MEMORY_KINESIS_ARN }}
161+
MEMORY_ROLE_ARN: ${{ secrets.MEMORY_ROLE_ARN }}
154162
id: tests
155163
timeout-minutes: ${{ matrix.timeout }}
156164
run: |

TESTING.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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, fails if unset)
25+
export BEDROCK_TEST_KINESIS_STREAM_ARN=<Kinesis Data Stream ARN>
26+
export MEMORY_ROLE_ARN=<IAM role ARN trusted by bedrock-agentcore.amazonaws.com with kinesis:PutRecord/PutRecords permissions>
27+
uv run pytest tests_integ/memory/test_stream_delivery.py -xvs
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+
| `integration-testing.yml` | `tests_integ/memory/test_stream_delivery.py` | Yes |
52+
| `integration-testing.yml` | `tests_integ/evaluation` | Yes |
53+
54+
Stream delivery tests fail in CI unless `BEDROCK_TEST_KINESIS_STREAM_ARN` and `MEMORY_ROLE_ARN` secrets are configured on the repo. Other memory integration tests are not yet run in CI due to provisioning times and flaky LLM-dependent assertions — CI support is planned once test stability is addressed.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Integration tests for streamDeliveryResources on MemoryClient.
2+
3+
Requires environment variables:
4+
BEDROCK_TEST_KINESIS_STREAM_ARN: ARN of a pre-existing Kinesis stream
5+
MEMORY_ROLE_ARN: ARN of an IAM role the memory service can assume
6+
7+
Run with:
8+
pytest tests_integ/memory/test_stream_delivery.py -xvs --log-cli-level=INFO
9+
"""
10+
11+
import os
12+
import time
13+
14+
import pytest
15+
16+
from bedrock_agentcore.memory import MemoryClient
17+
18+
19+
@pytest.mark.integration
20+
class TestStreamDeliveryResources:
21+
"""Integration tests for streamDeliveryResources."""
22+
23+
@classmethod
24+
def setup_class(cls):
25+
cls.kinesis_stream_arn = os.environ.get("BEDROCK_TEST_KINESIS_STREAM_ARN")
26+
cls.execution_role_arn = os.environ.get("MEMORY_ROLE_ARN")
27+
28+
if not cls.kinesis_stream_arn or not cls.execution_role_arn:
29+
pytest.fail("BEDROCK_TEST_KINESIS_STREAM_ARN and MEMORY_ROLE_ARN must be set")
30+
31+
cls.region = os.environ.get("BEDROCK_TEST_REGION", "us-west-2")
32+
cls.client = MemoryClient(region_name=cls.region)
33+
cls.test_prefix = f"test_stream_{int(time.time())}"
34+
cls.memory_ids = []
35+
36+
@classmethod
37+
def teardown_class(cls):
38+
for memory_id in cls.memory_ids:
39+
try:
40+
cls.client.delete_memory(memory_id)
41+
except Exception as e:
42+
print(f"Failed to delete memory {memory_id}: {e}")
43+
44+
def _make_delivery_config(self, level="FULL_CONTENT"):
45+
return {
46+
"resources": [
47+
{
48+
"kinesis": {
49+
"dataStreamArn": self.kinesis_stream_arn,
50+
"contentConfigurations": [{"type": "MEMORY_RECORDS", "level": level}],
51+
}
52+
}
53+
]
54+
}
55+
56+
def test_stream_delivery_create(self):
57+
"""Create memory with stream delivery config and verify via get_memory."""
58+
delivery_config = self._make_delivery_config("FULL_CONTENT")
59+
60+
memory = self.client.create_memory_and_wait(
61+
name=f"{self.test_prefix}_stream",
62+
strategies=[],
63+
memory_execution_role_arn=self.execution_role_arn,
64+
stream_delivery_resources=delivery_config,
65+
)
66+
67+
memory_id = memory.get("memoryId", memory.get("id"))
68+
self.memory_ids.append(memory_id)
69+
70+
assert memory["streamDeliveryResources"] == delivery_config

0 commit comments

Comments
 (0)