Skip to content

Commit

Permalink
tester part for ivy nearly ok + still need to modify ivy interface an…
Browse files Browse the repository at this point in the history
…d other small stuffs
  • Loading branch information
ElNiak committed Nov 28, 2024
1 parent 347c426 commit bbb72c9
Show file tree
Hide file tree
Showing 35 changed files with 3,449 additions and 220 deletions.
82 changes: 41 additions & 41 deletions panther/config/experiment_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,46 @@ docker:
build_docker_image: True
generate_new_certificates: True
tests:
- name: "QUIC Client-Server Communication Test I"
description: "Verify that the Picoquic client can communicate with the Picoquic server over Docker Compose network."
protocol: ["quic"] # Protocol name should match the folder name in plugins/
network_environment: "docker_compose" # Environment plugin name
execution_environment: []
debug_environment: []
services:
picoquic_server:
name: "picoquic_server" # Added 'name' key
implementation: "picoquic" # parameters are presents in folder plugins/implementations/quic/picoquic/config.yaml
version: "rfc9000"
type: "iut"
role: "server"
ports:
- "4443:4443"
- "8080:8080" # Health check endpoint
picoquic_client:
name: "picoquic_client" # Added 'name' key
implementation: "picoquic"
version: "rfc9000"
role: "client"
type: "iut"
target: "picoquic_server" # Docker Compose service name
ports:
- "5000:5000" # Example port if needed
- "8081:8081" # Changed to avoid port conflict
steps:
# record_pcap: True
wait:
duration: 20 # seconds to wait during the test
# record_pcap: False
assertions:
- type: "service_responsive"
service: "picoquic_server"
endpoint: "8080/health" # Adjust based on health endpoint
expected_status: 200
- type: "service_responsive"
service: "picoquic_client"
endpoint: "8081/health" # Adjust based on health endpoint
expected_status: 200
# - name: "QUIC Client-Server Communication Test I"
# description: "Verify that the Picoquic client can communicate with the Picoquic server over Docker Compose network."
# protocol: ["quic"] # Protocol name should match the folder name in plugins/
# network_environment: "docker_compose" # Environment plugin name
# execution_environment: []
# debug_environment: []
# services:
# picoquic_server:
# name: "picoquic_server" # Added 'name' key
# implementation: "picoquic" # parameters are presents in folder plugins/implementations/quic/picoquic/config.yaml
# version: "rfc9000"
# type: "iut"
# role: "server"
# ports:
# - "4443:4443"
# - "8080:8080" # Health check endpoint
# picoquic_client:
# name: "picoquic_client" # Added 'name' key
# implementation: "picoquic"
# version: "rfc9000"
# role: "client"
# type: "iut"
# target: "picoquic_server" # Docker Compose service name
# ports:
# - "5000:5000" # Example port if needed
# - "8081:8081" # Changed to avoid port conflict
# steps:
# # record_pcap: True
# wait:
# duration: 20 # seconds to wait during the test
# # record_pcap: False
# assertions:
# - type: "service_responsive"
# service: "picoquic_server"
# endpoint: "8080/health" # Adjust based on health endpoint
# expected_status: 200
# - type: "service_responsive"
# service: "picoquic_client"
# endpoint: "8081/health" # Adjust based on health endpoint
# expected_status: 200

