@@ -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
215301class TestMemoryControlPlaneClientUnit :
216302 """Unit tests for MemoryControlPlaneClient using mocks."""
0 commit comments