Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

How would you write an integration test that runs your Docker image against moto in CI?

AdvancedScenarioTesting, CI/CD, packaging & services
Answer

Situation read → Test the packaged artifact end to end without AWS.

What I'd do →

  1. Start moto as a server: docker run -d -p 5000:5000 motoserver/moto as a service container.
  2. Seed resources with boto3 pointed at endpoint_url="http://localhost:5000".
  3. Run the image with -e AWS_ENDPOINT_URL=http://host:5000 -e AWS_ACCESS_KEY_ID=x -e AWS_SECRET_ACCESS_KEY=x -e AWS_DEFAULT_REGION=us-east-1; recent boto3 honours AWS_ENDPOINT_URL without code changes.
  4. Assert exit code and report content.

Why → Catches packaging bugs (missing modules, wrong entrypoint) that unit tests cannot.

Interview tip → Mention AWS_ENDPOINT_URL; it removes the need for test-only code paths.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services