-
Notifications
You must be signed in to change notification settings - Fork 258
/
Makefile
528 lines (418 loc) · 21.5 KB
/
Makefile
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
SHELL := /bin/bash
IMAGE_VERSION ?= "latest"
NONQUOTE_IMAGE_VERSION := $(patsubst "%",%,$(IMAGE_VERSION))
DOCKER_BUILD_FLAGS ?=
SPLUNK_ANSIBLE_REPO ?= https://github.com/splunk/splunk-ansible.git
SPLUNK_ANSIBLE_BRANCH ?= develop
SPLUNK_COMPOSE ?= cluster_absolute_unit.yaml
# Set Splunk version/build parameters here to define downstream URLs and file names
SPLUNK_PRODUCT := splunk
SPLUNK_VERSION := 9.4.0
SPLUNK_BUILD := 6b4ebe426ca6
ifeq ($(shell arch), s390x)
SPLUNK_ARCH = s390x
else
SPLUNK_ARCH = amd64
endif
# Linux Splunk arguments
SPLUNK_LINUX_FILENAME ?= splunk-${SPLUNK_VERSION}-${SPLUNK_BUILD}-linux-${SPLUNK_ARCH}.tgz
SPLUNK_LINUX_BUILD_URL ?= https://download.splunk.com/products/${SPLUNK_PRODUCT}/releases/${SPLUNK_VERSION}/linux/${SPLUNK_LINUX_FILENAME}
UF_LINUX_FILENAME ?= splunkforwarder-${SPLUNK_VERSION}-${SPLUNK_BUILD}-linux-${SPLUNK_ARCH}.tgz
UF_LINUX_BUILD_URL ?= https://download.splunk.com/products/universalforwarder/releases/${SPLUNK_VERSION}/linux/${UF_LINUX_FILENAME}
# Windows Splunk arguments
SPLUNK_WIN_FILENAME ?= splunk-${SPLUNK_VERSION}-${SPLUNK_BUILD}-x64-release.msi
SPLUNK_WIN_BUILD_URL ?= https://download.splunk.com/products/${SPLUNK_PRODUCT}/releases/${SPLUNK_VERSION}/windows/${SPLUNK_WIN_FILENAME}
UF_WIN_FILENAME ?= splunkforwarder-${SPLUNK_VERSION}-${SPLUNK_BUILD}-x64-release.msi
UF_WIN_BUILD_URL ?= https://download.splunk.com/products/universalforwarder/releases/${SPLUNK_VERSION}/windows/${UF_WIN_FILENAME}
# Security Scanner Variables
SCANNER_DATE := `date +%Y-%m-%d`
SCANNER_DATE_YEST := `TZ=GMT+24 +%Y:%m:%d`
SCANNER_VERSION := v8
SCANNER_LOCALIP := $(shell ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | awk '{print $1}' | head -n 1)
SCANNER_IMAGES_TO_SCAN := splunk-debian-9 splunk-debian-10 splunk-centos-7 splunk-redhat-8 uf-debian-9 uf-debian-10 uf-centos-7 uf-redhat-8 splunk-py23-debian-9 splunk-py23-debian-10 splunk-py23-centos-7 splunk-py23-redhat-8 uf-py23-debian-9 uf-py23-debian-10 uf-py23-centos-7 uf-py23-redhat-8
CONTAINERS_TO_SAVE := splunk-debian-9 splunk-debian-10 splunk-centos-7 splunk-redhat-8 uf-debian-9 uf-debian-10 uf-centos-7 uf-redhat-8 splunk-py23-debian-9 splunk-py23-debian-10 splunk-py23-centos-7 splunk-py23-redhat-8 uf-py23-debian-9 uf-py23-debian-10 uf-py23-centos-7 uf-py23-redhat-8
ifeq ($(shell uname), Linux)
SCANNER_FILE = clair-scanner_linux_amd64
else ifeq ($(shell uname), Darwin)
SCANNER_FILE = clair-scanner_darwin_amd64
else
SCANNER_FILE = clair-scanner_windows_amd64.exe
endif
.PHONY: tests interactive_tutorials
all: splunk uf splunk-py23 uf-py23
ansible:
@if [ -d "splunk-ansible" ]; then \
echo "Ansible directory exists - skipping clone"; \
else \
git clone ${SPLUNK_ANSIBLE_REPO} --branch ${SPLUNK_ANSIBLE_BRANCH}; \
fi
@cd splunk-ansible && git rev-parse HEAD > version.txt
@cat splunk-ansible/version.txt
##### Base images #####
base: base-debian-9 base-debian-10 base-centos-7 base-centos-8 base-redhat-8 base-windows-2016
base-debian-10:
docker build ${DOCKER_BUILD_FLAGS} -t base-debian-10:${IMAGE_VERSION} ./base/debian-10
base-debian-9:
docker build ${DOCKER_BUILD_FLAGS} -t base-debian-9:${IMAGE_VERSION} ./base/debian-9
base-centos-7:
docker build ${DOCKER_BUILD_FLAGS} -t base-centos-7:${IMAGE_VERSION} ./base/centos-7
base-centos-8:
docker build ${DOCKER_BUILD_FLAGS} -t base-centos-8:${IMAGE_VERSION} ./base/centos-8
base-redhat-8:
docker build ${DOCKER_BUILD_FLAGS} --label version=${SPLUNK_VERSION} -t base-redhat-8:${IMAGE_VERSION} ./base/redhat-8
base-redhat-8-armv8:
docker buildx build ${DOCKER_BUILD_FLAGS} --build-arg BUSYBOX_URL=${BUSYBOX_URL} --label version=${SPLUNK_VERSION} -t base-redhat-8-armv8:${IMAGE_VERSION} ./base/redhat-8
base-windows-2016:
docker build ${DOCKER_BUILD_FLAGS} -t base-windows-2016:${IMAGE_VERSION} ./base/windows-2016
##### Minimal images #####
minimal: minimal-debian-9 minimal-debian-10 minimal-centos-7 minimal-centos-8 minimal-redhat-8
minimal-debian-9: base-debian-9
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-9 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target minimal -t minimal-debian-9:${IMAGE_VERSION} .
minimal-debian-10: base-debian-10
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-10 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target minimal -t minimal-debian-10:${IMAGE_VERSION} .
minimal-centos-7: base-centos-7
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-7 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target minimal -t minimal-centos-7:${IMAGE_VERSION} .
minimal-centos-8: base-centos-8
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-8 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target minimal -t minimal-centos-8:${IMAGE_VERSION} .
minimal-redhat-8: base-redhat-8
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-redhat-8 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target minimal -t minimal-redhat-8:${IMAGE_VERSION} .
##### Bare images #####
bare: bare-debian-9 bare-debian-10 bare-centos-7 bare-centos-8 bare-redhat-8
bare-debian-9: base-debian-9
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-9 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target bare -t bare-debian-9:${IMAGE_VERSION} .
bare-debian-10: base-debian-10
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-10 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target bare -t bare-debian-10:${IMAGE_VERSION} .
bare-centos-7: base-centos-7
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-7 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target bare -t bare-centos-7:${IMAGE_VERSION} .
bare-centos-8: base-centos-8
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-8 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target bare -t bare-centos-8:${IMAGE_VERSION} .
bare-redhat-8: base-redhat-8
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-redhat-8 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
--target bare -t bare-redhat-8:${IMAGE_VERSION} .
##### Splunk images #####
splunk: ansible splunk-debian-9 splunk-debian-10 splunk-centos-7 splunk-centos-8 splunk-redhat-8
splunk-debian-9: base-debian-9 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-9 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
-t splunk-debian-9:${IMAGE_VERSION} .
splunk-debian-10: base-debian-10 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-10 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
-t splunk-debian-10:${IMAGE_VERSION} .
splunk-centos-7: base-centos-7 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-7 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
-t splunk-centos-7:${IMAGE_VERSION} .
splunk-centos-8: base-centos-8 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-8 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
-t splunk-centos-8:${IMAGE_VERSION} .
splunk-redhat-8: base-redhat-8 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-redhat-8 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_LINUX_BUILD_URL} \
-t splunk-redhat-8:${IMAGE_VERSION} .
splunk-windows-2016: base-windows-2016 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f splunk/windows-2016/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-windows-2016 \
--build-arg SPLUNK_BUILD_URL=${SPLUNK_WIN_BUILD_URL} \
-t splunk-windows-2016:${IMAGE_VERSION} .
##### UF images #####
uf: ansible uf-debian-9 uf-debian-10 uf-centos-7 uf-centos-8 uf-redhat-8
ufbare-debian-9: base-debian-9 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-9 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
--target bare -t ufbare-debian-9:${IMAGE_VERSION} .
ufbare-debian-10: base-debian-10 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-10 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
--target bare -t ufbare-debian-10:${IMAGE_VERSION} .
uf-debian-9: base-debian-9 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-9 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
-t uf-debian-9:${IMAGE_VERSION} .
uf-debian-10: base-debian-10 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-debian-10 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
-t uf-debian-10:${IMAGE_VERSION} .
uf-centos-7: base-centos-7 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-7 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
-t uf-centos-7:${IMAGE_VERSION} .
uf-centos-8: base-centos-8 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-centos-8 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
-t uf-centos-8:${IMAGE_VERSION} .
uf-redhat-8: base-redhat-8 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-redhat-8 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
-t uf-redhat-8:${IMAGE_VERSION} .
uf-redhat-8-armv8: base-redhat-8-armv8 ansible
docker buildx build ${DOCKER_BUILD_FLAGS} \
-f uf/common-files/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-redhat-8-armv8 \
--build-arg SPLUNK_BUILD_URL=${UF_LINUX_BUILD_URL} \
-t uf-redhat-8-armv8:${IMAGE_VERSION} .
uf-windows-2016: base-windows-2016 ansible
docker build ${DOCKER_BUILD_FLAGS} \
-f uf/windows-2016/Dockerfile \
--build-arg SPLUNK_BASE_IMAGE=base-windows-2016 \
--build-arg SPLUNK_BUILD_URL=${UF_WIN_BUILD_URL} \
-t uf-windows-2016:${IMAGE_VERSION} .
##### Python 3 support #####
splunk-py23: splunk-py23-debian-9 splunk-py23-debian-10 splunk-py23-centos-7 splunk-py23-centos-8 splunk-py23-redhat-8
splunk-py23-debian-9: splunk-debian-9
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/debian-9/Dockerfile \
--build-arg SPLUNK_PRODUCT=splunk \
-t splunk-py23-debian-9:${IMAGE_VERSION} .
splunk-py23-debian-10: splunk-debian-10
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/debian-10/Dockerfile \
--build-arg SPLUNK_PRODUCT=splunk \
-t splunk-py23-debian-10:${IMAGE_VERSION} .
splunk-py23-centos-7: splunk-centos-7
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/centos-7/Dockerfile \
--build-arg SPLUNK_PRODUCT=splunk \
-t splunk-py23-centos-7:${IMAGE_VERSION} .
splunk-py23-centos-8: splunk-centos-8
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/centos-8/Dockerfile \
--build-arg SPLUNK_PRODUCT=splunk \
-t splunk-py23-centos-8:${IMAGE_VERSION} .
splunk-py23-redhat-8: splunk-redhat-8
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/redhat-8/Dockerfile \
--build-arg SPLUNK_PRODUCT=splunk \
-t splunk-py23-redhat-8:${IMAGE_VERSION} .
uf-py23: uf-py23-debian-9 uf-py23-debian-10 uf-py23-centos-7 uf-py23-redhat-8
uf-py23-debian-9: uf-debian-9
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/debian-9/Dockerfile \
--build-arg SPLUNK_PRODUCT=uf \
-t uf-py23-debian-9:${IMAGE_VERSION} .
uf-py23-debian-10: uf-debian-10
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/debian-10/Dockerfile \
--build-arg SPLUNK_PRODUCT=uf \
-t uf-py23-debian-10:${IMAGE_VERSION} .
uf-py23-centos-7: uf-centos-7
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/centos-7/Dockerfile \
--build-arg SPLUNK_PRODUCT=uf \
-t uf-py23-centos-7:${IMAGE_VERSION} .
uf-py23-centos-8: uf-centos-8
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/centos-8/Dockerfile \
--build-arg SPLUNK_PRODUCT=uf \
-t uf-py23-centos-8:${IMAGE_VERSION} .
uf-py23-redhat-8: uf-redhat-8
docker build ${DOCKER_BUILD_FLAGS} \
-f py23-image/redhat-8/Dockerfile \
--build-arg SPLUNK_PRODUCT=uf \
-t uf-py23-redhat-8:${IMAGE_VERSION} .
##### Tests #####
sample-compose-up: sample-compose-down
docker-compose -f test_scenarios/${SPLUNK_COMPOSE} up -d
sample-compose-down:
docker-compose -f test_scenarios/${SPLUNK_COMPOSE} down --volumes --remove-orphans || true
test: clean ansible test_setup all run_small_tests run_large_tests
run_small_tests: run_small_tests_centos7 run_small_tests_redhat8 run_small_tests_debian9 run_small_tests_debian10
run_large_tests: run_large_tests_centos7 run_large_tests_redhat8 run_large_tests_debian9 run_large_tests_debian10
test_centos7: clean ansible splunk-centos-7 uf-centos-7 test_setup run_small_tests_centos7 run_large_tests_centos7
test_redhat8: clean ansible splunk-redhat-8 uf-redhat-8 test_setup run_small_tests_redhat8 run_large_tests_redhat8
test_debian9: clean ansible splunk-debian-9 uf-debian-9 test_setup run_small_tests_debian9 run_large_tests_debian9
test_debian10: clean ansible splunk-debian-10 uf-debian-10 test_setup run_small_tests_debian10 run_large_tests_debian10
run_small_tests_centos7:
@echo 'Running the super awesome small tests; CentOS 7'
pytest -n 2 --reruns 1 -sv tests/test_single_splunk_image.py --platform centos-7 --junitxml test-results/centos7-result/testresults_small_centos7.xml
run_large_tests_centos7:
@echo 'Running the super awesome large tests; CentOS 7'
pytest -n 2 --reruns 1 -sv tests/test_distributed_splunk_image.py --platform centos-7 --junitxml test-results/centos7-result/testresults_large_centos7.xml
run_small_tests_redhat8:
@echo 'Running the super awesome small tests; RedHat 8'
pytest -n 2 --reruns 1 -sv tests/test_single_splunk_image.py --platform redhat-8 --junitxml test-results/redhat8-result/testresults_small_redhat8.xml
run_large_tests_redhat8:
@echo 'Running the super awesome large tests; RedHat 8'
pytest -n 2 --reruns 1 -sv tests/test_distributed_splunk_image.py --platform redhat-8 --junitxml test-results/redhat8-result/testresults_large_redhat8.xml
test_setup:
@echo 'Install test requirements'
pip install --upgrade pip
pip install -r $(shell pwd)/tests/requirements.txt --upgrade
mkdir test-results/centos7-result || true
mkdir test-results/debian9-result || true
mkdir test-results/debian10-result || true
mkdir test-results/redhat8-result || true
run_small_tests_debian9:
@echo 'Running the super awesome small tests; Debian 9'
pytest -n 2 --reruns 1 -sv tests/test_single_splunk_image.py --platform debian-9 --junitxml test-results/debian9-result/testresults_small_debian9.xml
run_large_tests_debian9:
@echo 'Running the super awesome large tests; Debian 9'
pytest -n 2 --reruns 1 -sv tests/test_distributed_splunk_image.py --platform debian-9 --junitxml test-results/debian9-result/testresults_large_debian9.xml
run_small_tests_debian10:
@echo 'Running the super awesome small tests; Debian 10'
pytest -n 2 --reruns 1 -sv tests/test_single_splunk_image.py --platform debian-10 --junitxml test-results/debian10-result/testresults_small_debian10.xml
run_large_tests_debian10:
@echo 'Running the super awesome large tests; Debian 10'
pytest -n 2 --reruns 1 -sv tests/test_distributed_splunk_image.py --platform debian-10 --junitxml test-results/debian10-result/testresults_large_debian10.xml
save_containers:
@echo 'Saving the following containers:${CONTAINERS_TO_SAVE}'
mkdir test-results/saved_images || true
$(foreach image,${CONTAINERS_TO_SAVE}, echo "Currently saving: ${image}"; docker save ${image} --output test-results/saved_images/${image}.tar; echo "Compressing: ${image}.tar"; gzip test-results/saved_images/${image}.tar; )
test_python3_all: test_splunk_python3_all test_uf_python3_all
test_splunk_python3_all: test_splunk_centos7_python3 test_splunk_redhat8_python3 test_splunk_debian9_python3 test_splunk_debian10_python3
test_uf_python3_all: test_uf_centos7_python3 test_uf_redhat8_python3 test_uf_debian9_python3 test_uf_debian10_python3
test_splunk_centos7_python3:
$(call test_python3_installation,splunk-py23-centos-7)
test_splunk_redhat8_python3:
$(call test_python3_installation,splunk-py23-redhat-8)
test_splunk_debian9_python3:
$(call test_python3_installation,splunk-py23-debian-9)
test_splunk_debian10_python3:
$(call test_python3_installation,splunk-py23-debian-10)
test_uf_centos7_python3:
$(call test_python3_installation,uf-py23-centos-7)
test_uf_redhat8_python3:
$(call test_python3_installation,uf-py23-redhat-8)
test_uf_debian9_python3:
$(call test_python3_installation,uf-py23-debian-9)
test_uf_debian10_python3:
$(call test_python3_installation,uf-py23-debian-10)
define test_python3_installation
docker run -d --rm --name $1 -it $1 bash
docker exec -it $1 bash -c 'if [[ $$(python3 -V) =~ "Python 3" ]] ; then echo "$$(python3 -V) installed" ; else echo "No Python3 installation found" ; docker kill $1 ; exit 1 ; fi'
docker kill $1
endef
test_python2_all: test_splunk_python2_all test_uf_python2_all
test_splunk_python2_all: test_splunk_centos7_python2 test_splunk_redhat8_python2 test_splunk_debian9_python2 test_splunk_debian10_python2
test_uf_python2_all: test_uf_centos7_python2 test_uf_redhat8_python2 test_uf_debian9_python2 test_uf_debian10_python2
test_splunk_centos7_python2:
$(call test_python2_installation,splunk-py23-centos-7)
test_splunk_redhat8_python2:
$(call test_python2_installation,splunk-py23-redhat-8)
test_splunk_debian9_python2:
$(call test_python2_installation,splunk-py23-debian-9)
test_splunk_debian10_python2:
$(call test_python2_installation,splunk-py23-debian-10)
test_uf_centos7_python2:
$(call test_python2_installation,uf-py23-centos-7)
test_uf_redhat8_python2:
$(call test_python2_installation,uf-py23-redhat-8)
test_uf_debian9_python2:
$(call test_python2_installation,uf-py23-debian-9)
test_uf_debian10_python2:
$(call test_python2_installation,uf-py23-debian-10)
#python2 version print to stderr, hence the 2>&1
define test_python2_installation
docker run -d --rm --name $1 -it $1 bash
docker exec -it $1 bash -c 'if [[ $$(python -V 2>&1) =~ "Python 2" ]] ; then echo "$$(python -V 2>&1) is the default python" ; else echo "Python is not default to python2" ; docker kill $1 ; exit 1 ; fi'
docker kill $1
endef
test_debian10_image_size:
$(call test_image_size,splunk-debian-10)
define test_image_size
docker pull splunk/splunk:edge
CUR_SIZE=$$(docker image inspect $1:latest --format='{{.Size}}') ; \
EDGE_SIZE=$$(docker image inspect splunk/splunk:edge --format='{{.Size}}') ; \
echo "current $1 image size = "$$CUR_SIZE ; \
echo "edge image size = "$$EDGE_SIZE ; \
if [[ $$CUR_SIZE -gt $$EDGE_SIZE*140/100 ]] ; then echo "current image size is 40% more than edge image" ; exit 1 ; fi
endef
setup_clair_scanner:
mkdir clair-scanner-logs
mkdir test-results/cucumber
docker stop clair_db || true
docker rm clair_db || true
docker stop clair || true
docker rm clair || true
docker pull arminc/clair-db:${SCANNER_DATE} || docker pull arminc/clair-db:${SCANNER_DATE_YEST} || echo "WARNING: Failed to pull daily image, defaulting to latest" >> clair-scanner-logs/clair_setup_errors.log ; docker pull arminc/clair-db:latest
docker run -d --name clair_db arminc/clair-db:${SCANNER_DATE} || docker run -d --name clair_db arminc/clair-db:${SCANNER_DATE_YEST} || docker run -d --name clair_db arminc/clair-db:latest
docker run -p 6060:6060 --link clair_db:postgres -d --name clair --restart on-failure arminc/clair-local-scan:v2.0.6
wget https://github.com/arminc/clair-scanner/releases/download/${SCANNER_VERSION}/${SCANNER_FILE}
mv ${SCANNER_FILE} clair-scanner
chmod +x clair-scanner
echo "Waiting for clair daemon to start"
retries=0 ; while( ! wget -T 10 -q -O /dev/null http://0.0.0.0:6060/v1/namespaces ) ; do sleep 1 ; echo -n "." ; if [ $$retries -eq 10 ] ; then echo " Timeout, aborting." ; exit 1 ; fi ; retries=$$(($$retries+1)) ; done
echo "Daemon started."
run_clair_scan:
$(foreach image,${SCANNER_IMAGES_TO_SCAN}, mkdir test-results/clair-scanner-${image}; ./clair-scanner -c http://0.0.0.0:6060 --ip ${SCANNER_LOCALIP} -r test-results/clair-scanner-${image}/results.json -l clair-scanner-logs/${image}.log -w clair-whitelist.yml ${image}:${NONQUOTE_IMAGE_VERSION} || true ; python clair_to_junit_parser.py test-results/clair-scanner-${image}/results.json --output test-results/clair-scanner-${image}/results.xml ; )
setup_and_run_clair: setup_clair_scanner run_clair_scan
clean:
docker stop clair_db || true
docker rm clair_db || true
docker stop clair || true
docker rm clair || true
rm -rf .pytest_cache || true
rm -rf clair-scanner || true
rm -rf clair-scanner-logs || true
rm -rf test-results/* || true
docker rm -f ${TEST_IMAGE_NAME} || true
docker system prune -f --volumes
clean_ansible:
rm -rf splunk-ansible
dev_loop:
SPLUNK_IMAGE="splunk-debian-10:latest" make sample-compose-down && sleep 15 && DOCKER_BUILD_FLAGS="--no-cache" make all && sleep 15 && SPLUNK_IMAGE="splunk-debian-10:latest" make sample-compose-up