1+ INTEG_STACK_NAME ?= rust-lambda-integration-tests
2+ INTEG_FUNCTIONS_BUILD := runtime-fn runtime-trait http-fn
3+ INTEG_FUNCTIONS_INVOKE := RuntimeFn RuntimeFnAl2 RuntimeTrait RuntimeTraitAl2 Python PythonAl2
4+ INTEG_API_INVOKE := RestApiUrl HttpApiUrl
5+ INTEG_EXTENSIONS := extension-fn extension-trait
6+ # Using musl to run extensions on both AL1 and AL2
7+ INTEG_ARCH := x86_64-unknown-linux-musl
8+
9+ integration-tests :
10+ # Build Integration functions
11+ cross build --release --target $(INTEG_ARCH) -p lambda_integration_tests
12+ rm -rf ./build
13+ mkdir -p ./build
14+ ${MAKE} ${MAKEOPTS} $(foreach function,${INTEG_FUNCTIONS_BUILD}, build-integration-function-${function})
15+ ${MAKE} ${MAKEOPTS} $(foreach extension,${INTEG_EXTENSIONS}, build-integration-extension-${extension})
16+ # Deploy to AWS
17+ sam deploy \
18+ --template lambda-integration-tests/template.yaml \
19+ --stack-name ${INTEG_STACK_NAME} \
20+ --capabilities CAPABILITY_IAM \
21+ --resolve-s3 \
22+ --no-fail-on-empty-changeset
23+ # Invoke functions
24+ ${MAKE} ${MAKEOPTS} $(foreach function,${INTEG_FUNCTIONS_INVOKE}, invoke-integration-function-${function})
25+ ${MAKE} ${MAKEOPTS} $(foreach api,${INTEG_API_INVOKE}, invoke-integration-api-${api})
26+
27+ build-integration-function-% :
28+ mkdir -p ./build/$*
29+ cp -v ./target/$(INTEG_ARCH ) /release/$* ./build/$* /bootstrap
30+
31+ build-integration-extension-% :
32+ mkdir -p ./build/$* /extensions
33+ cp -v ./target/$(INTEG_ARCH ) /release/$* ./build/$* /extensions/$*
34+
35+ invoke-integration-function-% :
36+ aws lambda invoke --function-name $$(aws cloudformation describe-stacks --stack-name $(INTEG_STACK_NAME ) \
37+ --query ' Stacks[0].Outputs[?OutputKey==`$*`].OutputValue' \
38+ --output text) --payload ' {"command": "hello"}' --cli-binary-format raw-in-base64-out /dev/stdout
39+
40+ invoke-integration-api-% :
41+ $(eval API_URL := $(shell aws cloudformation describe-stacks --stack-name $(INTEG_STACK_NAME ) \
42+ --query ' Stacks[0].Outputs[?OutputKey==`$*`].OutputValue' \
43+ --output text))
44+ curl $(API_URL ) /get
45+ curl $(API_URL ) /al2/get
46+ curl -X POST -d ' {"command": "hello"}' $(API_URL ) /post
47+ curl -X POST -d ' {"command": "hello"}' $(API_URL ) /al2/post
48+
0 commit comments