Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cumulative lint #24

Merged
merged 22 commits into from
May 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use enum instead of str equivalent
Signed-off-by: Zinkelburger <[email protected]>
Zinkelburger committed Apr 3, 2024
commit b9daa42deaf367b6b0afb60fc1f4d43d219ca261
22 changes: 14 additions & 8 deletions testConfig.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@
from k8sClient import K8sClient
from yaml import safe_load
import io
from common import TestType
from common import TestType, TestCaseType, enum_convert, PodType
from typing import List, Dict


class ClusterMode(Enum):
@@ -55,8 +56,8 @@ def __init__(self, config_path: str):

logger.info(self.GetConfig())

def parse_test_cases(self, input_str: str):
output = []
def parse_test_cases(self, input_str: str) -> List[TestCaseType]:
output: List[TestCaseType] = []
parts = input_str.split(",")

for part in parts:
@@ -68,19 +69,24 @@ def parse_test_cases(self, input_str: str):
if "-" in part:
try:
start, end = map(int, part.split("-"))
output.extend(range(start, end + 1))
output.extend(
[
enum_convert(TestCaseType, i)
for i in range(start, end + 1)
]
)
except ValueError:
raise ValueError(f"Invalid test case id: {part}")
else:
output.append(int(part))
output.append(enum_convert(TestCaseType, int(part)))

return output

def validate_pod_type(self, connection_server: dict):
def pod_type_to_enum(self, connection_server: Dict[str, str]) -> PodType:
if "sriov" in connection_server:
if "true" in connection_server["sriov"].lower():
return "sriov"
return "normal"
return PodType.SRIOV
return PodType.NORMAL

def validate_test_type(self, connection: dict) -> TestType:
if "type" not in connection:
4 changes: 2 additions & 2 deletions trafficFlowTests.py
Original file line number Diff line number Diff line change
@@ -188,8 +188,8 @@ def _run(
test_case_id=test_id,
node_server_name=node_server_name,
node_client_name=node_client_name,
server_pod_type=self._tc.validate_pod_type(connections["server"][0]),
client_pod_type=self._tc.validate_pod_type(connections["client"][0]),
server_pod_type=self._tc.pod_type_to_enum(connections["server"][0]),
client_pod_type=self._tc.pod_type_to_enum(connections["client"][0]),
index=index,
test_type=test_type,
reverse=reverse,