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