feat: runnable experiment with working test runner and agents

This commit is contained in:
gmega 2025-01-20 15:24:03 -03:00
parent 6978b7ef28
commit ab100c4841
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
4 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,4 @@
import logging
from pathlib import Path
from typing import Optional
@ -5,6 +6,8 @@ from torrentool.torrent import Torrent
from benchmarks.core.utils import random_data, megabytes
logger = logging.getLogger(__name__)
class DelugeAgent:
def __init__(self, torrents_path: Path, batch_size: int = megabytes(50)):
@ -15,6 +18,8 @@ class DelugeAgent:
torrent_path = self.torrents_path / name
torrent_path.mkdir(parents=True, exist_ok=False)
logger.info(f"Creating torrent {name} with size {size} and seed {seed}")
file_path = torrent_path / "datafile.bin"
with file_path.open(mode="wb") as output:
random_data(size=size, outfile=output, seed=seed)
@ -22,4 +27,6 @@ class DelugeAgent:
torrent = Torrent.create_from(torrent_path)
torrent.name = name
logger.info(f"Torrent {name} created successfully")
return torrent

View File

@ -1,6 +1,7 @@
import socket
import requests
from requests import ConnectionError
from tenacity import stop_after_attempt, wait_exponential, retry
from torrentool.torrent import Torrent
from urllib3.util import Url

View File

@ -13,7 +13,7 @@ deluge_experiment:
# Setting the correct name is critical, and it has to match what's in deluge the StatefulSet.
name: "${DELUGE_STATEFULSET}-{node_index}"
address: "${DELUGE_STATEFULSET}-{node_index}.${DELUGE_SERVICE}.${NAMESPACE}.svc.cluster.local"
agent_url: "http://${DELUGE_STATEFULSET}-{node_index}.${DELUGE_SERVICE}.${NAMESPACE}:${DELUGE_AGENT_PORT}/"
agent_url: "http://${DELUGE_STATEFULSET}-{node_index}.${DELUGE_SERVICE}.${NAMESPACE}:9001/"
daemon_port: 6890
listen_ports: [ 6891, 6892 ]

View File

@ -48,9 +48,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: benchmark-volume
mountPath: /opt/bittorrent-benchmarks/volume
resources:
requests:
cpu: "1"