Skip to content

Commit

Permalink
Merge pull request #16 from Zinkelburger/black_lint
Browse files Browse the repository at this point in the history
Lint with black, remove unnecessary imports
  • Loading branch information
SalDaniele authored Apr 17, 2024
2 parents 7387dae + 9b73f03 commit 63f1af6
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 264 deletions.
43 changes: 32 additions & 11 deletions arguments.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
import os
from logger import logger, configure_logger
from logger import configure_logger
import logging
import argparse
from pathlib import Path


def parse_args() -> argparse.Namespace:

parser = argparse.ArgumentParser(description='Build a custom image and store in the specified repository')
parser.add_argument('config', metavar='config', type=str, help='Yaml file with test configuration (see config.yaml)')
parser.add_argument('evaluator_config', metavar='evaluator_config', type=str, help="Yaml file with configuration for scoring test results (see eval-config.yaml)")
parser.add_argument('-v', '--verbosity', choices=['debug', 'info', 'warning', 'error', 'critical'], default='info', help='Set the logging level (default: info)')
parser = argparse.ArgumentParser(
description="Build a custom image and store in the specified repository"
)
parser.add_argument(
"config",
metavar="config",
type=str,
help="Yaml file with test configuration (see config.yaml)",
)
parser.add_argument(
"evaluator_config",
metavar="evaluator_config",
type=str,
help="Yaml file with configuration for scoring test results (see eval-config.yaml)",
)
parser.add_argument(
"-v",
"--verbosity",
choices=["debug", "info", "warning", "error", "critical"],
default="info",
help="Set the logging level (default: info)",
)

args = parser.parse_args()

log_levels = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': logging.CRITICAL
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
"critical": logging.CRITICAL,
}
args.verbosity = log_levels[args.verbosity]
configure_logger(args.verbosity)

if not Path(args.config).exists():
raise ValueError("Must provide a valid config.yaml file (see config.yaml)")
if not Path(args.evaluator_config).exists():
raise ValueError("Must provide a valid config file to evaluate results (see eval-config.yaml)")
raise ValueError(
"Must provide a valid config file to evaluate results (see eval-config.yaml)"
)

return args
99 changes: 55 additions & 44 deletions common.py
Original file line number Diff line number Diff line change
@@ -1,107 +1,118 @@
import jinja2
from dataclasses import dataclass, asdict, field
from dataclasses import dataclass, field
from enum import Enum
from typing import List

FT_BASE_IMG = "quay.io/wizhao/ft-base-image:0.9"
TFT_TOOLS_IMG = "quay.io/wizhao/tft-tools:latest"
TFT_TESTS = "tft-tests"


class TestType(Enum):
IPERF_TCP = 1
IPERF_UDP = 2
HTTP = 3
IPERF_TCP = 1
IPERF_UDP = 2
HTTP = 3


class PodType(Enum):
NORMAL = 1
SRIOV = 2
NORMAL = 1
SRIOV = 2
HOSTBACKED = 3


