version: "3.5"

services:
  cassandra:
    image: cassandra:4.1.1
    ports:
      - "9042:9042"
    networks:
      services-network:
        aliases:
          - cassandra
    environment:
      - "MAX_HEAP_SIZE=256M"
      - "HEAP_NEWSIZE=128M"
    healthcheck:
      test: ["CMD", "cqlsh", "-u cassandra", "-p cassandra" ,"-e describe keyspaces"]
      interval: 15s
      timeout: 30s
      retries: 10

  zookeeper:
    image: wurstmeister/zookeeper:3.4.6
    ports:
      - "2181:2181"
    networks:
      services-network:
        aliases:
          - zookeeper

  kafka:
    image: wurstmeister/kafka:2.12-2.1.1
    depends_on:
      - zookeeper
    ports:
      - "9092:9092"
    networks:
      services-network:
        aliases:
          - kafka
    environment:
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      # create a topic with 10 partitions and 1 replica
      # topic name must match ASYNC_WF_KAFKA_QUEUE_TOPIC specified in cadence container above
      KAFKA_CREATE_TOPICS: "async-wf-topic1:10:1"

  integration-test-async-wf:
    build:
      context: ../../
      dockerfile: ./docker/buildkite/Dockerfile
    command:
      - /bin/sh
      - -e
      - -c
      - >
        go test -timeout 60s
        -run ^TestAsyncWFIntegrationSuite$
        -tags asyncwfintegration
        -count 1
        -v
        github.com/uber/cadence/host
        | tee test.log
    ports:
      - "7933:7933"
      - "7934:7934"
      - "7935:7935"
      - "7939:7939"
    environment:
      - "ASYNC_WF_KAFKA_QUEUE_TOPIC=async-wf-topic1"
      - "CASSANDRA=1"
      - "CASSANDRA_SEEDS=cassandra"
      - "ES_SEEDS=elasticsearch"
      - "KAFKA_SEEDS=kafka"
      - "KAFKA_PORT=9092"
    depends_on:
      cassandra:
        condition: service_healthy
      kafka:
        condition: service_started
    volumes:
      - ../../:/cadence
    networks:
      services-network:
        aliases:
          - integration-test

networks:
  services-network:
    name: services-network
    driver: bridge
