Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnBoarding: Mysql test case #3476

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include:
- remote: https://gitlab-templates.ddbuild.io/libdatadog/include/single-step-instrumentation-tests.yml

stages:
- test_tracer
- ruby_tracer
- nodejs_tracer
- java_tracer
Expand Down Expand Up @@ -41,6 +42,26 @@ variables:
DD_INSTALLER_INJECTOR_VERSION:
description: "Set the version of the injector to be installed. Use the pipeline id pipeline-${CI_PIPELINE_ID}"

onboarding_mysql_test_case:
extends: .base_job_onboarding_system_tests
stage: test_tracer
allow_failure: true
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
- when: manual
variables:
TEST_LIBRARY: "nodejs"
SKIP_AMI_CACHE: "true"
parallel:
matrix:
- ONBOARDING_FILTER_WEBLOG: [test-app-mysql]
SCENARIO: [MYSQL_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

onboarding_nodejs:
extends: .base_job_onboarding_system_tests
stage: nodejs_tracer
Expand Down
23 changes: 23 additions & 0 deletions tests/auto_inject/test_auto_inject_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,26 @@ def test_install(self, virtual_machine):
logger.info(
f"Done test_install for : [{virtual_machine.name}][{virtual_machine.get_deployed_weblog().runtime_version}]"
)


@features.installer_auto_instrumentation
@scenarios.mysql_installer_auto_injection
class TestSimpleInstallerAutoInjectManual(base.AutoInjectBaseTest):
@parametrize_virtual_machines()
def test_mysql(self, virtual_machine):
logger.info(f"Launching test_mysql for : [{virtual_machine.name}] ...")
# uninstall SSI
self.execute_command(virtual_machine, "sudo datadog-installer apm uninstrument")
# Restart mysql
self.execute_command(virtual_machine, "sudo service mysql restart")
# The status of mysql should be OK
mysql_status = self.execute_command(virtual_machine, "sudo service mysql status")
assert " ERROR: ld.so: object" not in mysql_status, "The mysql service is reporting a ld.so error"
# install SSI
self.execute_command(virtual_machine, "sudo datadog-installer apm instrument")
# Restart mysql
self.execute_command(virtual_machine, "sudo service mysql restart")
# The status of mysql should be OK
mysql_status = self.execute_command(virtual_machine, "sudo service mysql status")
assert " ERROR: ld.so: object" not in mysql_status, "The mysql service is reporting a ld.so error"
logger.info(f"Done test_mysql for : [{virtual_machine.name}]")
1 change: 1 addition & 0 deletions tests/auto_inject/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def execute_command(self, virtual_machine, command):
vm_logger(context.scenario.name, virtual_machine.name).info(
f"{header} \n - COMMAND: \n {header} \n {command} \n\n {header} \n COMMAND OUTPUT \n\n {header} \n {command_output}"
)
return command_output

def _test_uninstall_commands(
self, virtual_machine, stop_weblog_command, start_weblog_command, uninstall_command, install_command
Expand Down
7 changes: 6 additions & 1 deletion utils/_context/_scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,12 @@ def all_endtoend_scenarios(test_object):
scenario_groups=[ScenarioGroup.ONBOARDING],
github_workflow="libinjection",
)

mysql_installer_auto_injection = InstallerAutoInjectionScenario(
"MYSQL_INSTALLER_AUTO_INJECTION",
"MySql test case scenario",
scenario_groups=[ScenarioGroup.ONBOARDING],
github_workflow="libinjection",
)
installer_auto_injection = InstallerAutoInjectionScenario(
"INSTALLER_AUTO_INJECTION",
doc="Installer auto injection scenario",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Installs the installer package
- os_type: linux
copy_files:
- name: copy-tracer-debug-config
local_path: utils/build/virtual_machine/provisions/auto-inject/tracer_debug/debug_config.yaml
- name: copy-docker-config
local_path: utils/build/virtual_machine/provisions/auto-inject/docker/docker_config.yaml

remote-command: |
if [ "${DD_env}" == "dev" ]; then
# To force the installer to pull from dev repositories -- agent config is set manually to datadoghq.com
export DD_SITE="datad0g.com"
export DD_INSTALLER_REGISTRY_URL='669783387624.dkr.ecr.us-east-1.amazonaws.com/dockerhub/datadog'
export DD_INSTALLER_REGISTRY_AUTH='ecr'
else
export DD_SITE="datadoghq.com"
fi

# Environment variables for the installer
export DD_APM_INSTRUMENTATION_ENABLED=all
export DD_APM_INSTRUMENTATION_LIBRARIES="java,js,python,ruby,dotnet"
export DD_INSTALLER_DEFAULT_PKG_INSTALL_DATADOG_AGENT=true

if [ -n "${DD_INSTALLER_LIBRARY_VERSION}" ]; then
export "DD_INSTALLER_REGISTRY_AUTH_APM_LIBRARY_$(echo "$DD_LANG" | tr "[:lower:]" "[:upper:]")_PACKAGE"='ecr'
export "DD_INSTALLER_REGISTRY_URL_APM_LIBRARY_$(echo "$DD_LANG" | tr "[:lower:]" "[:upper:]")_PACKAGE"='669783387624.dkr.ecr.us-east-1.amazonaws.com'
export "DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_LIBRARY_$(echo "$DD_LANG" | tr "[:lower:]" "[:upper:]")"="${DD_INSTALLER_LIBRARY_VERSION}"
fi

if [ -n "${DD_INSTALLER_INJECTOR_VERSION}" ]; then
export DD_INSTALLER_REGISTRY_AUTH_APM_INJECT_PACKAGE='ecr'
export DD_INSTALLER_REGISTRY_URL_APM_INJECT_PACKAGE='669783387624.dkr.ecr.us-east-1.amazonaws.com'
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_APM_INJECT="${DD_INSTALLER_INJECTOR_VERSION}"
fi

if [ -n "${DD_INSTALLER_AGENT_VERSION}" ]; then
export DD_INSTALLER_REGISTRY_AUTH_AGENT_PACKAGE='ecr'
export DD_INSTALLER_REGISTRY_URL_AGENT_PACKAGE='669783387624.dkr.ecr.us-east-1.amazonaws.com'
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_AGENT="${DD_INSTALLER_AGENT_VERSION}"
fi

if [ -n "${DD_INSTALLER_INSTALLER_VERSION}" ]; then
export DD_INSTALLER_REGISTRY_AUTH_INSTALLER_PACKAGE='ecr'
export DD_INSTALLER_REGISTRY_URL_INSTALLER_PACKAGE='669783387624.dkr.ecr.us-east-1.amazonaws.com'
export DD_INSTALLER_DEFAULT_PKG_VERSION_DATADOG_INSTALLER="${DD_INSTALLER_INSTALLER_VERSION}"
fi

# Env variables set on the scenario definition. Write to file and load
SCENARIO_AGENT_ENV="${DD_AGENT_ENV:-''}"
echo "${SCENARIO_AGENT_ENV}" > scenario_agent.env
echo "AGENT VARIABLES CONFIGURED FROM THE SCENARIO:"
cat scenario_agent.env
export $(cat scenario_agent.env | xargs)

sudo -E sh -c "sudo mkdir -p /etc/datadog-agent && printf \"api_key: ${DD_API_KEY}\nsite: datadoghq.com\n\" > /etc/datadog-agent/datadog.yaml"
DD_REPO_URL=${DD_injection_repo_url} bash -c "$(curl -L https://install.datadoghq.com/scripts/install_script_agent7.sh)"

sudo cp /tmp/datadog-installer-*.log /var/log/datadog

sudo mkdir -p /etc/datadog-agent/inject
sudo cp docker_config.yaml /etc/datadog-agent/inject/docker_config.yaml
sudo cp debug_config.yaml /etc/datadog-agent/inject/debug_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Optional: Load the environment variables
init-environment: !include utils/build/virtual_machine/provisions/auto-inject/auto-inject-environment.yml

# Mandatory: Scripts to extract the installed/tested components (json {component1:version, component2:version})
tested_components:
install: !include utils/build/virtual_machine/provisions/auto-inject/auto-inject-tested_components.yml

#Optional: Extract the logs from the VM
vm_logs:
install: !include utils/build/virtual_machine/provisions/auto-inject/auto-inject-vm_logs.yml

# Mandatory: Steps to provision VM
provision_steps:
- init-config # Init the VM configuration
- prepare-docker # Install docker
- amazon-ecr-credential-helper # Install AWS ECR helper to download images from ECR
- patch-docker-daemon #Patch the docker daemon to avoid networking issues/ip conflicts incident-31160
- pre-install-installer # we install only the installer and we cached it. The goal is to force download the required deps for the installer and cache them
- install-installer-all-langs # Install the installer

init-config:
cache: true
populate_env: false
install: !include utils/build/virtual_machine/provisions/auto-inject/auto-inject_init_vm_config.yml

prepare-docker:
cache: true
install: !include utils/build/virtual_machine/provisions/auto-inject/docker/auto-inject_prepare_docker.yml

amazon-ecr-credential-helper:
cache: true
install: !include utils/build/virtual_machine/provisions/auto-inject/docker/amazon-ecr-credential-helper.yml

patch-docker-daemon:
cache: true
install: !include utils/build/virtual_machine/provisions/auto-inject/docker/patch-docker-daemon.yml

pre-install-installer:
cache: true
install: !include utils/build/virtual_machine/provisions/auto-inject/auto-inject_pre_installer_manual.yml

install-installer-all-langs:
install: !include utils/build/virtual_machine/provisions/auto-inject/auto-inject_installer_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
lang_variant:
name: nodejs
version: default
cache: true
install:
- os_type: linux
os_distro: deb
remote-command: |
export DD_APM_INSTRUMENTATION_DEBUG=TRUE
export DD_INSTRUMENT_SERVICE_WITH_APM=TRUE
export DD_APM_INSTRUMENTATION_ENABLED=all
sudo -E apt-get install -y nodejs
sudo -E apt-get -y update && sudo -E apt-get -y install default-jdk
sudo -E apt-get -y install python3
sudo add-apt-repository -y ppa:dotnet/backports
sudo -E apt-get update
sudo -E apt-get install -y dotnet-sdk-6.0
sudo -E apt-get install -y dotnet-runtime-6.0

weblog:
name: test-app-mysql
exact_os_branches: [ubuntu24]
install:
- os_type: linux
remote-command: |
export DD_APM_INSTRUMENTATION_DEBUG=TRUE
sudo apt install -y mysql-server
sudo service mysql status
Loading