-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt old integration scripts to work with GitHub actions
- Loading branch information
Showing
44 changed files
with
1,434 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
roles/oneagent/tests/integration/resources/ansible/credentials.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
ansible_user: '' | ||
ansible_password: '' | ||
ansible_sudo_pass: "{{ ansible_password }}" |
31 changes: 31 additions & 0 deletions
31
roles/oneagent/tests/integration/resources/ansible/hosts.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
all: | ||
children: | ||
unix: | ||
children: | ||
aix_ppc: | ||
hosts: {} | ||
vars: {} | ||
linux_arm: | ||
hosts: {} | ||
vars: {} | ||
linux_ppcle: | ||
hosts: {} | ||
vars: {} | ||
linux_s390: | ||
hosts: {} | ||
vars: {} | ||
linux_x86: | ||
hosts: {} | ||
vars: {} | ||
vars: | ||
ansible_become: true | ||
ansible_ssh_common_args: '-o StrictHostKeyChecking=no' | ||
windows: | ||
children: | ||
windows_x86: | ||
hosts: {} | ||
vars: {} | ||
vars: | ||
ansible_connection: winrm | ||
ansible_port: 5985 |
11 changes: 11 additions & 0 deletions
11
roles/oneagent/tests/integration/resources/ansible/oneagent.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Basic playbook | ||
hosts: all | ||
vars_files: | ||
- credentials.yml | ||
vars: {} | ||
collections: | ||
- dynatrace.oneagent | ||
tasks: | ||
- import_role: | ||
name: oneagent |
21 changes: 21 additions & 0 deletions
21
roles/oneagent/tests/integration/resources/installers/Dynatrace-OneAgent-Linux.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
readonly INSTALLER_VERSION='##VERSION##' | ||
readonly ONEAGENTCTL_BIN='oneagentctl' | ||
readonly ONEAGENTCTL_DIR='/opt/dynatrace/oneagent/agent/tools' | ||
|
||
deployOneagentCtl() { | ||
mkdir -p "${ONEAGENTCTL_DIR}" | ||
# Separate ctl logic | ||
chmod +x "${ONEAGENTCTL_DIR}/${ONEAGENTCTL_BIN}" | ||
} | ||
|
||
main() { | ||
deployOneagentCtl | ||
} | ||
|
||
################## | ||
## SCRIPT START ## | ||
################## | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ansible >= 2.14 | ||
Flask == 3.0.3 | ||
netifaces ~= 0.11.0 | ||
pytest ~= 8.2.1 | ||
pywinrm == 0.4.3 | ||
PyYAML ~= 6.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
|
||
readonly TEST_DIR='test_dir' | ||
readonly LOG_DIR="${TEST_DIR}/logs" | ||
readonly SERVER_LOG_FILE="${LOG_DIR}/server.log" | ||
|
||
prepareInstallerFiles() { | ||
local baseName='Dynatrace-OneAgent-Linux' | ||
local srcInstallerDir="resources/installers" | ||
local destInstallerDir="${TEST_DIR}/installers" | ||
|
||
printf 'Preparing installer files...\n' | ||
mkdir -p "${destInstallerDir}" | ||
cp "${srcInstallerDir}/${baseName}.sh" "${destInstallerDir}/${baseName}-1.0.0.sh" | ||
sed -i "s/##VERSION##/1.0.0/g" "${destInstallerDir}/${baseName}-1.0.0.sh" | ||
cp "${srcInstallerDir}/${baseName}.sh" "${destInstallerDir}/${baseName}-2.0.0.sh" | ||
sed -i "s/##VERSION##/2.0.0/g" "${destInstallerDir}/${baseName}-2.0.0.sh" | ||
} | ||
|
||
runServer() { | ||
local serverScript='scripts/server/server.py' | ||
|
||
printf 'Running server...\n' | ||
mkdir -p "${LOG_DIR}" | ||
PYTHONPATH='scripts' python "${serverScript}" >>"${SERVER_LOG_FILE}" 2>&1 & | ||
} | ||
|
||
runTests() { | ||
printf 'Running tests...\n' | ||
} | ||
|
||
main() { | ||
rm -rf "${TEST_DIR}" | ||
prepareInstallerFiles | ||
runServer | ||
runTests | ||
} | ||
|
||
################## | ||
## SCRIPT START ## | ||
################## | ||
main "${@}" |
Empty file.
Empty file.
26 changes: 26 additions & 0 deletions
26
roles/oneagent/tests/integration/scripts/command/command_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from abc import abstractmethod | ||
from pathlib import Path | ||
|
||
from util.test_data_types import CommandResult | ||
|
||
|
||
class CommandWrapper: | ||
@abstractmethod | ||
def get_file_content(self, address: str, file: Path) -> CommandResult: | ||
pass | ||
|
||
@abstractmethod | ||
def file_exists(self, address: str, file: Path) -> CommandResult: | ||
pass | ||
|
||
@abstractmethod | ||
def directory_exists(self, address: str, directory: Path) -> CommandResult: | ||
pass | ||
|
||
@abstractmethod | ||
def create_directory(self, address: str, directory: Path) -> CommandResult: | ||
pass | ||
|
||
@abstractmethod | ||
def run_command(self, address: str, command: str, *args: str) -> CommandResult: | ||
pass |
32 changes: 32 additions & 0 deletions
32
roles/oneagent/tests/integration/scripts/command/platform_command_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from pathlib import Path | ||
|
||
from command.command_wrapper import CommandWrapper | ||
from command.unix.unix_command_wrapper import UnixCommandWrapper | ||
from command.windows.windows_command_wrapper import WindowsCommandWrapper | ||
from util.test_data_types import DeploymentPlatform, CommandResult | ||
|
||
|
||
class PlatformCommandWrapper: | ||
def __init__(self, user: str, password: str): | ||
self.unix_command_wrapper = UnixCommandWrapper(user, password) | ||
self.windows_command_wrapper = WindowsCommandWrapper(user, password) | ||
|
||
def _get_command_wrapper(self, platform: DeploymentPlatform) -> CommandWrapper: | ||
if platform == DeploymentPlatform.WINDOWS_X86: | ||
return self.windows_command_wrapper | ||
return self.unix_command_wrapper | ||
|
||
def get_file_content(self, platform: DeploymentPlatform, address: str, file: Path) -> CommandResult: | ||
return self._get_command_wrapper(platform).get_file_content(address, file) | ||
|
||
def file_exists(self, platform: DeploymentPlatform, address: str, file: Path) -> CommandResult: | ||
return self._get_command_wrapper(platform).file_exists(address, file) | ||
|
||
def directory_exists(self, platform: DeploymentPlatform, address: str, directory: Path) -> CommandResult: | ||
return self._get_command_wrapper(platform).directory_exists(address, directory) | ||
|
||
def create_directory(self, platform: DeploymentPlatform, address: str, directory: Path) -> CommandResult: | ||
return self._get_command_wrapper(platform).create_directory(address, directory) | ||
|
||
def run_command(self, platform: DeploymentPlatform, address: str, command: str, *args: str) -> CommandResult: | ||
return self._get_command_wrapper(platform).run_command(address, command, *args) |
Empty file.
23 changes: 23 additions & 0 deletions
23
roles/oneagent/tests/integration/scripts/command/unix/unix_command_executor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import subprocess | ||
|
||
from util.test_data_types import CommandResult | ||
|
||
|
||
class UnixCommandExecutor: | ||
def __init__(self, user: str, password: str): | ||
self.user = user | ||
self.password = password | ||
|
||
def execute(self, address: str, command: str, *args: str) -> CommandResult: | ||
cmd = [ | ||
"sshpass", | ||
"-p", | ||
f"{self.password}", | ||
"ssh", | ||
"-o StrictHostKeyChecking=no", | ||
f"{self.user}@{address}", | ||
command, | ||
*args, | ||
] | ||
out = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=False) | ||
return CommandResult(out.returncode, out.stdout, out.stderr) |
26 changes: 26 additions & 0 deletions
26
roles/oneagent/tests/integration/scripts/command/unix/unix_command_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pathlib import Path | ||
|
||
from command.command_wrapper import CommandWrapper | ||
from command.unix.unix_command_executor import UnixCommandExecutor | ||
from util.test_data_types import CommandResult | ||
|
||
|
||
class UnixCommandWrapper(CommandWrapper): | ||
def __init__(self, user: str, password: str): | ||
self.password = password | ||
self.executor = UnixCommandExecutor(user, password) | ||
|
||
def get_file_content(self, address: str, file: Path) -> CommandResult: | ||
return self.executor.execute(address, "cat", str(file)) | ||
|
||
def file_exists(self, address: str, file: Path) -> CommandResult: | ||
return self.executor.execute(address, "test", "-f", str(file)) | ||
|
||
def directory_exists(self, address: str, directory: Path) -> CommandResult: | ||
return self.executor.execute(address, "test", "-d", str(directory)) | ||
|
||
def create_directory(self, address: str, directory: Path) -> CommandResult: | ||
return self.executor.execute(address, "mkdir", "-p", str(directory)) | ||
|
||
def run_command(self, address: str, command: str, *args: str) -> CommandResult: | ||
return self.executor.execute(address, f"echo {self.password} | sudo -S {command}", *args) |
Empty file.
14 changes: 14 additions & 0 deletions
14
roles/oneagent/tests/integration/scripts/command/windows/windows_command_executor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import winrm | ||
|
||
from util.test_data_types import CommandResult | ||
|
||
|
||
class WindowsCommandExecutor: | ||
def __init__(self, user: str, password: str): | ||
self.user = user | ||
self.password = password | ||
|
||
def execute(self, address: str, command: str, *args: str) -> CommandResult: | ||
session = winrm.Session(address, auth=(self.user, self.password)) | ||
out = session.run_cmd(command, args) | ||
return CommandResult(out.status_code, out.std_out.decode("utf-8"), out.std_err.decode("utf-8")) |
37 changes: 37 additions & 0 deletions
37
roles/oneagent/tests/integration/scripts/command/windows/windows_command_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
from command.command_wrapper import CommandWrapper | ||
from command.windows.windows_command_executor import WindowsCommandExecutor | ||
from util.test_data_types import CommandResult | ||
|
||
|
||
class WindowsCommandWrapper(CommandWrapper): | ||
def __init__(self, user: str, password: str): | ||
self.executor = WindowsCommandExecutor(user, password) | ||
|
||
def get_file_content(self, address: str, file: Path) -> CommandResult: | ||
return self.executor.execute(address, "type", str(file)) | ||
|
||
def file_exists(self, address: str, file: Path) -> CommandResult: | ||
# Windows needs double quoting for passing paths containing | ||
# containing spaces, single quotes don't work | ||
return self.executor.execute(address, f'if exist "{file}" (exit 0) else (exit 1)') | ||
|
||
def directory_exists(self, address: str, directory: Path) -> CommandResult: | ||
return self.executor.execute(address, f'if exist "{directory}\\*" (exit 0) else (exit 1)') | ||
|
||
def _run_directory_creation_command(self, address: str, directory: Path) -> CommandResult: | ||
result = CommandResult(0, "", "") | ||
if self.directory_exists(address, directory).returncode == 1: | ||
result = self.executor.execute(address, "md", str(directory)) | ||
return result | ||
|
||
def create_directory(self, address: str, directory: Path) -> CommandResult: | ||
for parent in list(directory.parents)[::-1][1::]: | ||
result = self._run_directory_creation_command(address, parent) | ||
if result.returncode != 0: | ||
return result | ||
return self._run_directory_creation_command(address, directory) | ||
|
||
def run_command(self, address: str, command: str, *args: str) -> CommandResult: | ||
return self.executor.execute(address, f'"{command}"', *args) |
Empty file.
28 changes: 28 additions & 0 deletions
28
roles/oneagent/tests/integration/scripts/server/server.key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDNT4UDQYcRV54F | ||
xMIp6u4fVVlpUV1IwAfpJ8Uw/qC2rCByVKJ1EnxWFM2mKKBYWMDzPL1zwfj2U429 | ||
4GRNbXqeTNk+G3ykRmBidYLW1lISKBtyHVnLes/sE4TUsqT8fuqpcUAudH65au6i | ||
t3OMmdrY5H9l8nxsBpvGtD8dggrw44fLWNLPfpRExJrj9UlqQHF9kYMzGiwuJRWE | ||
y7hs9CviBppvT57tXzXbBEkxyFsiPulSu0xm8w3u7Rt23gfivhJaq0kgoRMB5LfW | ||
zNLOKH3xCFM5eMVA5Tym0xCIxsilws4i3NHddzJDiarn7kN9HBLmNW1JI9pjMsHd | ||
brPnAVq3AgMBAAECggEBAMrMVGe970vLDxVFoEDFhUbACJyGOS2mOWot1ZMqwNcP | ||
uNEWFo6rntNsoyIQmSoLKTRaeAyCuo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/gVxqhL5aqoCMwFxESfCLddalv6w8ZQyf5hNGgnTBWog1P3sxP | ||
rJPH0BM86eMF7v0Mu0Wv9um681pKEWCpZkAp0dsJOtSnAhqlLWeCPUzS5zf0wEy4 | ||
7yk7lt5cP/NaDG4NNsG9MOKSISI= | ||
-----END PRIVATE KEY----- |
19 changes: 19 additions & 0 deletions
19
roles/oneagent/tests/integration/scripts/server/server.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDIzCCAgugAwIBAgIUJhfqy4q2EdPrvDXueL0lmnXMwtowDQYJKoZIhvcNAQEL | ||
BQAwITELMAkGA1UEBhMCUEwxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yMDExMDUx | ||
MTE5MzJaFw0zMDExMDMxMTE5MzJaMCExCzAJBgNVBAYTAlBMMRIwEAYDVQQDDAls | ||
b2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNT4UDQYcR | ||
V54FxMIp6u4fVVlpUV1IwAfpJ8Uw/qC2rCByVKJ1EnxWFM2mKKBYWMDzPL1zwfj2 | ||
U4294GRNbXqeTNk+G3ykRmBidYLW1lISKBtyHVnLes/sE4TUsqT8fuqpcUAudH65 | ||
au6it3OMmdrY5H9l8nxsBpvGtD8dggrw44fLWNLPfpRExJrj9UlqQHF9kYMzGiwu | ||
JRWEy7hs9CviBppvT57tXzXbBEkxyFsiPulSu0xm8w3u7Rt23gfivhJaq0kgoRMB | ||
5LfWzNLOKH3xCFM5eMVA5Tym0xCIxsilws4i3NHddzJDiarn7kN9HBLmNW1JI9pj | ||
MsHdbrPnAVq3AgMBAAGjUzBRMB0GA1UdDgQWBBRfvpPyXvcy61QjgVwGJYleMeLF | ||
pzAfBgNVHSMEGDAWgBRfvpP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