Skip to content

vellankikoti/testcontainers-db-message-brokers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comprehensive Guide for Database Testing & Message Brokers with Testcontainers in Python 🐍🐳

Welcome to the world of Testcontainers for Database Testing & Message Brokers with Python!

This guide is a dedicated resource to help developers understand and utilize Testcontainers for database testing and message-driven applications in various environments.

It covers setup, core concepts, database testing, message brokers, and best practices.


🎯 How to Navigate the Guide (What's Inside)

This guide covers everything you need to know about database testing and message brokers with Testcontainers:

  • Setup: Instructions for setting up your environment and troubleshooting common issues.
  • Core Concepts: Fundamental concepts essential for understanding Testcontainers.
  • Database Testing Examples: Hands-on implementations for various databases.
  • Message Brokers: How to test RabbitMQ, Kafka, and Redis.
  • Best Practices: Writing clean, efficient, and reliable tests.

πŸ“š Repository Structure

testcontainers-python-guide/
β”œβ”€β”€ README.md
β”œβ”€β”€ setup/
β”‚   β”œβ”€β”€ environment_setup.md
β”‚   └── troubleshooting.md
β”œβ”€β”€ core_concepts/
β”‚   β”œβ”€β”€ core_concepts.md
β”‚   β”œβ”€β”€ accessing_logs.md
β”‚   └── health_checks.md
β”œβ”€β”€ database_testing/
β”‚   β”œβ”€β”€ postgres_example/
β”‚   β”œβ”€β”€ mysql_example/
β”‚   β”œβ”€β”€ mongodb_example/
β”œβ”€β”€ message_brokers/
β”‚   β”œβ”€β”€ rabbitmq_example/
β”‚   β”œβ”€β”€ kafka_example/
β”‚   β”œβ”€β”€ redis_example/
β”œβ”€β”€ best_practices/
β”‚   β”œβ”€β”€ clean_tests.md
β”‚   β”œβ”€β”€ optimizing_startup.md
β”‚   β”œβ”€β”€ resource_management.md

πŸš€ Getting Started

  1. Clone this repository:

    git clone https://github.com/vellankikoti/testcontainers-db-message-brokers.git
    cd testcontainers-db-message-brokers
  2. Install the prerequisites:

    • Python 3.7+
    • Docker
    • Docker Compose (optional, for multi-container examples)
  3. Navigate to any example directory and follow the README instructions.


πŸ“Œ Database Testing Examples

βœ… PostgreSQL Example

  • Testing database connections and queries using Testcontainers for PostgreSQL.
  • Includes sample queries, transactions, and rollback tests.

βœ… MySQL Example

  • Testing schema migrations and data integrity using Testcontainers for MySQL.
  • Sample test cases for CRUD operations.

βœ… MongoDB Example

  • Testing NoSQL queries and indexing using Testcontainers for MongoDB.
  • Example scenarios for schema-less validation.

πŸ“Œ Message Brokers

βœ… RabbitMQ Example

  • Testing message queueing, pub/sub models, and event-driven architectures with Testcontainers for RabbitMQ.
  • Simulating producer-consumer workflows.

βœ… Kafka Example

  • Testing distributed event streaming with Kafka.
  • Example scenarios for producing and consuming messages in a microservices architecture.

βœ… Redis Example

  • Using Testcontainers for Redis caching and pub/sub testing.
  • Ensuring cache consistency and expiry testing.

πŸ† Best Practices

  • Write isolated tests to avoid interdependencies.
  • Use test fixtures to manage database states.
  • Leverage database snapshots to speed up tests.
  • Optimize container startup times for CI/CD efficiency.
  • Use parallelized testing to speed up execution.

🀝 Contributing

We welcome contributions! Here's how you can help:

Adding New Examples

  1. Choose the appropriate section for your example:

    • Database Testing β†’ database_testing/
    • Message Brokers β†’ message_brokers/
  2. Create a new directory following the naming convention:

    section_name/your_example_name/
    
  3. Include these files in your example directory:

    • README.md (explaining the example)
    • requirements.txt (Python dependencies)
    • Source code files
    • Test files
    • Docker configurations (if needed)

Pull Request Process

  1. Fork the repository.
  2. Create a feature branch:
    git checkout -b feature/NewExample
  3. Commit your changes:
    git commit -m 'Add new example'
  4. Push to your branch:
    git push origin feature/NewExample
  5. Open a Pull Request.

πŸ“š Resources


⭐ Show Your Support

If you find this guide helpful, please give it a star! ⭐ It helps others discover this resource.


Made with ❀️ by the Community

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages