avast / pytest-docker

Docker-based integration tests
MIT License
406 stars 68 forks source link

Pytest hangs on custom docker compose file #111

Open nazikus opened 1 month ago

nazikus commented 1 month ago

I have a custom docker compose file, I redefine docker_compose_file fixture as instructed, but it hangs there on execution and never gets to actual test function. The path to compose file is correct.

Reproduce code:

@pytest.fixture(scope="session")
def docker_compose_file(pytestconfig):
    compose_path = os.path.join(str(pytestconfig.rootdir), "docker-compose.live.yml")
    print(compose_path)
    return compose_path

def test_docker(docker_services):
    print("test")
    print(docker_services.port_for("mediamtx", 8554))
    assert True

To see test stdout output run: pytest -vv -s

n1ngu commented 1 month ago

What are the contents of the docker-compose.live.yml file?

nazikus commented 1 month ago
# docker compose for testing live streams

services:

  tracker:
    image: app:latest
    build:
      dockerfile: Dockerfile
    depends_on: [stream]
    network_mode: service:mediamtx
    privileged: true
    stdin_open: true
    init: true
    tty: true
    ipc: host
    deploy:
      resources:
        limits:
          memory: 2G

  mediamtx:
    image: bluenviron/mediamtx:latest
    ports:
      - "8554:8554"  # RTSP
      - "1935:1935"  # RTMP
      - "8888:8888"  # HLS
      - "8889:8889"  # WebRTC
    volumes:
      - ./mediamtx.yml:/mediamtx.yml
    environment:
      - MTX_PROTOCOLS=tcp,udp
    init: true
    deploy:
      resources:
        limits:
          memory: 1G

  stream:
    image: linuxserver/ffmpeg:latest
    entrypoint: ["bash", "-c"]
    depends_on: [mediamtx]
    network_mode: service:mediamtx
    command: [
      "ffmpeg -hide_banner -loglevel info -re -stream_loop -1
        -i /videos/test.mp4
        -c copy
        -f rtsp
        -rtsp_transport tcp
        rtsp://localhost:8554/live/test"]
    volumes:
      - ./videos:/videos
    logging:
      driver: none
    init: true
nazikus commented 2 weeks ago

@n1ngu any ideas? i could try to help fixing this issue but not sure where to start from

cdeneen-adelaide commented 5 days ago

Does it work if you don't attempt to redefine the location of the Dockerfile?