Skip to content

Commit

Permalink
Fix installation test
Browse files Browse the repository at this point in the history
  • Loading branch information
WStechura committed Jul 23, 2024
1 parent a1f90b9 commit d768e31
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ ENDCTL
CTL_PARAMS=
INSTALL_DIR="${DEFAULT_INSTALL_DIR}"

uninstall() {
local uninstallScript="${INSTALL_DIR}/agent/${UNINSTALL_SCRIPT}"
if [ -f "${uninstallScript}" ]; then
"${uninstallScript}"
fi
}

parseParams() {
while [ $# -gt 0 ]; do
local param="${1}"
Expand All @@ -41,6 +34,13 @@ parseParams() {
done
}

uninstall() {
local uninstallScript="${INSTALL_DIR}/agent/${UNINSTALL_SCRIPT}"
if [ -f "${uninstallScript}" ]; then
"${uninstallScript}"
fi
}

deployOneagentCtl() {
local ONEAGENTCTL_DIR="${INSTALL_DIR}/agent/tools"
mkdir -p "${ONEAGENTCTL_DIR}"
Expand Down
11 changes: 6 additions & 5 deletions roles/oneagent/tests/integration/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_file_content(path: Path):
def prepare_installers():
logging.info("Preparing installers...")

# TODO: remove SH once oneagentctl in ready
oneagentctl_bin_name = "oneagentctl.sh"
uninstall_script_name = "uninstall.sh"
installer_partial_name = "Dynatrace-OneAgent-Linux"
Expand All @@ -58,15 +59,15 @@ def prepare_installers():
uninstall_code_tag = "##UNINSTALL_CODE##"
oneagentctl_code_tag = "##ONEAGENTCTL_CODE##"

src_dir = Path("resources") / "installers"
resource_dir = Path("resources") / "installers"

uninstall_code = get_file_content(src_dir / uninstall_script_name)
uninstall_code = get_file_content(resource_dir / uninstall_script_name)
uninstall_code = [line.replace("$", r"\$") for line in uninstall_code]
# TODO: remove SH once oneagentctl in ready
oneagentctl_code = get_file_content(src_dir / oneagentctl_bin_name)

oneagentctl_code = get_file_content(resource_dir / oneagentctl_bin_name)
oneagentctl_code = [line.replace("$", r"\$") for line in oneagentctl_code]

installer_template = get_file_content(src_dir / f"{installer_partial_name}.sh")
installer_template = get_file_content(resource_dir / f"{installer_partial_name}.sh")
installer_template = [line.replace(uninstall_code_tag, "".join(uninstall_code)) for line in installer_template]
installer_template = [line.replace(oneagentctl_code_tag, "".join(oneagentctl_code)) for line in installer_template]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def _assert_oneagentctl_getter(
):
oneagentctl = f"{get_oneagentctl_path(platform)}"
tags = wrapper.run_command(platform, address, oneagentctl, ctl_param)
logging.info("AAAAAAAAAAAAAAAAAAAAA")
logging.info(set(tags.stdout.strip().splitlines()))
logging.info(expected_values)
assert tags.returncode == 0 and expected_values == set(tags.stdout.strip().splitlines())


Expand Down Expand Up @@ -144,17 +147,17 @@ 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_INTENDED_PROPERTY, INSTALLER_PROPERTY}
expected_properties = {PLATFORM_PROPERTY, CONFIG_INSTALL_PROPERTY, CONFIG_INTENDED_PROPERTY, INSTALLER_PROPERTY}

perform_operation_on_platforms(platforms, _check_config_args, wrapper, expected_tags, expected_properties)

#
# def test_uninstall(_set_up, runner, configurator, platforms, wrapper):
# logging.info("Running uninstall test")
#
# configurator.set_common_parameter(configurator.PACKAGE_STATE_KEY, "absent")
#
# run_deployment(runner)
#
# logging.info("Check if agent is uninstalled")
# perform_operation_on_platforms(platforms, check_agent_state, wrapper, False)

def test_uninstall(_set_up, runner, configurator, platforms, wrapper):
logging.info("Running uninstall test")

configurator.set_common_parameter(configurator.PACKAGE_STATE_KEY, "absent")

run_deployment(runner)

logging.info("Check if agent is uninstalled")
perform_operation_on_platforms(platforms, check_agent_state, wrapper, False)

0 comments on commit d768e31

Please sign in to comment.