diff --git a/roles/oneagent/tests/integration/resources/installers/oneagentctl.sh b/roles/oneagent/tests/integration/resources/installers/oneagentctl.sh index 973bc94..6e2e071 100644 --- a/roles/oneagent/tests/integration/resources/installers/oneagentctl.sh +++ b/roles/oneagent/tests/integration/resources/installers/oneagentctl.sh @@ -15,13 +15,22 @@ cutVariable() { saveToConfig() { while [ $# -gt 0 ]; do - local setter="$(cutVariable "${1}" "=" 1)" - local setterType="$(cutVariable "${setter}" "-" "5-")" - local value="$(cutVariable "${1}" "=" "2-")" - local setterFile="${DEPLOYMENT_CONF_PATH}/${setterType}" + # example command: --set-host-property=TENANT=tenant1 + # setter: --set-host-property + local setter="$(cutVariable "${1}" "=" 1)" + # setterType: property + local setterType="$(cutVariable "${setter}" "-" "5-")" + # value: TENANT=tenant1 + local value="$(cutVariable "${1}" "=" "2-")" + # property: TENANT + local property="$(cutVariable "${value}" "=" "1")" + local setterFile="${DEPLOYMENT_CONF_PATH}/${setterType}" + if grep -q "${property}" "${setterFile}"; then + sed -i "s/${property}.*/${value}/" "${setterFile}" + else printf '%s\n' "${value}" >>"${setterFile}" - echo "${1} Set ${setterType} to ${value}" >> "${DIR_NAME}/output" - shift + fi + shift done } diff --git a/roles/oneagent/tests/integration/run.py b/roles/oneagent/tests/integration/run.py index b719593..08109c0 100644 --- a/roles/oneagent/tests/integration/run.py +++ b/roles/oneagent/tests/integration/run.py @@ -4,6 +4,7 @@ import os import shutil import subprocess +from datetime import datetime from pathlib import Path from typing import Dict, Any, List @@ -112,10 +113,12 @@ def prepare_installers(): installer_template = replace_tag(installer_template, uninstall_code_tag, "".join(uninstall_code)) installer_template = replace_tag(installer_template, oneagentctl_code_tag, "".join(oneagentctl_code)) + timestamp = '{:%Y%m%d-%H%M%S}'.format(datetime.now()) # Minimal supported version is 1.199 for version in ["1.199.0", "1.300.0"]: - installer_code = replace_tag(installer_template, version_tag, version) - with open(INSTALLERS_DIR / f"{installer_partial_name}-{version}.sh", "w") as f: + full_version = f"{version}.{timestamp}" + installer_code = replace_tag(installer_template, version_tag, full_version) + with open(INSTALLERS_DIR / f"{installer_partial_name}-{full_version}.sh", "w") as f: f.writelines(installer_code) @@ -151,6 +154,7 @@ def main(): prepare_environment() with ServerWrapper(run_server()): result = run_tests(parse_args()) + shutil.rmtree(TEST_DIR, ignore_errors=True) return result diff --git a/roles/oneagent/tests/integration/scripts/tests/test_installAndConfig.py b/roles/oneagent/tests/integration/scripts/tests/test_installAndConfig.py index 25bfa3b..0bfdbb2 100644 --- a/roles/oneagent/tests/integration/scripts/tests/test_installAndConfig.py +++ b/roles/oneagent/tests/integration/scripts/tests/test_installAndConfig.py @@ -144,7 +144,7 @@ def test_oneagentctl_intended_config(_set_up, runner, configurator, platforms, w logging.info("Check if config args were applied correctly") expected_tags = {INSTALLER_TAG, PLATFORM_TAG, CONFIG_INSTALL_TAG, CONFIG_INTENDED_TAG} - expected_properties = {PLATFORM_PROPERTY, CONFIG_INSTALL_PROPERTY, CONFIG_INTENDED_PROPERTY, INSTALLER_PROPERTY} + expected_properties = {PLATFORM_PROPERTY, CONFIG_INTENDED_PROPERTY, INSTALLER_PROPERTY} perform_operation_on_platforms(platforms, _check_config_args, wrapper, expected_tags, expected_properties) diff --git a/roles/oneagent/tests/integration/scripts/tests/test_upgrade.py b/roles/oneagent/tests/integration/scripts/tests/test_upgrade.py index 60abc2e..fa9a08c 100644 --- a/roles/oneagent/tests/integration/scripts/tests/test_upgrade.py +++ b/roles/oneagent/tests/integration/scripts/tests/test_upgrade.py @@ -18,7 +18,7 @@ def _get_versions_for_platforms(platforms: PlatformCollection, latest: bool) -> for platform, _ in platforms.items(): installers = get_installers(platform.system(), platform.arch()) versioned_installer = installers[-1 if latest else 0] - versions[platform] = re.search(r"\d.\d+.\d+", str(versioned_installer)).group() + versions[platform] = re.search(r"\d.\d+.\d+.\d+-\d+", str(versioned_installer)).group() return versions