Skip to content

Commit

Permalink
group scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
robertomonteromiguel committed Oct 29, 2024
1 parent 5d332cc commit 2685c65
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 106 deletions.
80 changes: 6 additions & 74 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include:

stages:
- extravms_tracer
- chaos_tracer
- ruby_tracer
- nodejs_tracer
- java_tracer
Expand Down Expand Up @@ -86,9 +85,6 @@ onboarding_nodejs:
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-nodejs]
SCENARIO: [HOST_AUTO_INJECTION_INSTALL_SCRIPT_PROFILING]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-shell-script]
SCENARIO: [INSTALLER_AUTO_INJECTION_BLOCK_LIST]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-nodejs-multicontainer]
SCENARIO: [ CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT_PROFILING]
Expand All @@ -100,41 +96,10 @@ onboarding_nodejs:
SCENARIO: [INSTALLER_NOT_SUPPORTED_AUTO_INJECTION]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-nodejs]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-nodejs]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
script:
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV}


onboarding_CHAOS:
extends: .base_job_onboarding_system_tests
stage: chaos_tracer
allow_failure: true
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
- when: manual
variables:
TEST_LIBRARY: "java"
parallel:
matrix:
- ONBOARDING_FILTER_ENV: [prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
- ONBOARDING_FILTER_ENV: [prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java]
SCENARIO: [CHAOS_INSTALLER_AUTO_INJECTION]
script:
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV} --vm-only-branch ubuntu22_amd64

- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV}

onboarding_java:
extends: .base_job_onboarding_system_tests
Expand All @@ -152,12 +117,6 @@ onboarding_java:
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java]
SCENARIO: [HOST_AUTO_INJECTION_INSTALL_SCRIPT_PROFILING]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-shell-script]
SCENARIO: [INSTALLER_AUTO_INJECTION_BLOCK_LIST]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java-multicontainer]
SCENARIO: [CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java-multicontainer]
SCENARIO: [CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT_PROFILING]
Expand All @@ -169,10 +128,7 @@ onboarding_java:
SCENARIO: [SIMPLE_AUTO_INJECTION_PROFILING]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-java]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
SCENARIO: [CHAOS_INSTALLER_AUTO_INJECTION]
script:
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV}
Expand All @@ -193,9 +149,6 @@ onboarding_python:
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-python]
SCENARIO: [HOST_AUTO_INJECTION_INSTALL_SCRIPT]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-shell-script]
SCENARIO: [INSTALLER_AUTO_INJECTION_BLOCK_LIST]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-python-container,test-app-python-alpine]
SCENARIO: [ CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT]
Expand All @@ -208,10 +161,7 @@ onboarding_python:
SCENARIO: [INSTALLER_AUTO_INJECTION]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-python]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-python]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
SCENARIO: [CHAOS_INSTALLER_AUTO_INJECTION]
script:
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV}
Expand All @@ -232,9 +182,6 @@ onboarding_dotnet:
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-dotnet]
SCENARIO: [HOST_AUTO_INJECTION_INSTALL_SCRIPT_PROFILING]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-shell-script]
SCENARIO: [INSTALLER_AUTO_INJECTION_BLOCK_LIST]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-dotnet-container]
SCENARIO: [ CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT_PROFILING]
Expand All @@ -243,10 +190,7 @@ onboarding_dotnet:
SCENARIO: [INSTALLER_AUTO_INJECTION, SIMPLE_AUTO_INJECTION_PROFILING]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-dotnet]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-dotnet]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
SCENARIO: [CHAOS_INSTALLER_AUTO_INJECTION]
script:
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV}
Expand All @@ -267,9 +211,6 @@ onboarding_ruby:
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-ruby]
SCENARIO: [HOST_AUTO_INJECTION_INSTALL_SCRIPT]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-shell-script]
SCENARIO: [INSTALLER_AUTO_INJECTION_BLOCK_LIST]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-ruby-container]
SCENARIO: [ CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT]
Expand All @@ -278,10 +219,7 @@ onboarding_ruby:
SCENARIO: [INSTALLER_AUTO_INJECTION]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-ruby]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-ruby]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
SCENARIO: [CHAOS_INSTALLER_AUTO_INJECTION]
script:
- ./build.sh -i runner
- timeout 2700s ./run.sh $SCENARIO --vm-weblog ${ONBOARDING_FILTER_WEBLOG} --vm-env ${ONBOARDING_FILTER_ENV} --vm-library ${TEST_LIBRARY} --vm-provider aws --report-run-url ${CI_PIPELINE_URL} --report-environment ${ONBOARDING_FILTER_ENV}
Expand All @@ -302,9 +240,6 @@ onboarding_php:
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-php]
SCENARIO: [HOST_AUTO_INJECTION_INSTALL_SCRIPT]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-shell-script]
SCENARIO: [INSTALLER_AUTO_INJECTION_BLOCK_LIST]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-php-container-83,test-app-php-container-alpine]
SCENARIO: [CONTAINER_AUTO_INJECTION_INSTALL_SCRIPT]
Expand All @@ -313,10 +248,7 @@ onboarding_php:
SCENARIO: [INSTALLER_AUTO_INJECTION]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-php]
SCENARIO: [INSTALLER_AUTO_INJECTION_LD_PRELOAD]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-php]
SCENARIO: [INSTALLER_HOST_AUTO_INJECTION_CHAOS]
SCENARIO: [CHAOS_INSTALLER_AUTO_INJECTION]
- ONBOARDING_FILTER_ENV: [dev, prod]
ONBOARDING_FILTER_WEBLOG: [test-app-php-container-56]
SCENARIO: [INSTALLER_NOT_SUPPORTED_AUTO_INJECTION]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from utils import scenarios, context, features
from utils.tools import logger
from utils import irrelevant
from utils.onboarding.injection_log_parser import command_injection_skipped
from utils.virtual_machine.utils import parametrize_virtual_machines