- name: "QUIC Client-Server Communication Test II"
description: "Verify that the Picoquic server can communicate with the Ivy-Tester client over Docker Compose network."
Expand Down Expand Up @@ -83,7 +83,7 @@ tests:
steps:
# record_pcap: True
wait:
duration: 20 # seconds to wait during the test
duration: 60 # seconds to wait during the test
# record_pcap: False
assertions:
- type: "service_responsive"
Expand Down
52 changes: 52 additions & 0 deletions panther/config/experiment_config_iut_2_iut.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
logging:
level: DEBUG
format: "%(asctime)s [%(levelname)s] - %(module)s - %(message)s"
paths:
output_dir: "outputs"
log_dir: "outputs/logs"
config_dir: "configs"
plugin_dir: "plugins"
docker:
build_docker_image: True
generate_new_certificates: True
tests:
- name: "QUIC Client-Server Communication Test IUT"
description: "Verify that the Picoquic client can communicate with the Picoquic server over Docker Compose network."
protocol: ["quic"] # Protocol name should match the folder name in plugins/
network_environment: "docker_compose" # Environment plugin name
execution_environment: []
debug_environment: []
services:
picoquic_server:
name: "picoquic_server" # Added 'name' key
implementation: "picoquic" # parameters are presents in folder plugins/implementations/quic/picoquic/config.yaml
version: "rfc9000"
type: "iut"
role: "server"
ports:
- "4443:4443"
- "8080:8080" # Health check endpoint
picoquic_client:
name: "picoquic_client" # Added 'name' key
implementation: "picoquic"
version: "rfc9000"
role: "client"
type: "iut"
target: "picoquic_server" # Docker Compose service name
ports:
- "5000:5000" # Example port if needed
- "8081:8081" # Changed to avoid port conflict
steps:
# record_pcap: True
wait:
duration: 20 # seconds to wait during the test
# record_pcap: False
assertions:
- type: "service_responsive"
service: "picoquic_server"
endpoint: "8080/health" # Adjust based on health endpoint
expected_status: 200
- type: "service_responsive"
service: "picoquic_client"
endpoint: "8081/health" # Adjust based on health endpoint
expected_status: 200
98 changes: 98 additions & 0 deletions panther/config/experiment_config_iut_2_ivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
logging:
level: DEBUG
format: "%(asctime)s [%(levelname)s] - %(module)s - %(message)s"
paths:
output_dir: "outputs"
log_dir: "outputs/logs"
config_dir: "configs"
plugin_dir: "plugins"
docker:
build_docker_image: True
generate_new_certificates: True
tests:
- name: "QUIC IyvClient-Server Communication Test"
description: "Verify that the Picoquic server can communicate with the Ivy-Tester client over Docker Compose network."
protocol: ["quic"] # Protocol name should match the folder name in plugins/
network_environment: "docker_compose" # Environment plugin name
execution_environment: []
debug_environment: [ ]
services:
picoquic_server:
name: "picoquic_server" # Added 'name' key
type: "iut"
implementation: "picoquic" # parameters are presents in folder plugins/implementations/quic/picoquic/config.yaml
version: "rfc9000"
role: "server"
ports:
- "4443:4443"
- "8080:8080" # Health check endpoint
ivy_client:
name: "ivy_client" # Added 'name' key
implementation: "panther_ivy"
type: "tester"
protocol:
name: "quic"
version: "rfc9000"
test: quic_client_test_max
role: "client"
target: "picoquic_server" # Docker Compose service name
ports:
- "5000:5000" # Example port if needed
- "8081:8081" # Changed to avoid port conflict
steps:
# record_pcap: True
wait:
duration: 60 # seconds to wait during the test
# record_pcap: False
assertions:
- type: "service_responsive"
service: "picoquic_server"
endpoint: "8080/health" # Adjust based on health endpoint
expected_status: 200
- type: "service_responsive"
service: "ivy_client"
endpoint: "8081/health" # Adjust based on health endpoint
expected_status: 200

- name: "QUIC Client-IvyServer Communication Test"
description: "Verify that the Picoquic client can communicate with the Picoquic server over Docker Compose network."
protocol: "quic" # Protocol name should match the folder name in plugins/
network_environment: "docker_compose" # Environment plugin name
execution_environment: None
services:
picoquic_client:
name: "picoquic_client" # Added 'name' key
implementation: "picoquic"
version: "rfc9000"
role: "client"
type: "iut"
target: "ivy_server" # Docker Compose service name
ports:
- "5000:5000" # Example port if needed
- "8081:8081" # Changed to avoid port conflict
ivy_server:
name: "ivy_server" # Added 'name' key
implementation: "ivy"
protocol: "quic"
version: "rfc9000"
role: "server"
type: "tester"
target: "picoquic_client" # Docker Compose service name
ports:
- "4443:4443"
- "8080:8080" # Health check endpoint
steps:
# record_pcap: True
wait:
duration: 20 # seconds to wait during the test
# record_pcap: False
assertions:
- type: "service_responsive"
service: "picoquic_server"
endpoint: "8080/health" # Adjust based on health endpoint
expected_status: 200
- type: "service_responsive"
service: "ivy_server"
endpoint: "8081/health" # Adjust based on health endpoint
expected_status: 200

8 changes: 8 additions & 0 deletions panther/core/test_cases/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def __str__(self):
f"services={self.services}, "
f"environments={self.environments}, "
f"test_experiment_dir={self.test_experiment_dir})")

def __repr__(self):
return (f"TestCase(name={self.test_config.get('name', 'Unnamed Test')}, "
f"description={self.test_config.get('description', '')}, "
f"services={self.services}, "
f"environments={self.environments}, "
f"test_experiment_dir={self.test_experiment_dir})")

