Skip to content

Commit

Permalink
make it possible to run the test runner containerized; add integratio…
Browse files Browse the repository at this point in the history
…n tests to CI
  • Loading branch information
gmega committed Dec 3, 2024
1 parent c334c12 commit 1261dd0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 9 additions & 8 deletions benchmarks/deluge/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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')))
12 changes: 12 additions & 0 deletions docker-compose.ci.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions experiments-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]

0 comments on commit 1261dd0

Please sign in to comment.