Skip to content

Commit

Permalink
* Adapt output file name to latest beats changes.
Browse files Browse the repository at this point in the history
This fixes the tests for beats when checking for the output files.
Relates to changes from elastic/beats#28927
Add output ndjson suffix to APM Server output (unclear why this is necessary).

* Increase timeout for output file and ensure it is written.

The output file is only written when some actual values are processed. Enable
self-instrumentation for APM to ensure the output file is written and increase
timeout. For beats, enable metrics logging explicitly.
  • Loading branch information
simitt committed Jan 5, 2022
1 parent 1b27954 commit 6ff119b
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions roles/test-beat/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ beat_home_path: '{{ installdir }}'
beat_config_path: '{{ installdir }}'
beat_data_path: '{{ installdir }}/data'
beat_logs_path: '{{ installdir }}/logs'
beat_file_suffix: '-{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}.ndjson'

beat_service_name: '{{ beat_name }}'
registry_file: ''
2 changes: 1 addition & 1 deletion roles/test-beat/tasks/darwin/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
wait_for:
path: '{{ beat_output_file }}'
search_regex: '"version"'
timeout: 20
timeout: 45

- name: 'Fetch metrics from {{ beat_name }} over HTTP'
get_url:
Expand Down
2 changes: 1 addition & 1 deletion roles/test-beat/tasks/linux/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
wait_for:
path: '{{ beat_output_file }}'
search_regex: '"version"'
timeout: 20
timeout: 45

- name: 'Fetch metrics from {{ beat_name }} over HTTP'
get_url:
Expand Down
4 changes: 2 additions & 2 deletions roles/test-beat/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
- name: Set config/output/log file vars
set_fact:
beat_config_file: '{{ beat_config_path}}/{{ beat_name }}.yml'
beat_output_file: '{{ beat_logs_path }}/output.json'
beat_log_file: '{{ beat_logs_path }}/{{ beat_name }}.json'
beat_output_file: '{{ beat_logs_path }}/output.json{{ beat_file_suffix }}'
beat_log_file: '{{ beat_logs_path }}/{{ beat_name }}.json{{ beat_file_suffix }}'
beat_registry_file: '{{ beat_data_path }}/{{ registry_file }}'
beat_metrics_file: '{{ beat_logs_path }}/metrics.json'

Expand Down
10 changes: 8 additions & 2 deletions roles/test-beat/templates/apm-server.yml.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
apm-server:
kibana:
enabled: true

logging:
level: info
json: true
to_files: true
files:
name: apm-server.json
name: '{{ beat_name }}.json-{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}.ndjson'
metrics:
enabled: true
output.file:
path: '${path.logs}'
filename: output.json
filename: 'output.json-{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}.ndjson'
http.host: localhost
instrumentation.enabled: true
4 changes: 3 additions & 1 deletion roles/test-beat/templates/auditbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ logging:
to_files: true
files:
name: {{ beat_name }}.json
metrics:
enabled: true

http.host: localhost
http.host: localhost
4 changes: 3 additions & 1 deletion roles/test-beat/templates/filebeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ logging:
to_files: true
files:
name: {{ beat_name }}.json
metrics:
enabled: true

http.host: localhost
http.host: localhost
4 changes: 3 additions & 1 deletion roles/test-beat/templates/heartbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ logging:
to_files: true
files:
name: {{ beat_name }}.json
metrics:
enabled: true

http.host: localhost
http.host: localhost
4 changes: 3 additions & 1 deletion roles/test-beat/templates/metricbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ logging:
to_files: true
files:
name: {{ beat_name }}.json
metrics:
enabled: true

http.host: localhost
http.host: localhost
2 changes: 2 additions & 0 deletions roles/test-beat/templates/packetbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ logging:
to_files: true
files:
name: {{ beat_name }}.json
metrics:
enabled: true

http.host: localhost
4 changes: 3 additions & 1 deletion roles/test-beat/templates/winlogbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ logging:
to_files: true
files:
name: {{ beat_name }}.json
metrics:
enabled: true

http.host: localhost
http.host: localhost
22 changes: 11 additions & 11 deletions roles/test-linux-binary/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@
shell: wget google.com
when: beat_name == "packetbeat"

- name: Wait for the output file to be created, should contain type=http
wait_for: >
path={{workdir}}/output/packetbeat timeout=5
search_regex='"type":"http"'
when: beat_name == "packetbeat"
# - name: Wait for the output file to be created, should contain type=http
# wait_for: >
# path={{workdir}}/output/packetbeat{{ beat_file_suffix }} timeout=5
# search_regex='"type":"http"'
# when: beat_name == "packetbeat"

- name: Wait for the output file to be created, should contain system load
wait_for: >
path={{workdir}}/output/{{beat_name}} timeout=5
path={{workdir}}/output/{{beat_name}}{{ beat_file_suffix }} timeout=20
search_regex='"load"'
when: beat_name == "metricbeat"

- name: Wait for the output file to be created, should contain HTTP pinging
wait_for: >
path={{workdir}}/output/heartbeat timeout=5
search_regex='"scheme":"http"'
when: beat_name == "heartbeat"
# - name: Wait for the output file to be created, should contain HTTP pinging
# wait_for: >
# path={{workdir}}/output/heartbeat{{ beat_file_suffix }} timeout=5
# search_regex='"scheme":"http"'
# when: beat_name == "heartbeat"

- name: Check if version number is correct
shell: chdir={{installdir}} ./{{beat_name}} version | grep {{ version[0:5] }}

0 comments on commit 6ff119b

Please sign in to comment.