This sample demonstrates how you can use the AWS Integrated Application Test Kit (IATK) to develop integration tests for your serverless and event-driven applications. It can help you locate test resources hosted on the cloud, attach and monitor test harnesses within SLAs, extract tracing data for your test executions, and more.
Read more on the Introducing the AWS Integrated Application Test Kit (IATK) blog post.
- Prevalidate Plugin Sample
- Postvalidate Plugin Sample with the Integrated Application Test Kit
This sample is built around the idea of a Video Plugin application where users might upload video streams to the platform. Lifecycle events are triggered as the videos are processed. Plugins can react to the events to perform work on the video or video metadata.
The system includes a plugin tester, which is an AWS Step Functions workflow that acts as the video platform - emitting lifecycle events with the expected structure and sequence. The sample tests integrate with the plugin tester to exercise plugin functionality.
Before you run the integration tests, deploy the plugin tester.
cd ./plugins/plugin_tester && sam build --use-container
cd ./plugins/plugin_tester && sam deploy --no-confirm-changeset --no-fail-on-empty-changesetThis example shows how you might write tests without the use of the IATK.
The prevalidate plugin is a sample plugin that acts on the prevalidate event emitted by the platform.
The integration tests use the AWS SDK to query the Amazon CloudFormation API directly and poll the plugin tester workflow.
Deploy the test-prevalidate-plugin
cd ./plugins/1-prevalidate-plugins/test-prevalidate-plugin && sam build --use-container
cd ./plugins/1-prevalidate-plugins/test-prevalidate-plugin && sam deploy --no-confirm-changeset --no-fail-on-empty-changesetRun the test-prevalidate-plugin integration tests
Replace the AWS_REGION parameter with the region you deployed to.
cd ./plugins/1-prevalidate-plugins/test-prevalidate-plugin && npm install
cd ./plugins/1-prevalidate-plugins/test-prevalidate-plugin && PLUGIN_TESTER_STACK_NAME=video-plugin-tester AWS_REGION=us-west-2 npm testIn contrast to the previous test example, these tests show how the IATK simplifies some common testing tasks.
The postvalidate plugin is a sample plugin that acts on the postvalidate event emitted by the platform.
These integration tests use the Integrated Application Test Kit to find cloud-hosted resources and listen for activity.
Deploy the python-minimal-plugin
cd ./plugins/2-postvalidate-plugins/python-minimal-plugin && sam build --use-container
cd ./plugins/2-postvalidate-plugins/python-minimal-plugin && sam deploy --no-confirm-changeset --no-fail-on-empty-changesetRun the python-minimal-plugin integration tests
Replace the AWS_REGION parameter with the region you deployed to.
cd ./plugins/2-postvalidate-plugins/python-minimal-plugin/tests/integration
PLUGIN_TESTER_STACK_NAME=video-plugin-tester AWS_REGION=us-west-2 python3 -m unittest ./test_by_polling.py
PLUGIN_TESTER_STACK_NAME=video-plugin-tester AWS_REGION=us-west-2 python3 -m unittest ./test_by_waiting.py
PLUGIN_TESTER_STACK_NAME=video-plugin-tester AWS_REGION=us-west-2 python3 -m unittest ./test_by_polling_with_registry.py
PLUGIN_TESTER_STACK_NAME=video-plugin-tester AWS_REGION=us-west-2 python3 -m unittest ./test_trace.pyDelete the python-minimal-plugin
cd ./plugins/2-postvalidate-plugins/python-minimal-plugin && sam deleteDelete the test-prevalidate-plugin
cd ./plugins/1-prevalidate-plugins/test-prevalidate-plugin && sam deleteDelete the plugin tester
cd ./plugins/plugin_tester && sam deleteTo learn more about testing serverless applications go to serverlessland.com/testing.

