Skip to content

Commit

Permalink
Client-triggered forced update of pip packages
Browse files Browse the repository at this point in the history
  • Loading branch information
joergschultzelutter authored Aug 8, 2022
1 parent 072cd22 commit c753997
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
18 changes: 16 additions & 2 deletions src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,23 @@


class RemoteFrameworkClient:
def __init__(self, remote_connect_string: str, debug=False):
def __init__(
self,
remote_connect_string: str,
always_upgrade_server_packages: bool,
debug: bool = False,
):
"""
Constructor for RemoteFrameworkClient
Parameters
==========
remote_connect_string : 'str'
connect string, containing host, port, user and pass
always_upgrade_server_packages: 'bool'
Always upgrade pip packages on the server even if they are already installed. This is
exquivalent to the server's "always-upgrade-packages" option but allows you to control
the upgrade through a client call
debug: 'bool'
run in debug mode. Enables extra logging and instructs the remote server not to cleanup the
workspace after test execution
Expand All @@ -66,6 +75,7 @@ def __init__(self, remote_connect_string: str, debug=False):

self._debug = debug
self._remote_connect_string = remote_connect_string
self._always_upgrade_server_packages = always_upgrade_server_packages
self._dependencies = {}
self._pip_dependencies = {}
self._suites = {}
Expand Down Expand Up @@ -122,6 +132,7 @@ def execute_run(
self._suites,
self._dependencies,
self._pip_dependencies,
self._always_upgrade_server_packages,
robot_arg_dict,
self._debug,
)
Expand Down Expand Up @@ -347,6 +358,7 @@ def _process_robot_file(self, source):
robot_output_file,
robot_log_file,
robot_report_file,
robot_always_upgrade_server_packages,
) = get_command_line_params_client()

# Set debug level
Expand Down Expand Up @@ -427,7 +439,9 @@ def _process_robot_file(self, source):

# Default branch for executing actual tests
rfs = RemoteFrameworkClient(
remote_connect_string=remote_connect_string, debug=robot_debug
remote_connect_string=remote_connect_string,
always_upgrade_server_packages=robot_always_upgrade_server_packages,
debug=robot_debug,
)
result = rfs.execute_run(
suite_list=robot_input_dir,
Expand Down
11 changes: 9 additions & 2 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def execute_robot_run(
test_suites: dict,
dependencies: dict,
pip_dependencies: dict,
always_upgrade_server_packages: bool,
robot_args: dict,
debug=False,
):
Expand All @@ -123,6 +124,10 @@ def execute_robot_run(
Dictionary of files the test suites are dependent on
pip_dependencies: 'list'
List of pip packages that the user explicitly asked us to install
always_upgrade_server_packages: 'bool'
Always upgrade pip packages on the server even if they are already installed. This is
exquivalent to the server's "always-upgrade-packages" option but allows you to control
the upgrade through a client call
robot_args: 'dict'
Dictionary of arguments to pass to robot.run()
debug: 'bool'
Expand Down Expand Up @@ -169,8 +174,10 @@ def execute_robot_run(
# Check if the package (excluding the version info!) is already installed
# If not, collect the entries with potential version info
# (but don't install the pip packages yet)
if (pip_package not in installed_pips) or (
robot_always_upgrade_packages
if (
(pip_package not in installed_pips)
or (robot_always_upgrade_packages)
or (always_upgrade_server_packages)
):
if pip_dependency not in pips_to_be_installed:
pips_to_be_installed.append(pip_dependency)
Expand Down
16 changes: 15 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def get_command_line_params_server():
dest="robot_always_upgrade_packages",
action="store_true",
help="If your Robot Framework suite depends on external pip packages, always upgrade these packages"
" even if they are already installed",
" on the XMLRPC server even if they are already installed. Similar to the client argument"
" 'always-upgrade-server-packages' but forces the upgrade for each test (regardless of the client"
" settings)."
)

parser.add_argument(
Expand Down Expand Up @@ -416,6 +418,16 @@ def get_command_line_params_client():
help="Robot Framework report file name. Default value: remote_report.html",
)

parser.add_argument(
"--always-upgrade-server-packages",
dest="robot_always_upgrade_server_packages",
action="store_true",
help="If your Robot Framework suite depends on external pip packages, always upgrade these packages"
" on the remote XMLRPC server even if they are already installed. This is the equivalent to the"
" server's 'always-upgrade-packages' option which allows you to control a forced update through"
" the client.",
)

parser.add_argument(
"--debug",
dest="robot_debug",
Expand Down Expand Up @@ -445,6 +457,7 @@ def get_command_line_params_client():
robot_output_file = args.robot_output_file
robot_log_file = args.robot_log_file
robot_report_file = args.robot_report_file
robot_always_upgrade_server_packages = args.robot_always_upgrade_server_packages

# populate defaults in case the user has not specified a value
# obviously, argparse's 'extend' option does not permit defaults
Expand All @@ -471,6 +484,7 @@ def get_command_line_params_client():
robot_output_file,
robot_log_file,
robot_report_file,
robot_always_upgrade_server_packages,
)


Expand Down

0 comments on commit c753997

Please sign in to comment.