-
Notifications
You must be signed in to change notification settings - Fork 6.8k
210 lines (167 loc) · 7.45 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: CI
on:
push:
branches: [ release-7.x ]
pull_request:
branches: [ release-7.x ]
jobs:
test:
name: Test suite
# List of supported runners:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
runs-on: ubuntu-22.04
env:
COMPOSE_PROJECT_NAME: docker-elk
steps:
- uses: actions/checkout@v3
#####################################################
# #
# Install all dependencies required by test suites. #
# #
#####################################################
- name: Pre-build container images
run: >-
docker compose
-f docker-compose.yml
-f extensions/logspout/logspout-compose.yml
-f extensions/fleet/fleet-compose.yml
-f extensions/fleet/agent-apmserver-compose.yml
-f extensions/metricbeat/metricbeat-compose.yml
-f extensions/filebeat/filebeat-compose.yml
-f extensions/heartbeat/heartbeat-compose.yml
-f extensions/enterprise-search/enterprise-search-compose.yml
build
########################################################
# #
# Ensure §"Initial setup" of the README remains valid. #
# #
########################################################
- name: Set password of every built-in user to 'testpasswd'
run: |
sed -i -e 's/\(ELASTIC_PASSWORD=\)'\''changeme'\''/\1testpasswd/g' \
-e 's/\(LOGSTASH_INTERNAL_PASSWORD=\)'\''changeme'\''/\1testpasswd/g' \
-e 's/\(KIBANA_SYSTEM_PASSWORD=\)'\''changeme'\''/\1testpasswd/g' \
-e 's/\(METRICBEAT_INTERNAL_PASSWORD=\)'\'\''/\1testpasswd/g' \
-e 's/\(FILEBEAT_INTERNAL_PASSWORD=\)'\'\''/\1testpasswd/g' \
-e 's/\(HEARTBEAT_INTERNAL_PASSWORD=\)'\'\''/\1testpasswd/g' \
-e 's/\(MONITORING_INTERNAL_PASSWORD=\)'\'\''/\1testpasswd/g' \
-e 's/\(BEATS_SYSTEM_PASSWORD=\)'\'\''/\1testpasswd/g' .env
##########################################################
# #
# Test core components: Elasticsearch, Logstash, Kibana. #
# #
##########################################################
- name: Run the stack
run: |
docker compose up setup
docker compose up -d
- name: Execute core test suite
run: .github/workflows/scripts/run-tests-core.sh
##############################
# #
# Test supported extensions. #
# #
##############################
#
# Logspout
#
- name: Execute Logspout test suite
run: |
# Set mandatory Logstash settings
sed -i '$ a input { udp { port => 50000 codec => json } }' logstash/pipeline/logstash.conf
# Restart Logstash for changes to take effect
docker compose restart logstash
# Run Logspout and execute tests.
docker compose -f docker-compose.yml -f extensions/logspout/logspout-compose.yml up --remove-orphans -d logspout
.github/workflows/scripts/run-tests-logspout.sh
# Revert changes to Logstash configuration
sed -i '/input { udp { port => 50000 codec => json } }/d' logstash/pipeline/logstash.conf
docker compose restart logstash
# next steps don't need Logstash
docker compose stop logstash
#
# Fleet
#
- name: Execute Fleet test suite
run: |
docker compose -f docker-compose.yml -f extensions/fleet/fleet-compose.yml -f extensions/fleet/agent-apmserver-compose.yml up --remove-orphans -d fleet-server apm-server
.github/workflows/scripts/run-tests-fleet.sh
#
# Metricbeat
#
- name: Execute Metricbeat test suite
run: |
docker compose -f docker-compose.yml -f extensions/metricbeat/metricbeat-compose.yml up --remove-orphans -d metricbeat
.github/workflows/scripts/run-tests-metricbeat.sh
#
# Filebeat
#
- name: Execute Filebeat test suite
run: |
docker compose -f docker-compose.yml -f extensions/filebeat/filebeat-compose.yml up --remove-orphans -d filebeat
.github/workflows/scripts/run-tests-filebeat.sh
#
# Heartbeat
#
- name: Execute Heartbeat test suite
run: |
docker compose -f docker-compose.yml -f extensions/heartbeat/heartbeat-compose.yml up --remove-orphans -d heartbeat
.github/workflows/scripts/run-tests-heartbeat.sh
#
# Enterprise Search
#
- name: Execute Enterprise Search test suite
run: |
sed -i 's/\(secret_management.encryption_keys:\)/\1 [test-encrypt]/g' extensions/enterprise-search/config/enterprise-search.yml
docker compose -f docker-compose.yml -f extensions/enterprise-search/enterprise-search-compose.yml up --remove-orphans -d enterprise-search
.github/workflows/scripts/run-tests-enterprise-search.sh
- name: Collect troubleshooting data
id: debug-data
if: failure()
run: |
declare debug_data_dir="$(mktemp -d)"
docker compose \
-f docker-compose.yml \
-f extensions/logspout/logspout-compose.yml \
-f extensions/fleet/fleet-compose.yml \
-f extensions/fleet/agent-apmserver-compose.yml \
-f extensions/metricbeat/metricbeat-compose.yml \
-f extensions/filebeat/filebeat-compose.yml \
-f extensions/heartbeat/heartbeat-compose.yml \
-f extensions/enterprise-search/enterprise-search-compose.yml \
ps >"$debug_data_dir"/docker_ps.log
docker compose \
-f docker-compose.yml \
-f extensions/logspout/logspout-compose.yml \
-f extensions/fleet/fleet-compose.yml \
-f extensions/fleet/agent-apmserver-compose.yml \
-f extensions/metricbeat/metricbeat-compose.yml \
-f extensions/filebeat/filebeat-compose.yml \
-f extensions/heartbeat/heartbeat-compose.yml \
-f extensions/enterprise-search/enterprise-search-compose.yml \
logs >"$debug_data_dir"/docker_logs.log
echo "path=${debug_data_dir}" >>"$GITHUB_OUTPUT"
- name: Upload collected troubleshooting data
if: always() && steps.debug-data.outputs.path
uses: actions/upload-artifact@v3
with:
name: debug-data
path: ${{ steps.debug-data.outputs.path }}/*.*
##############
# #
# Tear down. #
# #
##############
- name: Terminate all components
if: always()
run: >-
docker compose
-f docker-compose.yml
-f extensions/logspout/logspout-compose.yml
-f extensions/fleet/fleet-compose.yml
-f extensions/fleet/agent-apmserver-compose.yml
-f extensions/metricbeat/metricbeat-compose.yml
-f extensions/filebeat/filebeat-compose.yml
-f extensions/heartbeat/heartbeat-compose.yml
-f extensions/enterprise-search/enterprise-search-compose.yml
down -v