class TestCaseType(Enum):
POD_TO_POD_SAME_NODE = 1
POD_TO_POD_DIFF_NODE = 2
POD_TO_HOST_SAME_NODE = 3
POD_TO_HOST_DIFF_NODE = 4
POD_TO_CLUSTER_IP_TO_POD_SAME_NODE = 5
POD_TO_CLUSTER_IP_TO_POD_DIFF_NODE = 6
POD_TO_CLUSTER_IP_TO_HOST_SAME_NODE = 7
POD_TO_CLUSTER_IP_TO_HOST_DIFF_NODE = 8
POD_TO_NODE_PORT_TO_POD_SAME_NODE = 9
POD_TO_NODE_PORT_TO_POD_DIFF_NODE = 10
POD_TO_NODE_PORT_TO_HOST_SAME_NODE = 11
POD_TO_NODE_PORT_TO_HOST_DIFF_NODE = 12
HOST_TO_HOST_SAME_NODE = 13
HOST_TO_HOST_DIFF_NODE = 14
HOST_TO_POD_SAME_NODE = 15
HOST_TO_POD_DIFF_NODE = 16
HOST_TO_CLUSTER_IP_TO_POD_SAME_NODE = 17
HOST_TO_CLUSTER_IP_TO_POD_DIFF_NODE = 18
POD_TO_POD_SAME_NODE = 1
POD_TO_POD_DIFF_NODE = 2
POD_TO_HOST_SAME_NODE = 3
POD_TO_HOST_DIFF_NODE = 4
POD_TO_CLUSTER_IP_TO_POD_SAME_NODE = 5
POD_TO_CLUSTER_IP_TO_POD_DIFF_NODE = 6
POD_TO_CLUSTER_IP_TO_HOST_SAME_NODE = 7
POD_TO_CLUSTER_IP_TO_HOST_DIFF_NODE = 8
POD_TO_NODE_PORT_TO_POD_SAME_NODE = 9
POD_TO_NODE_PORT_TO_POD_DIFF_NODE = 10
POD_TO_NODE_PORT_TO_HOST_SAME_NODE = 11
POD_TO_NODE_PORT_TO_HOST_DIFF_NODE = 12
HOST_TO_HOST_SAME_NODE = 13
HOST_TO_HOST_DIFF_NODE = 14
HOST_TO_POD_SAME_NODE = 15
HOST_TO_POD_DIFF_NODE = 16
HOST_TO_CLUSTER_IP_TO_POD_SAME_NODE = 17
HOST_TO_CLUSTER_IP_TO_POD_DIFF_NODE = 18
HOST_TO_CLUSTER_IP_TO_HOST_SAME_NODE = 19
HOST_TO_CLUSTER_IP_TO_HOST_DIFF_NODE = 20
HOST_TO_NODE_PORT_TO_POD_SAME_NODE = 21
HOST_TO_NODE_PORT_TO_POD_DIFF_NODE = 22
HOST_TO_NODE_PORT_TO_HOST_SAME_NODE = 23
HOST_TO_NODE_PORT_TO_HOST_DIFF_NODE = 24
POD_TO_EXTERNAL = 25
HOST_TO_EXTERNAL = 26
HOST_TO_NODE_PORT_TO_POD_SAME_NODE = 21
HOST_TO_NODE_PORT_TO_POD_DIFF_NODE = 22
HOST_TO_NODE_PORT_TO_HOST_SAME_NODE = 23
HOST_TO_NODE_PORT_TO_HOST_DIFF_NODE = 24
POD_TO_EXTERNAL = 25
HOST_TO_EXTERNAL = 26


class ConnectionMode(Enum):
POD_IP = 1
CLUSTER_IP = 2
NODE_PORT_IP = 3
EXTERNAL_IP = 4
POD_IP = 1
CLUSTER_IP = 2
NODE_PORT_IP = 3
EXTERNAL_IP = 4


class NodeLocation(Enum):
SAME_NODE = 1
DIFF_NODE = 2
SAME_NODE = 1
DIFF_NODE = 2


@dataclass
class PodInfo():
class PodInfo:
name: str
pod_type: str
is_tenant: bool
index: int


@dataclass
class TestMetadata():
class TestMetadata:
test_case_id: str
test_type: str
reverse: bool
server: PodInfo
client: PodInfo


@dataclass
class IperfOutput():
class IperfOutput:
tft_metadata: TestMetadata
command: str
result: dict


@dataclass
class PluginOutput():
class PluginOutput:
plugin_metadata: dict
command: str
result: dict
name: str


@dataclass
class RxTxData():
class RxTxData:
rx_start: int
tx_start: int
rx_end: int
tx_end: int


@dataclass
class TftAggregateOutput():
'''Aggregated output of a single tft run. A single run of a trafficFlowTests._run_tests() will
class TftAggregateOutput:
"""Aggregated output of a single tft run. A single run of a trafficFlowTests._run_tests() will
pass a reference to an instance of TftAggregateOutput to each task to which the task will append
it's respective output. A list of this class will be the expected format of input provided to
evaluator.py.
Attributes:
flow_test: an object of type IperfOutput containing the results of a flow test run
plugins: a list of objects derivated from type PluginOutput for each optional plugin to append
resulting output to.'''
resulting output to."""

flow_test: IperfOutput = None
plugins: List[PluginOutput] = field(default_factory=list)

Expand Down
Loading

0 comments on commit 63f1af6

Please sign in to comment.