Skip to content

Commit 8a9142e

Browse files
authored
Merge pull request #97 from splunk/docker-splunk
Install sdk-app-collection via docker-compose
2 parents b20d732 + f16a80e commit 8a9142e

File tree

5 files changed

+78
-12
lines changed

5 files changed

+78
-12
lines changed

.travis.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,22 @@ before_install:
1313
- echo password=changed! >> $HOME/.splunkrc
1414
# Set SPLUNK_HOME
1515
- export SPLUNK_HOME="/opt/splunk"
16-
# Pull docker image
17-
- docker pull splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
1816
# Add DOCKER to iptables, 1/10 times this is needed, force 0 exit status
1917
- sudo iptables -N DOCKER || true
20-
# Start Docker container
21-
- docker run -p 127.0.0.1:8089:8089 -d splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
22-
# curl Splunk until it returns valid data indicating it has been setup, try 20 times maximum
23-
- 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
24-
18+
# Start docker-compose in detached mode
19+
- docker-compose up -d
20+
# Health Check (3 minutes)
21+
- 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
2522

2623
language: node_js
2724
node_js:
2825
- "10.0"
2926
- "4.2"
3027
- "0.12"
3128

32-
#Splunk versions can be set here
3329
env:
34-
- SPLUNK_VERSION=7.0-sdk
35-
- SPLUNK_VERSION=7.2-sdk
30+
- SPLUNK_VERSION=7.3
31+
- SPLUNK_VERSION=8.0
3632

3733
before_script:
3834
node sdkdo hint

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+
@node sdkdo tests
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 " node sdkdo tests [test1,test2]"

tests/service_tests/user.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ module.exports = function (svc, loggedOutSvc) {
154154
var versionParts = info.properties().version.split(".");
155155

156156
var isDevBuild = versionParts.length === 1;
157-
var newerThan72 = (parseInt(versionParts[0], 10) >= 7 && parseInt(versionParts[1], 10) >= 2);
157+
var newerThan72 = (parseInt(versionParts[0], 10) > 7 ||
158+
(parseInt(versionParts[0], 10) === 7 && parseInt(versionParts[1], 10) >= 2));
158159

159160
if (isDevBuild || newerThan72) {
160161
useOldPassword = true;
@@ -243,4 +244,4 @@ module.exports = function (svc, loggedOutSvc) {
243244
});
244245
}
245246
};
246-
};
247+
};

0 commit comments

Comments
 (0)