Table of Contents |
---|
Overview
Testcontainers-Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
Sample Test Case using Docker-Compose
...
Code Block |
---|
version: "2" services: zookeeper: image: bitnami/zookeeper:3.7 ports: - "2181:2181" environment: - ALLOW_ANONYMOUS_LOGIN=yes kafka: image: docker.io/bitnami/kafka:3 ports: - "9092:9092" environment: - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 - ALLOW_PLAINTEXT_LISTENER=yes - KAFKA_CFG_LISTENERS=INTERNAL://:9093,EXTERNAL://:9092 - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://:9093,EXTERNAL://localhost:9092 - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL depends_on: - zookeeper kowl: image: rsmnarts/kowl:latest restart: on-failure ports: - "8080:8080" environment: - KAFKA_BROKERS=kafka:9093 depends_on: - kafka |
References
Reference | URL |
---|---|
Testcontainers-Go | https://golang.testcontainers.org/ |
Using Docker Compose | https://golang.testcontainers.org/features/docker_compose/ |
Kafka Test Containers with GoLang | https://medium.com/trendyol-tech/kafka-test-containers-with-golang-b85e4b2469db |