# Starts an OpenTelemetry Collector and then runs the OTLP exporter integration tests.
# This should be run from the root of the repo:
#    docker-compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/docker-compose.yml --project-directory=. up --exit-code-from=tests --build

version: '3.7'

services:
  create-cert:
    image: mcr.microsoft.com/dotnet/sdk:7.0
    volumes:
      - ./test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest:/cfg
    command: /cfg/create-cert.sh

  otel-collector:
    image: otel/opentelemetry-collector
    volumes:
      - ./test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest:/cfg
    command: --config=/cfg/otel-collector-config.yaml
    depends_on:
      - create-cert

  tests:
    build:
      context: .
      dockerfile: ./test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/Dockerfile
    volumes:
      - ./test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest:/cfg
    command: /cfg/run-test.sh
    environment:
      - OTEL_COLLECTOR_HOSTNAME=otel-collector
      - OTEL_MOCK_COLLECTOR_HOSTNAME=mock-otel-collector
    depends_on:
      - otel-collector
