Skip to content

Commit

Permalink
Renamed run_inside_docker to run_for_dockerized_ws
Browse files Browse the repository at this point in the history
Signed-off-by: noopur <[email protected]>
  • Loading branch information
noopurintel committed Dec 17, 2024
1 parent f0731c5 commit 967a9d5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions tests/end_to_end/models/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ def generate_sign_request(self):
except Exception as e:
raise ex.CSRGenerationException(f"Failed to generate sign request for {self.name}: {e}")

def start(self, res_file, run_inside_docker=False):
def start(self, res_file, run_for_dockerized_ws=False):
"""
Start the aggregator
Args:
res_file (str): Result file to track the logs
run_inside_docker (bool): Flag to run the aggregator inside a docker container
run_for_dockerized_ws (bool): Flag to run the aggregator inside a docker container
Returns:
str: Path to the log file
"""
try:
log.info(f"Starting {self.name}")
res_file = res_file if not run_inside_docker else os.path.basename(res_file)
res_file = res_file if not run_for_dockerized_ws else os.path.basename(res_file)
error_msg = "Failed to start the aggregator"
fh.run_command(
"fx aggregator start",
error_msg=error_msg,
container_id=self.container_id,
workspace_path=self.workspace_path if not run_inside_docker else "",
workspace_path=self.workspace_path if not run_for_dockerized_ws else "",
run_in_background=True,
bg_file=res_file,
run_inside_docker=run_inside_docker
run_for_dockerized_ws=run_for_dockerized_ws
)
log.info(
f"Started {self.name} and tracking the logs in {res_file}."
Expand Down
18 changes: 9 additions & 9 deletions tests/end_to_end/models/collaborator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ def create_collaborator(self):
log.error(f"{error_msg}: {e}")
raise e

def import_pki(self, zip_name, run_inside_docker=False):
def import_pki(self, zip_name, run_for_dockerized_ws=False):
"""
Import and certify the CSR for the collaborator
Args:
zip_name (str): Zip file name
run_inside_docker (bool): Run the command inside the docker container
run_for_dockerized_ws (bool): Run the command inside the docker container
This is special case for dockerized workspace.
Returns:
bool: True if successful, else False
Expand All @@ -102,8 +102,8 @@ def import_pki(self, zip_name, run_inside_docker=False):
cmd,
error_msg=error_msg,
container_id=self.container_id,
workspace_path=self.workspace_path if not run_inside_docker else "",
run_inside_docker=run_inside_docker,
workspace_path=self.workspace_path if not run_for_dockerized_ws else "",
run_for_dockerized_ws=run_for_dockerized_ws,
)
fh.verify_cmd_output(
output, return_code, error, error_msg,
Expand All @@ -115,27 +115,27 @@ def import_pki(self, zip_name, run_inside_docker=False):
raise e
return True

def start(self, res_file, run_inside_docker=False):
def start(self, res_file, run_for_dockerized_ws=False):
"""
Start the collaborator
Args:
res_file (str): Result file to track the logs
run_inside_docker (bool): Flag to run the collaborator inside a docker container
run_for_dockerized_ws (bool): Flag to run the collaborator inside a docker container
Returns:
str: Path to the log file
"""
try:
log.info(f"Starting {self.collaborator_name}")
res_file = res_file if not run_inside_docker else os.path.basename(res_file)
res_file = res_file if not run_for_dockerized_ws else os.path.basename(res_file)
error_msg = f"Failed to start {self.collaborator_name}"
fh.run_command(
f"fx collaborator start -n {self.collaborator_name}",
error_msg=error_msg,
container_id=self.container_id,
workspace_path=self.workspace_path if not run_inside_docker else "",
workspace_path=self.workspace_path if not run_for_dockerized_ws else "",
run_in_background=True,
bg_file=res_file,
run_inside_docker=run_inside_docker
run_for_dockerized_ws=run_for_dockerized_ws
)
log.info(
f"Started {self.name} and tracking the logs in {res_file}."
Expand Down
18 changes: 9 additions & 9 deletions tests/end_to_end/utils/federation_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ def copy_file_between_participants(
return True


def run_federation(fed_obj, install_dependencies=True, run_inside_docker=False):
def run_federation(fed_obj, install_dependencies=True, run_for_dockerized_ws=False):
"""
Start the federation
Args:
fed_obj (object): Federation fixture object
install_dependencies (bool): Install dependencies on collaborators (default is True)
run_inside_docker (bool): Run the command inside docker container (default is False)
run_for_dockerized_ws (bool): Run the command inside docker container (default is False)
This is special case for dockerized workspace where the command is run inside the container only at the end
Returns:
list: List of response files for all the participants
Expand All @@ -247,7 +247,7 @@ def run_federation(fed_obj, install_dependencies=True, run_inside_docker=False):
constants.AGG_COL_RESULT_FILE.format(
fed_obj.workspace_path, participant.name
),
run_inside_docker=run_inside_docker,
run_for_dockerized_ws=run_for_dockerized_ws,
)
for participant in fed_obj.collaborators + [fed_obj.aggregator]
]
Expand Down Expand Up @@ -278,7 +278,7 @@ def run_federation_for_dws(fed_obj, use_tls):
workspace_path="",
error_msg=f"Failed to extract certificates for {participant.name}",
container_id=participant.container_id,
run_inside_docker=True,
run_for_dockerized_ws=True,
)
for participant in [fed_obj.aggregator] + fed_obj.collaborators
]
Expand All @@ -295,7 +295,7 @@ def run_federation_for_dws(fed_obj, use_tls):
executor.submit(
collaborator.import_pki,
zip_name=f"agg_to_col_{collaborator.name}_signed_cert.zip",
run_inside_docker=True,
run_for_dockerized_ws=True,
)
for collaborator in fed_obj.collaborators
]
Expand All @@ -307,7 +307,7 @@ def run_federation_for_dws(fed_obj, use_tls):
raise e

# Start federation run for all the participants
return run_federation(fed_obj, run_inside_docker=True)
return run_federation(fed_obj, run_for_dockerized_ws=True)


def install_dependencies_on_collaborators(fed_obj):
Expand Down Expand Up @@ -582,7 +582,7 @@ def run_command(
run_in_background=False,
bg_file=None,
print_output=False,
run_inside_docker=False,
run_for_dockerized_ws=False,
):
"""
Run the command
Expand All @@ -593,7 +593,7 @@ def run_command(
run_in_background (bool): Run the command in background
bg_file (str): Background file (with path)
print_output (bool): Print the output
run_inside_docker (bool): Run the command inside docker container
run_for_dockerized_ws (bool): Run the command inside docker container
This is special case for dockerized workspace where the command is run inside the container only at the end
Returns:
tuple: Return code, output and error
Expand All @@ -603,7 +603,7 @@ def run_command(

is_docker = (
True
if (os.getenv("TEST_ENV") == "task_runner_docker" or run_inside_docker)
if (os.getenv("TEST_ENV") == "task_runner_docker" or run_for_dockerized_ws)
else False
)

Expand Down

0 comments on commit 967a9d5

Please sign in to comment.