Skip to content

Commit 4163332

Browse files
authored
Merge pull request #146 from splunk/docker-splunk
Install sdk-app-collection via docker-compose; add standard SDK makef…
2 parents d1827fc + 5a1139c commit 4163332

File tree

4 files changed

+77
-13
lines changed

4 files changed

+77
-13
lines changed

.travis.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
notifications:
32
email: false
43

@@ -17,31 +16,27 @@ before_install:
1716
- export TEST_UDP_PORT=10668
1817
# Set SPLUNK_HOME
1918
- export SPLUNK_HOME="/opt/splunk"
20-
# Pull docker image
21-
- docker pull splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
2219
# Add DOCKER to iptables, 1/10 times this is needed, force 0 exit status
2320
- sudo iptables -N DOCKER || true
24-
# Start Docker container
25-
- docker run -p 127.0.0.1:8089:8089 -p 127.0.0.1:$TEST_TCP_PORT:$TEST_TCP_PORT -p 127.0.0.1:$TEST_UDP_PORT:$TEST_UDP_PORT/udp -d splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
26-
# curl Splunk until it returns valid data indicating it has been setup, try 20 times maximum
27-
- for i in `seq 0 20`; do if curl --fail -k https://localhost:8089/services/server/info &> /dev/null; then break; fi; echo $i; sleep 1; done
28-
# Additional sleep to make sure splunkd is
29-
- sleep 30
21+
# Start docker-compose in detached mode
22+
- docker-compose up -d
23+
# Health Check (3 minutes)
24+
- for i in `seq 0 180`; do if docker exec -it splunk /sbin/checkstate.sh &> /dev/null; then break; fi; echo $i; sleep 1; done
3025

31-
env:
32-
- SPLUNK_VERSION=7.0-sdk
33-
- SPLUNK_VERSION=7.2-sdk
3426

3527
language: java
3628

29+
env:
30+
- SPLUNK_VERSION=7.3
31+
- SPLUNK_VERSION=8.0
32+
3733
addons:
3834
apt:
3935
packages:
4036
- ant-optional
4137

4238
jdk:
4339
- openjdk8
44-
- openjdk11
4540

4641
before_script:
4742
- ant

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# text reset
2+
NO_COLOR=\033[0m
3+
# green
4+
OK_COLOR=\033[32;01m
5+
# red
6+
ERROR_COLOR=\033[31;01m
7+
# cyan
8+
WARN_COLOR=\033[36;01m
9+
# yellow
10+
ATTN_COLOR=\033[33;01m
11+
12+
ROOT_DIR := $(shell git rev-parse --show-toplevel)
13+
14+
VERSION := `git describe --tags --dirty 2>/dev/null`
15+
COMMITHASH := `git rev-parse --short HEAD 2>/dev/null`
16+
DATE := `date "+%FT%T%z"`
17+
18+
.PHONY: all
19+
all: init test
20+
21+
init:
22+
@echo "$(ATTN_COLOR)==> init $(NO_COLOR)"
23+
24+
.PHONY: test
25+
test:
26+
@echo "$(ATTN_COLOR)==> test $(NO_COLOR)"
27+
@ant test
28+
29+
.PHONY: test_specific
30+
test_specific:
31+
@echo "$(ATTN_COLOR)==> test_specific $(NO_COLOR)"
32+
@sh ./scripts/test_specific.sh
33+
34+
.PHONY: up
35+
up:
36+
@echo "$(ATTN_COLOR)==> up $(NO_COLOR)"
37+
@docker-compose up -d
38+
39+
.PHONY: wait_up
40+
wait_up:
41+
@echo "$(ATTN_COLOR)==> wait_up $(NO_COLOR)"
42+
@for i in `seq 0 180`; do if docker exec -it splunk /sbin/checkstate.sh &> /dev/null; then break; fi; printf "\rWaiting for Splunk for %s seconds..." $$i; sleep 1; done
43+
44+
.PHONY: down
45+
down:
46+
@echo "$(ATTN_COLOR)==> down $(NO_COLOR)"
47+
@docker-compose stop

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.6'
2+
3+
services:
4+
splunk:
5+
image: "splunk/splunk:${SPLUNK_VERSION}"
6+
container_name: splunk
7+
environment:
8+
- SPLUNK_START_ARGS=--accept-license
9+
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
10+
- SPLUNK_PASSWORD=changed!
11+
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.0.0/sdk-app-collection.tgz
12+
ports:
13+
- 8000:8000
14+
- 8088:8088
15+
- 8089:8089
16+
healthcheck:
17+
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
18+
interval: 5s
19+
timeout: 5s
20+
retries: 20

scripts/test_specific.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo "To run a specific test:"
2+
echo " ant test -Dtestcase=[testclass]"

0 commit comments

Comments
 (0)