diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index 6dbf4ff1..55f55761 100755 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -33,7 +33,7 @@ git config --global --add safe.directory $WORKSPACE # get the current tag (Release) or commit hash (Artifact) #export RMK_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`) # dirty hack - won't spent more time into this... -export RMK_VERSION="1.4.3" +export RMK_VERSION="1.4.3.1" echo "▹ Removing old packages..." rm -f $OMD_ROOT/var/check_mk/packages/* @@ -64,7 +64,7 @@ if [ -n "${GITHUB_WORKSPACE-}" ]; then echo "::set-output name=pkgfile::$NEWFILENAME" # echo "::set-output name=pkgname::${NAME}" # dirty hack - won't spent more time into this... - VERSION="1.4.3" + VERSION="1.4.3.1" # echo "::set-output name=pkgversion::$RMK_VERSION" # echo "::set-output name=cmkmversion::$MVERSION" echo "::set-output name=artifactname::$NEWFILENAME" diff --git a/.vscode/v2/launch.json b/.vscode/v2/launch.json new file mode 100644 index 00000000..15b40d2d --- /dev/null +++ b/.vscode/v2/launch.json @@ -0,0 +1,109 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "devc V2.x bakery localhost", + "type": "python", + "request": "launch", + "program": "/omd/sites/cmk/bin/cmk", + "args": [ + "-A", + "-v", + "-f", + "localhost" + ], + "console": "integratedTerminal", + "python": "/omd/sites/cmk/bin/python3", + // allow to inspect also foreign code + "justMyCode": false + }, + { + "name": "devc V2.x bakery win10simdows", + "type": "python", + "request": "launch", + "program": "/omd/sites/cmk/bin/cmk", + "args": [ + "-A", + "-v", + "-f", + "win10simdows" + ], + "console": "integratedTerminal", + "python": "/omd/sites/cmk/bin/python3", + // allow to inspect also foreign code + "justMyCode": false + }, + { + "name": "devc V2.x Inventory localhost", + "type": "python", + "request": "launch", + "program": "/omd/sites/cmk/bin/cmk", + "args": [ + "-v", + "-II", + "--debug", + "localhost" + ], + "console": "integratedTerminal", + "python": "/omd/sites/cmk/bin/python3", + // allow to inspect also foreign code + "justMyCode": false + }, + { + "name": "devc V2.x Inventory localfoo", + "type": "python", + "request": "launch", + "program": "/omd/sites/cmk/bin/cmk", + "args": [ + "-v", + "-II", + "--debug", + "localfoo" + ], + "console": "integratedTerminal", + "python": "/omd/sites/cmk/bin/python3", + // allow to inspect also foreign code + "justMyCode": false + }, + { + "name": "devc V2.x check localhost", + "type": "python", + "request": "launch", + "program": "/omd/sites/cmk/bin/cmk", + "args": [ + "-v", + "-n", + "-p", + "localhost" + ], + "console": "integratedTerminal", + "python": "/omd/sites/cmk/bin/python3", + // allow to inspect also foreign code + "justMyCode": false + }, + { + "name": "devc V2.x check localfoo", + "type": "python", + "request": "launch", + "program": "/omd/sites/cmk/bin/cmk", + "args": [ + "-v", + "-n", + "-p", + "localfoo" + ], + "console": "integratedTerminal", + "python": "/omd/sites/cmk/bin/python3", + // allow to inspect also foreign code + "justMyCode": false + }, + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": false + }, + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 45de463c..7c6b375f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.4.3.1 - 2024-03-26 + +### Fixed + +* Relative library/resource imports did not work properly in past versions, because the Robot Framework suite wasn't executed in the suite base directory. +* Disabling suite execution by placing a `DISABLED` file did not work when a .robot file was executed instead of a directory. +* Fixed a bug in pathdir function. +* Incremental re-execution strategy did not merge results when suite finally ended OK. ## 1.4.3 - 2024-03-11 diff --git a/agents_plugins/robotmk.py b/agents_plugins/robotmk.py index de061789..14f518ab 100755 --- a/agents_plugins/robotmk.py +++ b/agents_plugins/robotmk.py @@ -34,7 +34,7 @@ local_tz = datetime.utcnow().astimezone().tzinfo -ROBOTMK_VERSION = '1.4.3' +ROBOTMK_VERSION = '1.4.3.1' class RMKConfig: @@ -530,27 +530,23 @@ def execute(self): rc = self.env_strategy.run() self._runner.loginfo(f" < RC: {rc}") - if max_exec == 1 or (max_exec > 1 and rc == 0): - # get out of here if - # - re-execution is not enabled OR - # - first attempt was successful - break - else: - # re-execution possible, check if we should - if rc == 0: - # retry was OK, get out here - self.reexecution_strategy.finalize_results() - break + if max_exec == 1: + break # no re-execution strategy needed + + if rc == 0: + # retry was OK, get out here + self.reexecution_strategy.finalize_results() + break + else: + # retry was not OK, try again + if attempt < max_exec: + self.reexecution_strategy.reparametrize_robot() else: - if attempt < max_exec: - # Chance for next try: set reexecution params according to strategy - self.reexecution_strategy.reparametrize_robot() - else: - # ...GAME OVER! => MERGE - self._runner.loginfo( - " Even the last attempt was unsuccessful!" - ) - self.reexecution_strategy.finalize_results() + # ...GAME OVER! => MERGE + self._runner.loginfo( + " Even the last attempt was unsuccessful!" + ) + self.reexecution_strategy.finalize_results() self.set_statevars( [ @@ -602,7 +598,7 @@ def get_suite_or_global(self, name, default=None): @property def is_disabled_by_flagfile(self): # if disabled flag file exists, return True - return self.path.joinpath("DISABLED").exists() + return self.pathdir.joinpath("DISABLED").exists() @property def get_disabled_reason(self): @@ -610,7 +606,7 @@ def get_disabled_reason(self): # Otherwise return default message. if self.is_disabled_by_flagfile: try: - with open(self.path.joinpath("DISABLED"), "r") as f: + with open(self.pathdir.joinpath("DISABLED"), "r") as f: reason = f.read() if len(reason) > 0: return "Reason: " + reason @@ -630,7 +626,7 @@ def path(self): def pathdir(self): """The absolute path of the Robot test directory, built from the robotdir and the DIRECTORY of the path given in WATO""" - if self.path.is_dir: + if self.path.is_dir(): return self.path else: return self.path.parent @@ -890,7 +886,14 @@ def run(self): cli_args = self.prepare_rf_args() cli_args.append(str(self._suite.path)) self._suite.logger.debug(f"Robot arguments: {' '.join(cli_args)}") + # Change to the suite root directory so that relative imports work + curdir = os.getcwd() + suite_rootdir = Path(self._suite.global_dict['robotdir']) / Path(self._suite.suite_dict["path"]).parts[0] + self._suite.logger.debug(f"Chdir to: {suite_rootdir}") + os.chdir(suite_rootdir) rc = robot.run_cli(cli_args, exit=False) + self._suite.logger.debug(f"Chdir to: {curdir}") + os.chdir(curdir) return rc @@ -1217,16 +1220,15 @@ def update_runner_statevars(self): ] ) runtime_robotmk = runtime_total - runtime_suites - - self.set_statevars( - [ + runtimes = [ ("runtime_total", runtime_total), ("runtime_suites", runtime_suites), ("runtime_robotmk", runtime_robotmk), # ('suites', suites), ("selective_run", self.selective_run), ] - ) + self.loginfo("runtimes: " + str(runtimes)) + self.set_statevars(runtimes) if self.execution_mode == "agent_serial": self.set_statevars( [ diff --git a/bakery/robotmk.py b/bakery/robotmk.py index 704bdf18..511abeab 100644 --- a/bakery/robotmk.py +++ b/bakery/robotmk.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later # This file is part of the Robotmk project (https://www.robotmk.org) -ROBOTMK_VERSION = '1.4.3' +ROBOTMK_VERSION = '1.4.3.1' from typing import Iterable, TypedDict, List from pathlib import Path diff --git a/checks/robotmk.py b/checks/robotmk.py index 9937cb1c..bbba639a 100644 --- a/checks/robotmk.py +++ b/checks/robotmk.py @@ -21,7 +21,7 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import * from cmk.utils.exceptions import MKGeneralException -ROBOTMK_VERSION = '1.4.3' +ROBOTMK_VERSION = '1.4.3.1' DEFAULT_SVC_PREFIX = 'Robot Framework E2E $SUITEID$SPACE-$SPACE' HTML_LOG_DIR = "%s/%s" % (os.environ['OMD_ROOT'], 'var/robotmk')