Expand Down Expand Up @@ -49,7 +48,7 @@ def _execute_remote_command(self, ssh_client, command, config={}, use_injection_

unique_log_name = f"host_injection_{uuid.uuid4()}.log"

command_with_config = f"DD_APM_INSTRUMENTATION_OUTPUT_PATHS=/var/log/datadog_weblog/{unique_log_name} {command}"
command_with_config = f"DD_APM_INSTRUMENTATION_DEBUG=TRUE DD_APM_INSTRUMENTATION_OUTPUT_PATHS=/var/log/datadog_weblog/{unique_log_name} {command}"
if use_injection_config:
# Use yml template and replace the key DD_<lang>_IGNORED_ARGS with the value of the config
test_conf_content = self.yml_config_template
Expand All @@ -65,7 +64,7 @@ def _execute_remote_command(self, ssh_client, command, config={}, use_injection_

# Write as local file and the copy by scp to user home. by ssh copy the file to /etc/datadog-agent/inject
file_name = f"host_config_{uuid.uuid4()}.yml"
temp_file_path = scenarios.installer_auto_injection_block_list.host_log_folder + "/" + file_name
temp_file_path = context.scenario.host_log_folder + "/" + file_name
with open(temp_file_path, "w") as host_config_file:
host_config_file.write(test_conf_content)
SCPClient(ssh_client.get_transport()).put(temp_file_path, file_name)
Expand All @@ -82,8 +81,7 @@ def _execute_remote_command(self, ssh_client, command, config={}, use_injection_
command_with_config = f"{key}='{config[key]}' {command_with_config}"

logger.info(f"Executing command: [{command_with_config}] associated with log file: [{unique_log_name}]")

log_local_path = scenarios.installer_auto_injection_block_list.host_log_folder + f"/{unique_log_name}"
log_local_path = context.scenario.host_log_folder + f"/{unique_log_name}"

_, stdout, stderr = ssh_client.exec_command(command_with_config)
logger.info("Command output:")
Expand All @@ -92,15 +90,23 @@ def _execute_remote_command(self, ssh_client, command, config={}, use_injection_
logger.info(stderr.readlines())

scp = SCPClient(ssh_client.get_transport())

scp.get(
remote_path=f"/var/log/datadog_weblog/{unique_log_name}", local_path=log_local_path,
)

return log_local_path


@features.host_user_managed_block_list
@scenarios.installer_auto_injection_block_list
class TestAutoInjectBlockListInstallManualHost(_AutoInjectBlockListBaseTest):
def test_deprecated(self):
logger.info("Test deprecated")
pass


@features.host_user_managed_block_list
@scenarios.installer_auto_injection
class TestAutoInjectBlockListInstallManualHost(_AutoInjectBlockListBaseTest):

buildIn_args_commands_block = {
Expand Down Expand Up @@ -218,11 +224,6 @@ class TestAutoInjectBlockListInstallManualHost(_AutoInjectBlockListBaseTest):
],
}

@irrelevant(
condition="datadog-apm-inject" not in context.scenario.components
or context.scenario.components["datadog-apm-inject"] < "0.12.4",
reason="Block list not fully implemented ",
)
@parametrize_virtual_machines(
bugs=[
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
Expand All @@ -232,18 +233,12 @@ class TestAutoInjectBlockListInstallManualHost(_AutoInjectBlockListBaseTest):
)
def test_builtIn_block_commands(self, virtual_machine):
""" Check that commands are skipped from the auto injection. This commands are defined on the buildIn processes to block """

logger.info(f"[{virtual_machine.get_ip()}] Executing commands that should be blocked")
ssh_client = virtual_machine.ssh_config.get_ssh_connection()

for command in self.buildIn_commands_not_injected:
local_log_file = self._execute_remote_command(ssh_client, command)
assert command_injection_skipped(command, local_log_file), f"The command {command} was instrumented!"

@irrelevant(
condition="datadog-apm-inject" not in context.scenario.components
or context.scenario.components["datadog-apm-inject"] < "0.12.4",
reason="Block list not fully implemented ",
)
@parametrize_virtual_machines(
bugs=[
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
Expand All @@ -260,11 +255,6 @@ def test_builtIn_block_args(self, virtual_machine):
local_log_file = self._execute_remote_command(ssh_client, command)
assert command_injection_skipped(command, local_log_file), f"The command {command} was instrumented!"

@irrelevant(
condition="datadog-apm-inject" not in context.scenario.components
or context.scenario.components["datadog-apm-inject"] < "0.12.4",
reason="Block list not fully implemented ",
)
@parametrize_virtual_machines(
bugs=[
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
Expand All @@ -290,11 +280,6 @@ def _create_remote_executable_script(self, ssh_client, script_path, content="#!/
stdout.channel.set_combine_stderr(True)
output = stdout.readlines()

@irrelevant(
condition="datadog-apm-inject" not in context.scenario.components
or context.scenario.components["datadog-apm-inject"] < "0.12.4",
reason="Block list not fully implemented ",
)
@parametrize_virtual_machines(
bugs=[
{"vm_branch": "amazon_linux2", "library": "ruby", "reason": "INPLAT-103"},
Expand All @@ -304,6 +289,7 @@ def _create_remote_executable_script(self, ssh_client, script_path, content="#!/
)
def test_user_ignored_args(self, virtual_machine):
""" Check that we are not instrumenting the lang commands (java,ruby,dotnet,python,php) that match with args set by DD_<LANG>_IGNORED_ARGS env variable"""
logger.info(f"[{virtual_machine.get_ip()}] Testing args ignored by user")
language = context.scenario.library.library
if language in self.user_args_commands:
ssh_client = virtual_machine.ssh_config.get_ssh_connection()
Expand Down
7 changes: 3 additions & 4 deletions utils/_context/_scenarios/auto_injection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import re
import json
from utils._context.library_version import LibraryVersion
from utils.tools import logger
Expand Down Expand Up @@ -313,8 +312,8 @@ def customize_feature_parity_dashboard(self, result):
for test in result["tests"]:
if vm.name in test["description"]:
new_test = test.copy()
new_test["description"] = re.sub("[\[].*?[\]]", "", new_test["description"])
new_test["path"] = re.sub("[\[].*?[\]]", "", new_test["path"])
new_test["description"] = new_test["description"].split("[", 1)[0]
new_test["path"] = new_test["path"].split("[", 1)[0]
new_result["tests"].append(new_test)
with open(f"{self.host_log_folder}/{vm.name}_feature_parity.json", "w", encoding="utf-8") as f:
json.dump(new_result, f, indent=2)
Expand Down Expand Up @@ -349,7 +348,7 @@ def __init__(
include_ubuntu_23_10_arm64=True,
include_ubuntu_24_amd64=True,
include_ubuntu_24_arm64=True,
include_ubuntu_18_amd64=True,
include_ubuntu_18_amd64=False,
include_amazon_linux_2_amd64=True,
include_amazon_linux_2_arm64=True,
include_amazon_linux_2023_amd64=True,
Expand Down

0 comments on commit 2685c65

Please sign in to comment.