@@ -15,6 +15,297 @@ To run just one test:
1515SYSTEM_NAMESPACE=knative-eventing go test -count=1 -v -tags=e2e -run Smoke_PingSource ./test/rekt/...
1616```
1717
18+ ## AWS Integration tests
19+
20+ AWS integration tests validate IntegrationSource and IntegrationSink resources
21+ that interact with AWS services (S3, SQS, SNS, DynamoDB Streams). These tests
22+ use the ` e2e_aws ` build tag to separate them from regular e2e tests.
23+
24+ To run only AWS integration tests:
25+
26+ ``` bash
27+ SYSTEM_NAMESPACE=knative-eventing \
28+ AWS_ACCESS_KEY_ID=< your-access-key> \
29+ AWS_SECRET_ACCESS_KEY=< your-secret-key> \
30+ go test -count=1 -v -tags=e2e_aws ./test/rekt/...
31+ ```
32+
33+ To run a specific AWS integration test:
34+
35+ ``` bash
36+ SYSTEM_NAMESPACE=knative-eventing \
37+ AWS_ACCESS_KEY_ID=< your-access-key> \
38+ AWS_SECRET_ACCESS_KEY=< your-secret-key> \
39+ go test -count=1 -v -tags=e2e_aws -run TestIntegrationSinkS3Success ./test/rekt/...
40+ ```
41+
42+ ### Required environment variables
43+
44+ - ` AWS_ACCESS_KEY_ID ` - AWS access key with permissions for S3, SQS, SNS, and DynamoDB
45+ - ` AWS_SECRET_ACCESS_KEY ` - AWS secret key
46+
47+ ### Optional environment variables
48+
49+ - ` AWS_REGION ` - AWS region (default: ` us-west-1 ` )
50+
51+ #### IntegrationSource specific
52+
53+ - ` AWS_S3_SOURCE_ARN ` - S3 bucket ARN for source tests (default: ` arn:aws:s3:::eventing-e2e-source ` )
54+ - ` AWS_SQS_SOURCE_ARN ` - SQS queue ARN for source tests (default: ` arn:aws:sqs:us-west-1::eventing-e2e-sqs-source ` )
55+ - ` AWS_DDB_STREAMS_TABLE ` - DynamoDB table name for stream tests (default: ` eventing-e2e-source ` )
56+
57+ #### IntegrationSink specific
58+
59+ - ` AWS_S3_SINK_ARN ` - S3 bucket ARN for sink tests (default: ` arn:aws:s3:::eventing-e2e-sink ` )
60+ - ` AWS_SQS_QUEUE_NAME ` - SQS queue name for sink tests (default: ` eventing-e2e-sqs-sink ` )
61+ - ` AWS_SNS_TOPIC_NAME ` - SNS topic name for sink tests (default: ` eventing-e2e-sns-sink ` )
62+ - ` AWS_SNS_VERIFICATION_QUEUE_NAME ` - SQS queue name for SNS message verification (default: ` eventing-e2e-sns-verification ` )
63+
64+ ** Note:** The AWS resources (S3 buckets, SQS queues, SNS topics, DynamoDB tables)
65+ must be created before running the tests. The tests will clean up objects/messages
66+ created during test execution, but will not create or delete the AWS resources themselves.
67+
68+ ### Setting up AWS resources
69+
70+ You can use the following script to create all required AWS resources:
71+
72+ ``` bash
73+ #! /bin/bash
74+ # setup-aws-resources.sh - Create AWS resources for integration tests
75+
76+ set -e
77+
78+ # Configuration
79+ AWS_REGION=" ${AWS_REGION:- us-west-1} "
80+ S3_SOURCE_BUCKET=" eventing-e2e-source"
81+ S3_SINK_BUCKET=" eventing-e2e-sink"
82+ SQS_SOURCE_QUEUE=" eventing-e2e-sqs-source"
83+ SQS_SINK_QUEUE=" eventing-e2e-sqs-sink"
84+ SNS_VERIFICATION_QUEUE=" eventing-e2e-sns-verification"
85+ SNS_TOPIC=" eventing-e2e-sns-sink"
86+ DDB_TABLE=" eventing-e2e-source"
87+
88+ echo " Creating AWS resources in region: $AWS_REGION "
89+
90+ # Create S3 buckets
91+ echo " Creating S3 buckets..."
92+ aws s3api create-bucket \
93+ --bucket " $S3_SOURCE_BUCKET " \
94+ --region " $AWS_REGION " \
95+ --create-bucket-configuration LocationConstraint=" $AWS_REGION " 2> /dev/null || echo " Bucket $S3_SOURCE_BUCKET already exists"
96+
97+ aws s3api create-bucket \
98+ --bucket " $S3_SINK_BUCKET " \
99+ --region " $AWS_REGION " \
100+ --create-bucket-configuration LocationConstraint=" $AWS_REGION " 2> /dev/null || echo " Bucket $S3_SINK_BUCKET already exists"
101+
102+ # Create SQS queues
103+ echo " Creating SQS queues..."
104+ aws sqs create-queue \
105+ --queue-name " $SQS_SOURCE_QUEUE " \
106+ --region " $AWS_REGION " > /dev/null || echo " Queue $SQS_SOURCE_QUEUE already exists"
107+
108+ aws sqs create-queue \
109+ --queue-name " $SQS_SINK_QUEUE " \
110+ --region " $AWS_REGION " > /dev/null || echo " Queue $SQS_SINK_QUEUE already exists"
111+
112+ aws sqs create-queue \
113+ --queue-name " $SNS_VERIFICATION_QUEUE " \
114+ --region " $AWS_REGION " > /dev/null || echo " Queue $SNS_VERIFICATION_QUEUE already exists"
115+
116+ # Get queue ARN for SNS subscription
117+ VERIFICATION_QUEUE_URL=$( aws sqs get-queue-url \
118+ --queue-name " $SNS_VERIFICATION_QUEUE " \
119+ --region " $AWS_REGION " \
120+ --query ' QueueUrl' \
121+ --output text)
122+
123+ VERIFICATION_QUEUE_ARN=$( aws sqs get-queue-attributes \
124+ --queue-url " $VERIFICATION_QUEUE_URL " \
125+ --attribute-names QueueArn \
126+ --region " $AWS_REGION " \
127+ --query ' Attributes.QueueArn' \
128+ --output text)
129+
130+ # Create SNS topic
131+ echo " Creating SNS topic..."
132+ SNS_TOPIC_ARN=$( aws sns create-topic \
133+ --name " $SNS_TOPIC " \
134+ --region " $AWS_REGION " \
135+ --query ' TopicArn' \
136+ --output text)
137+
138+ echo " SNS Topic ARN: $SNS_TOPIC_ARN "
139+
140+ # Set SQS queue policy to allow SNS to send messages
141+ echo " Setting SQS queue policy for SNS..."
142+ ACCOUNT_ID=$( aws sts get-caller-identity --query Account --output text)
143+
144+ QUEUE_POLICY=$( cat << EOF
145+ {
146+ "Version": "2012-10-17",
147+ "Statement": [
148+ {
149+ "Effect": "Allow",
150+ "Principal": {
151+ "Service": "sns.amazonaws.com"
152+ },
153+ "Action": "SQS:SendMessage",
154+ "Resource": "$VERIFICATION_QUEUE_ARN ",
155+ "Condition": {
156+ "ArnEquals": {
157+ "aws:SourceArn": "$SNS_TOPIC_ARN "
158+ }
159+ }
160+ }
161+ ]
162+ }
163+ EOF
164+ )
165+
166+ POLICY_STRING=$( echo " $QUEUE_POLICY " | jq -c . | jq -R .)
167+ aws sqs set-queue-attributes \
168+ --queue-url " $VERIFICATION_QUEUE_URL " \
169+ --attributes " {\" Policy\" :$POLICY_STRING }" \
170+ --region " $AWS_REGION "
171+
172+ # Subscribe SQS queue to SNS topic
173+ echo " Subscribing SQS queue to SNS topic..."
174+ SUBSCRIPTION_ARN=$( aws sns subscribe \
175+ --topic-arn " $SNS_TOPIC_ARN " \
176+ --protocol sqs \
177+ --notification-endpoint " $VERIFICATION_QUEUE_ARN " \
178+ --region " $AWS_REGION " \
179+ --query ' SubscriptionArn' \
180+ --output text)
181+
182+ echo " Subscription ARN: $SUBSCRIPTION_ARN "
183+
184+ # Create DynamoDB table with streams enabled
185+ echo " Creating DynamoDB table with streams..."
186+ aws dynamodb create-table \
187+ --table-name " $DDB_TABLE " \
188+ --attribute-definitions AttributeName=id,AttributeType=S \
189+ --key-schema AttributeName=id,KeyType=HASH \
190+ --billing-mode PAY_PER_REQUEST \
191+ --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
192+ --region " $AWS_REGION " > /dev/null 2>&1 || echo " Table $DDB_TABLE already exists"
193+
194+ # Wait for DynamoDB table to be active
195+ echo " Waiting for DynamoDB table to be active..."
196+ aws dynamodb wait table-exists \
197+ --table-name " $DDB_TABLE " \
198+ --region " $AWS_REGION "
199+
200+ echo " All AWS resources created successfully!"
201+ echo " "
202+ echo " Environment variables for tests:"
203+ echo " export AWS_REGION=$AWS_REGION "
204+ echo " export AWS_S3_SOURCE_ARN=arn:aws:s3:::$S3_SOURCE_BUCKET "
205+ echo " export AWS_S3_SINK_ARN=arn:aws:s3:::$S3_SINK_BUCKET "
206+ echo " export AWS_SQS_SOURCE_ARN=arn:aws:sqs:$AWS_REGION :$ACCOUNT_ID :$SQS_SOURCE_QUEUE "
207+ echo " export AWS_SQS_QUEUE_NAME=$SQS_SINK_QUEUE "
208+ echo " export AWS_SNS_TOPIC_NAME=$SNS_TOPIC "
209+ echo " export AWS_SNS_VERIFICATION_QUEUE_NAME=$SNS_VERIFICATION_QUEUE "
210+ echo " export AWS_DDB_STREAMS_TABLE=$DDB_TABLE "
211+ ```
212+
213+ ### Tearing down AWS resources
214+
215+ You can use the following script to delete all AWS resources created for testing:
216+
217+ ``` bash
218+ #! /bin/bash
219+ # teardown-aws-resources.sh - Delete AWS resources for integration tests
220+
221+ set -e
222+
223+ # Configuration
224+ AWS_REGION=" ${AWS_REGION:- us-west-1} "
225+ S3_SOURCE_BUCKET=" eventing-e2e-source"
226+ S3_SINK_BUCKET=" eventing-e2e-sink"
227+ SQS_SOURCE_QUEUE=" eventing-e2e-sqs-source"
228+ SQS_SINK_QUEUE=" eventing-e2e-sqs-sink"
229+ SNS_VERIFICATION_QUEUE=" eventing-e2e-sns-verification"
230+ SNS_TOPIC=" eventing-e2e-sns-sink"
231+ DDB_TABLE=" eventing-e2e-source"
232+
233+ echo " Deleting AWS resources in region: $AWS_REGION "
234+
235+ # Delete S3 buckets (must empty first)
236+ echo " Deleting S3 buckets..."
237+ aws s3 rm " s3://$S3_SOURCE_BUCKET " --recursive --region " $AWS_REGION " 2> /dev/null || true
238+ aws s3api delete-bucket \
239+ --bucket " $S3_SOURCE_BUCKET " \
240+ --region " $AWS_REGION " 2> /dev/null || echo " Bucket $S3_SOURCE_BUCKET not found"
241+
242+ aws s3 rm " s3://$S3_SINK_BUCKET " --recursive --region " $AWS_REGION " 2> /dev/null || true
243+ aws s3api delete-bucket \
244+ --bucket " $S3_SINK_BUCKET " \
245+ --region " $AWS_REGION " 2> /dev/null || echo " Bucket $S3_SINK_BUCKET not found"
246+
247+ # Get SNS topic ARN and unsubscribe SQS queue
248+ echo " Unsubscribing SQS from SNS..."
249+ SNS_TOPIC_ARN=$( aws sns list-topics \
250+ --region " $AWS_REGION " \
251+ --query " Topics[?contains(TopicArn, '$SNS_TOPIC ')].TopicArn" \
252+ --output text 2> /dev/null || true)
253+
254+ if [ -n " $SNS_TOPIC_ARN " ]; then
255+ SUBSCRIPTIONS=$( aws sns list-subscriptions-by-topic \
256+ --topic-arn " $SNS_TOPIC_ARN " \
257+ --region " $AWS_REGION " \
258+ --query ' Subscriptions[].SubscriptionArn' \
259+ --output text 2> /dev/null || true)
260+
261+ for SUB_ARN in $SUBSCRIPTIONS ; do
262+ if [ " $SUB_ARN " != " PendingConfirmation" ]; then
263+ aws sns unsubscribe \
264+ --subscription-arn " $SUB_ARN " \
265+ --region " $AWS_REGION " 2> /dev/null || true
266+ fi
267+ done
268+ fi
269+
270+ # Delete SNS topic
271+ echo " Deleting SNS topic..."
272+ if [ -n " $SNS_TOPIC_ARN " ]; then
273+ aws sns delete-topic \
274+ --topic-arn " $SNS_TOPIC_ARN " \
275+ --region " $AWS_REGION " 2> /dev/null || echo " SNS topic $SNS_TOPIC not found"
276+ fi
277+
278+ # Delete SQS queues
279+ echo " Deleting SQS queues..."
280+ for QUEUE in " $SQS_SOURCE_QUEUE " " $SQS_SINK_QUEUE " " $SNS_VERIFICATION_QUEUE " ; do
281+ QUEUE_URL=$( aws sqs get-queue-url \
282+ --queue-name " $QUEUE " \
283+ --region " $AWS_REGION " \
284+ --query ' QueueUrl' \
285+ --output text 2> /dev/null || true)
286+
287+ if [ -n " $QUEUE_URL " ]; then
288+ aws sqs delete-queue \
289+ --queue-url " $QUEUE_URL " \
290+ --region " $AWS_REGION " 2> /dev/null || echo " Queue $QUEUE not found"
291+ fi
292+ done
293+
294+ # Delete DynamoDB table
295+ echo " Deleting DynamoDB table..."
296+ aws dynamodb delete-table \
297+ --table-name " $DDB_TABLE " \
298+ --region " $AWS_REGION " > /dev/null 2>&1 || echo " Table $DDB_TABLE not found"
299+
300+ # Wait for DynamoDB table to be deleted
301+ echo " Waiting for DynamoDB table deletion..."
302+ aws dynamodb wait table-not-exists \
303+ --table-name " $DDB_TABLE " \
304+ --region " $AWS_REGION " 2> /dev/null || true
305+
306+ echo " All AWS resources deleted successfully!"
307+ ```
308+
18309## Broker tests.
19310
20311The Broker class can be overridden by using the envvar ` BROKER_CLASS ` . By
0 commit comments