Skip to content

Commit

Permalink
Adapt tests to work with with regular installer
Browse files Browse the repository at this point in the history
  • Loading branch information
WStechura committed Jul 26, 2024
1 parent 096e8f9 commit f6fb43e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 6 additions & 2 deletions roles/oneagent/tests/integration/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import shutil
import subprocess
from datetime import datetime

from pathlib import Path
from typing import Dict, Any, List
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f6fb43e

Please sign in to comment.