Skip to content

Commit

Permalink
chore: define AnalyzerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
penglei0 committed Jul 31, 2024
1 parent ad24f99 commit 366793b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/containernet/data_analyzer/analyzer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from abc import ABC, abstractmethod


class AnalyzerConfig:
input: str # The input file
output: str # The output file


class IDataAnalyzer(ABC):
def __init__(self) -> None:
self.config = None

@abstractmethod
def analyze(self, log_file: str):
def analyze(self, config: AnalyzerConfig):
pass

@abstractmethod
def visualize(self, log_file: str):
def visualize(self, config: AnalyzerConfig):
pass
2 changes: 1 addition & 1 deletion src/containernet/data_analyzer/analyzer_factory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .iperf3_analyzer import Iperf3Analyzer


class LogAnalyzerFactory:
class AnalyzerFactory:
@staticmethod
def get_analyzer(log_type: str):
if log_type == "iperf3":
Expand Down
6 changes: 3 additions & 3 deletions src/containernet/data_analyzer/iperf3_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from .analyzer import IDataAnalyzer
from .analyzer import (IDataAnalyzer, AnalyzerConfig)


class Iperf3Analyzer(IDataAnalyzer):
def analyze(self, log_file: str):
def analyze(self, config: AnalyzerConfig):
pass

def visualize(self, log_file: str):
def visualize(self, config: AnalyzerConfig):
# Implement visualization logic for iperf3 logs
# ... (visualization code)
pass
1 change: 1 addition & 0 deletions src/containernet/test_suites/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class TestType(IntEnum):
class ITestSuite(ABC):
def __init__(self) -> None:
self.is_success = False
self.log_file = None

@abstractmethod
def post_process(self):
Expand Down
11 changes: 9 additions & 2 deletions src/containernet/test_suites/test_iperf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging

from containernet.network import Network
from containernet.data_analyzer.analyzer import AnalyzerConfig
from containernet.data_analyzer.analyzer_factory import AnalyzerFactory
from .test import (ITestSuite, TestType)


Expand All @@ -10,10 +12,15 @@ def __init__(self, type: TestType) -> None:
self.type = type

def post_process(self):
pass
analyzer = AnalyzerFactory.get_analyzer("iperf3")
config = AnalyzerConfig()
config.input = self.log_file
config.output = "iperf3_result.svg"
analyzer.analyze(config)
analyzer.visualize(config)

def pre_process(self):
pass
self.log_file = "iperf3_log.txt"

def _run_test(self, network: Network):
logging.info(
Expand Down

0 comments on commit 366793b

Please sign in to comment.