diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1c6620..6558ce8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,6 +56,10 @@ jobs: run: | docker run --rm --entrypoint pytest bittorrent-benchmarks:test -m "not integration" + - name: Run Integration Tests + run: | + docker compose -f docker-compose.yaml -f docker-compose.ci.yaml up --abort-on-container-exit --exit-code-from test-runner + - name: Build and Push Prod. Image uses: docker/build-push-action@v6 with: diff --git a/benchmarks/deluge/tests/fixtures.py b/benchmarks/deluge/tests/fixtures.py index 1ec1e06..e723c99 100644 --- a/benchmarks/deluge/tests/fixtures.py +++ b/benchmarks/deluge/tests/fixtures.py @@ -1,8 +1,9 @@ +import os from pathlib import Path from typing import Generator import pytest -from urllib3.util import Url, parse_url +from urllib3.util import parse_url from benchmarks.core import utils from benchmarks.core.utils import megabytes, await_predicate @@ -11,9 +12,9 @@ from benchmarks.tests.utils import shared_volume -def deluge_node(name: str, port: int) -> Generator[DelugeNode, None, None]: - node = DelugeNode(name, volume=shared_volume(), daemon_port=port) - await_predicate(node.is_ready, timeout=10, polling_interval=0.5) +def deluge_node(name: str, address: str, port: int) -> Generator[DelugeNode, None, None]: + node = DelugeNode(name, volume=shared_volume(), daemon_address=address, daemon_port=port) + assert await_predicate(node.is_ready, timeout=10, polling_interval=0.5) node.wipe_all_torrents() try: yield node @@ -23,17 +24,17 @@ def deluge_node(name: str, port: int) -> Generator[DelugeNode, None, None]: @pytest.fixture def deluge_node1() -> Generator[DelugeNode, None, None]: - yield from deluge_node('deluge-1', 6890) + yield from deluge_node('deluge-1', os.environ.get('DELUGE_NODE_1', 'localhost'), 6890) @pytest.fixture def deluge_node2() -> Generator[DelugeNode, None, None]: - yield from deluge_node('deluge-2', 6893) + yield from deluge_node('deluge-2', os.environ.get('DELUGE_NODE_2', 'localhost'), 6893) @pytest.fixture def deluge_node3() -> Generator[DelugeNode, None, None]: - yield from deluge_node('deluge-3', 6896) + yield from deluge_node('deluge-3', os.environ.get('DELUGE_NODE_3', 'localhost'), 6896) @pytest.fixture @@ -44,4 +45,4 @@ def temp_random_file() -> Generator[Path, None, None]: @pytest.fixture def tracker() -> Tracker: - return Tracker(parse_url('http://127.0.0.1:8000/announce')) + return Tracker(parse_url(os.environ.get('TRACKER_ANNOUNCE_URL', 'http://127.0.0.1:8000/announce'))) diff --git a/docker-compose.ci.yaml b/docker-compose.ci.yaml new file mode 100644 index 0000000..2e09456 --- /dev/null +++ b/docker-compose.ci.yaml @@ -0,0 +1,12 @@ +services: + test-runner: + image: bittorrent-benchmarks:test + container_name: test-runner + volumes: + - ./volume:/opt/bittorrent-benchmarks/volume + entrypoint: [ "pytest", "--exitfirst" ] + environment: + - DELUGE_NODE_1=deluge-1 + - DELUGE_NODE_2=deluge-2 + - DELUGE_NODE_3=deluge-3 + - TRACKER_ANNOUNCE_URL=http://tracker:8000/announce \ No newline at end of file diff --git a/experiments-local.yaml b/experiments-local.yaml index f6c9321..fd45e85 100644 --- a/experiments-local.yaml +++ b/experiments-local.yaml @@ -2,18 +2,18 @@ # Docker compose environment. deluge_experiment: seeders: 1 - tracker_announce_url: http://127.0.0.1:8000/announce + tracker_announce_url: ${TRACKER_ANNOUNCE_URL:-http://127.0.0.1:8000/announce} file_size: 52428800 repetitions: 3 shared_volume_path: ${PWD}/volume nodes: - - address: localhost + - address: ${DELUGE_NODE_1:-localhost} daemon_port: 6890 listen_ports: [ 6891, 6892 ] - - address: localhost + - address: ${DELUGE_NODE_2:-localhost} daemon_port: 6893 listen_ports: [ 6894, 6895 ] - - address: localhost + - address: ${DELUGE_NODE_3:-localhost} daemon_port: 6896 listen_ports: [ 6897, 6898 ]