From 9da309f86ec9a69c57b3213fd6d14efbaae3794e Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 14 May 2024 18:57:59 +0200 Subject: [PATCH] Add agent fields into config file for system tests (#739) Add the current agent fields used to customize Elastic Agent in the spec for the configuration file of system tests. --- spec/changelog.yml | 3 + .../_dev/test/system/config.spec.yml | 122 ++++++++++++++++++ .../_dev/test/system/test-default-config.yml | 19 +++ .../agent/stream/stream.yml.hbs | 7 + .../elasticsearch/ingest_pipeline/default.yml | 10 ++ .../agent_settings/fields/base-fields.yml | 12 ++ .../data_stream/agent_settings/manifest.yml | 13 ++ test/packages/good_v3/manifest.yml | 6 +- 8 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 test/packages/good_v3/data_stream/agent_settings/_dev/test/system/test-default-config.yml create mode 100644 test/packages/good_v3/data_stream/agent_settings/agent/stream/stream.yml.hbs create mode 100644 test/packages/good_v3/data_stream/agent_settings/elasticsearch/ingest_pipeline/default.yml create mode 100644 test/packages/good_v3/data_stream/agent_settings/fields/base-fields.yml create mode 100644 test/packages/good_v3/data_stream/agent_settings/manifest.yml diff --git a/spec/changelog.yml b/spec/changelog.yml index d58a9df29..488a9382f 100644 --- a/spec/changelog.yml +++ b/spec/changelog.yml @@ -16,6 +16,9 @@ - description: Support store mapping option. type: enhancement link: https://github.com/elastic/package-spec/pull/748 + - description: Add agent settings definitions into configuration files for system tests. + type: enhancement + link: https://github.com/elastic/package-spec/pull/739 - version: 3.1.4 changes: - description: Add definitions for different deployment modes. diff --git a/spec/integration/data_stream/_dev/test/system/config.spec.yml b/spec/integration/data_stream/_dev/test/system/config.spec.yml index 2c2740209..496792b0c 100644 --- a/spec/integration/data_stream/_dev/test/system/config.spec.yml +++ b/spec/integration/data_stream/_dev/test/system/config.spec.yml @@ -23,3 +23,125 @@ spec: items: type: string example: "error.message" + agent: + description: "Configuration overrides for the Elastic Agent" + type: object + additionalProperties: true + properties: + runtime: + description: "Runtime to run the Elastic Agent process" + type: string + enum: + - docker + default: docker + user: + description: "User that runs the Elastic Agent process" + type: string + example: root + default: "" + pid_mode: + description: > + (From docker-compose docs) Turns on sharing between container and the host + operating system the PID address space + type: string + enum: + - host + ports: + description: "List of ports to be exposed to access to the Elastic Agent" + type: array + items: + type: string + description: Port to be exposed, as defined in https://docs.docker.com/compose/compose-file/compose-file-v2/#ports + examples: + - "3000" + - "8000:8000" + - "127.0.0.1:7443:7443" + - "8000:8000/udp" + linux_capabilities: + description: "Linux Capabilities that must been enabled in the system to run the Elastic Agent process" + type: array + items: + type: string + description: Capability name + # https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities + enum: + - AUDIT_CONTROL + - AUDIT_READ + - AUDIT_WRITE + - BLOCK_SUSPEND + - BPF + - CHECKPOINT_RESTORE + - CHOWN + - DAC_OVERRIDE + - DAC_READ_SEARCH + - FOWNER + - FSETID + - IPC_LOCK + - IPC_OWNER + - KILL + - LEASE + - LINUX_IMMUTABLE + - MAC_ADMIN + - MAC_OVERRIDE + - MKNOD + - NET_ADMIN + - NET_BIND_SERVICE + - NET_BROADCAST + - NET_RAW + - PERFORM + - SETFCAP + - SETGID + - SETPCAP + - SETUID + - SYS_ADMIN + - SYS_BOOT + - SYS_CHROOT + - SYS_MODULE + - SYS_NICE + - SYS_PACCT + - SYS_PTRACE + - SYS_RAWIO + - SYS_RESOURCE + - SYS_TIME + - SYS_TTY_CONFIG + - SYSLOG + - WAKE_ALARM + examples: + - AUDIT_CONTROL + - AUDIT_READ + provisioning_script: + description: "Optional: Custom script to be run to update environment where Elastic Agent runs (e.g. installing new libraries/dependencies)" + type: object + additionalProperties: false + properties: + language: + description: "Programming language to run the script." + type: string + examples: + - "sh" + - "bash" + - "python" + default: "sh" + contents: + description: "Contents of the script." + type: string + default: "" + required: + - contents + pre_start_script: + description: "Optional: Custom sh script to be run to set required changes for the Elastic Agent process (e.g. export environment variables)" + type: object + additionalProperties: false + properties: + language: + description: "Programming language to run the script. Currently, just supported \"sh\"." + type: string + enum: + - sh + default: sh + contents: + description: "Contents of the script." + type: string + default: "" + required: + - contents diff --git a/test/packages/good_v3/data_stream/agent_settings/_dev/test/system/test-default-config.yml b/test/packages/good_v3/data_stream/agent_settings/_dev/test/system/test-default-config.yml new file mode 100644 index 000000000..0a1614488 --- /dev/null +++ b/test/packages/good_v3/data_stream/agent_settings/_dev/test/system/test-default-config.yml @@ -0,0 +1,19 @@ +wait_for_data_timeout: 10m +vars: ~ +agent: + runtime: docker + user: root + pid_mode: host + linux_capabilities: + - AUDIT_CONTROL + ports: + - 127.0.0.0:8000:8000 + - 8888:8888 + provisioning_script: + language: bash + contents: | + mkdir -p /testfolder/ + pre_start_script: + language: sh + contents: | + export PATH=${PATH}:/testfolder/ diff --git a/test/packages/good_v3/data_stream/agent_settings/agent/stream/stream.yml.hbs b/test/packages/good_v3/data_stream/agent_settings/agent/stream/stream.yml.hbs new file mode 100644 index 000000000..5845510de --- /dev/null +++ b/test/packages/good_v3/data_stream/agent_settings/agent/stream/stream.yml.hbs @@ -0,0 +1,7 @@ +paths: +{{#each paths as |path i|}} + - {{path}} +{{/each}} +exclude_files: [".gz$"] +processors: + - add_locale: ~ diff --git a/test/packages/good_v3/data_stream/agent_settings/elasticsearch/ingest_pipeline/default.yml b/test/packages/good_v3/data_stream/agent_settings/elasticsearch/ingest_pipeline/default.yml new file mode 100644 index 000000000..1a308fded --- /dev/null +++ b/test/packages/good_v3/data_stream/agent_settings/elasticsearch/ingest_pipeline/default.yml @@ -0,0 +1,10 @@ +--- +description: Pipeline for processing sample logs +processors: +- set: + field: sample_field + value: "1" +on_failure: +- set: + field: error.message + value: '{{ _ingest.on_failure_message }}' diff --git a/test/packages/good_v3/data_stream/agent_settings/fields/base-fields.yml b/test/packages/good_v3/data_stream/agent_settings/fields/base-fields.yml new file mode 100644 index 000000000..7c798f453 --- /dev/null +++ b/test/packages/good_v3/data_stream/agent_settings/fields/base-fields.yml @@ -0,0 +1,12 @@ +- name: data_stream.type + type: constant_keyword + description: Data stream type. +- name: data_stream.dataset + type: constant_keyword + description: Data stream dataset. +- name: data_stream.namespace + type: constant_keyword + description: Data stream namespace. +- name: '@timestamp' + type: date + description: Event timestamp. diff --git a/test/packages/good_v3/data_stream/agent_settings/manifest.yml b/test/packages/good_v3/data_stream/agent_settings/manifest.yml new file mode 100644 index 000000000..7e1c929f5 --- /dev/null +++ b/test/packages/good_v3/data_stream/agent_settings/manifest.yml @@ -0,0 +1,13 @@ +title: "Agent Settings" +type: logs +streams: + - input: logfile + title: Sample logs + description: Collect sample logs + vars: + - name: paths + type: text + title: Paths + multi: true + default: + - /var/log/*.log diff --git a/test/packages/good_v3/manifest.yml b/test/packages/good_v3/manifest.yml index a57228237..20ebeee26 100644 --- a/test/packages/good_v3/manifest.yml +++ b/test/packages/good_v3/manifest.yml @@ -33,8 +33,7 @@ policy_templates: description: Collect logs and metrics from Apache instances deployment_modes: agentless: - enabled: - true + enabled: true inputs: - type: apache/metrics title: Collect metrics from Apache instances @@ -69,8 +68,7 @@ policy_templates: description: Collect logs and metrics from Apache instances in agentless deployment_modes: agentless: - enabled: - true + enabled: true inputs: - type: apache/metrics title: Collect metrics in agentless