def run(self):
"""Runs the test case based on the provided configuration."""
Expand Down Expand Up @@ -381,5 +388,6 @@ def generate_deployment_commands(self, environment:str) -> Dict[str, str]:
deployment_commands.update(info_commands)
except Exception as e:
self.logger.error(f"Failed to generate deployment command for service '{service_name}': {e}")
exit(1)
self.logger.debug(f"Collected deployment commands: {deployment_commands}")
self.deployment_commands = deployment_commands
23 changes: 18 additions & 5 deletions panther/core/utils/docker_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ def build_image(self, impl_name: str, version: str, dockerfile_path: Path,
network_mode="host",
)
self.log_docker_output(build_logs, f"Building Docker image '{image_tag}'")
self.logger.info(f"Successfully built Docker image '{image_tag}'")
self.logger.info(f"Successfully built Docker image '{image_tag}' with context '{context_path}' and build args '{build_args}'")
return image_tag
except (BuildError, APIError) as e:
self.logger.error(f"Failed to build Docker image '{image_tag}': {e}")
self.logger.error(f"Failed to build Docker image '{image_tag}' : {e}")
self.log_docker_output(e.build_log, f"Building Docker image '{image_tag}'", log_f)
if self.build_log_file:
with open(self.build_log_file, 'a') as log_f:
Expand Down Expand Up @@ -159,9 +159,9 @@ def find_dockerfiles(self, plugins_dir: str) -> Dict[str, Path]:
"""
dockerfiles = {}
self.plugins_dir = plugins_dir # Store for later use in dependency builds

implementations_dir = Path(plugins_dir) / "implementations"
self.logger.info(f"Scanning for Dockerfiles in '{implementations_dir.resolve()}'")

if not implementations_dir.exists():
self.logger.warning(f"Implementations directory '{implementations_dir}' does not exist.")
return dockerfiles
Expand All @@ -175,9 +175,8 @@ def find_dockerfiles(self, plugins_dir: str) -> Dict[str, Path]:
self.logger.debug(f"Found Dockerfile for implementation '{impl_name}': {dockerfile.resolve()}")


testers_dir = Path(plugins_dir) / "testers"
self.logger.info(f"Scanning for Dockerfiles in '{testers_dir.resolve()}'")
tester_dir = Path(plugins_dir) / "testers"
self.logger.info(f"Scanning for Dockerfiles in '{tester_dir.resolve()}'")
if not tester_dir.exists():
self.logger.warning(f"Testers directory '{tester_dir}' does not exist.")
return dockerfiles
Expand All @@ -191,6 +190,20 @@ def find_dockerfiles(self, plugins_dir: str) -> Dict[str, Path]:
self.logger.debug(f"Found Dockerfile for tester '{impl_name}': {dockerfile.resolve()}")


env_dir = Path(plugins_dir) / "environments"
self.logger.info(f"Scanning for Dockerfiles in '{env_dir.resolve()}'")
if not env_dir.exists():
self.logger.warning(f"Environment directory '{env_dir}' does not exist.")
return dockerfiles

for impl_dir in env_dir.rglob("*"):
if impl_dir.is_dir():
dockerfile = impl_dir / "Dockerfile"
if dockerfile.exists():
impl_name = impl_dir.name # e.g., 'picoquic', 'picotls'
dockerfiles[impl_name] = dockerfile.resolve()
self.logger.debug(f"Found Dockerfile for environment '{impl_name}': {dockerfile.resolve()}")

self.logger.info(f"Total Dockerfiles found: {len(dockerfiles)}")
self.logger.debug(f"Dockerfiles found: {dockerfiles}")
return dockerfiles
Expand Down
File renamed without changes.
48 changes: 48 additions & 0 deletions panther/core/utils/plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,54 @@ def build_docker_image(self, impl_name: str, version: Optional[str] = None):
self.logger.error(f"Configuration file '{config_path}' does not exist for implementation '{impl_name}'. Skipping.")
exit(1)

def build_docker_image_from_path(self, path: Path, version: Optional[str] = None):
"""
Builds a Docker image for a given implementation and version.
:param impl_name: Name of the implementation.
:param version: Version of the implementation.
"""
if impl_name in self.dockerfiles:
dockerfile_path = self.dockerfiles[impl_name]
# Load version-specific configurations from config.yaml
config_path = dockerfile_path.parent / "config.yaml"
if config_path.exists():
with open(config_path, 'r') as f:
full_config = yaml.safe_load(f)

impl_config = full_config.get(impl_name, {})
if not version:
if "ivy" in impl_name:
versions = impl_config.get("quic",{}).get('versions', {})
else:
versions = impl_config.get('versions', {})
else:
versions = {version: impl_config.get(version, {})}

self.logger.debug(f"Found configuration for implementation '{impl_name}': {versions}")
for version, version_config in versions.items():
self.logger.info(f"Building image for implementation '{impl_name}' version '{version}'")
image_tag = self.docker_builder.build_image(
impl_name=impl_name,
version=version,
dockerfile_path=dockerfile_path,
context_path=dockerfile_path.parent,
config=version_config,
tag_version="latest" # or use version if desired
)
if image_tag:
key = f"{impl_name}_{version}"
self.built_images[key] = image_tag
else:
self.logger.error(f"Image build failed for implementation '{impl_name}' version '{version}'")
else:
self.logger.error(f"Configuration file '{config_path}' does not exist for implementation '{impl_name}'. Skipping.")
exit(1)
else:
self.logger.error(f"Configuration file '{config_path}' does not exist for implementation '{impl_name}'. Skipping.")
exit(1)


def build_all_docker_images(self):
"""
Finds and builds all Docker images from Dockerfiles using DockerBuilder.
Expand Down
Loading

0 comments on commit bbb72c9

Please sign in to comment.