Skip to content

Install sdk-app-collection via docker-compose #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@ before_install:
- echo password=changed! >> $HOME/.splunkrc
# Set SPLUNK_HOME
- export SPLUNK_HOME="/opt/splunk"
# Pull docker image
- docker pull splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
# Add DOCKER to iptables, 1/10 times this is needed, force 0 exit status
- sudo iptables -N DOCKER || true
# Start Docker container
- docker run -p 127.0.0.1:8089:8089 -d splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
# curl Splunk until it returns valid data indicating it has been setup, try 20 times maximum
- 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

# Start docker-compose in detached mode
- docker-compose up -d
# Health Check (3 minutes)
- 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

language: node_js
node_js:
- "10.0"
- "4.2"
- "0.12"

#Splunk versions can be set here
env:
- SPLUNK_VERSION=7.0-sdk
- SPLUNK_VERSION=7.2-sdk
- SPLUNK_VERSION=7.3
- SPLUNK_VERSION=8.0

before_script:
node sdkdo hint
Expand Down
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# text reset
NO_COLOR=\033[0m
# green
OK_COLOR=\033[32;01m
# red
ERROR_COLOR=\033[31;01m
# cyan
WARN_COLOR=\033[36;01m
# yellow
ATTN_COLOR=\033[33;01m

ROOT_DIR := $(shell git rev-parse --show-toplevel)

VERSION := `git describe --tags --dirty 2>/dev/null`
COMMITHASH := `git rev-parse --short HEAD 2>/dev/null`
DATE := `date "+%FT%T%z"`

.PHONY: all
all: init test

init:
@echo "$(ATTN_COLOR)==> init $(NO_COLOR)"

.PHONY: test
test:
@echo "$(ATTN_COLOR)==> test $(NO_COLOR)"
@node sdkdo tests

.PHONY: test_specific
test_specific:
@echo "$(ATTN_COLOR)==> test_specific $(NO_COLOR)"
@sh ./scripts/test_specific.sh

.PHONY: up
up:
@echo "$(ATTN_COLOR)==> up $(NO_COLOR)"
@docker-compose up -d

.PHONY: wait_up
wait_up:
@echo "$(ATTN_COLOR)==> wait_up $(NO_COLOR)"
@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

.PHONY: down
down:
@echo "$(ATTN_COLOR)==> down $(NO_COLOR)"
@docker-compose stop
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.6'

services:
splunk:
image: "splunk/splunk:${SPLUNK_VERSION}"
container_name: splunk
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.0.0/sdk-app-collection.tgz
ports:
- 8000:8000
- 8088:8088
- 8089:8089
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
interval: 5s
timeout: 5s
retries: 20
2 changes: 2 additions & 0 deletions scripts/test_specific.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "To run a specific test:"
echo " node sdkdo tests [test1,test2]"
5 changes: 3 additions & 2 deletions tests/service_tests/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ module.exports = function (svc, loggedOutSvc) {
var versionParts = info.properties().version.split(".");

var isDevBuild = versionParts.length === 1;
var newerThan72 = (parseInt(versionParts[0], 10) >= 7 && parseInt(versionParts[1], 10) >= 2);
var newerThan72 = (parseInt(versionParts[0], 10) > 7 ||
(parseInt(versionParts[0], 10) === 7 && parseInt(versionParts[1], 10) >= 2));

if (isDevBuild || newerThan72) {
useOldPassword = true;
Expand Down Expand Up @@ -243,4 +244,4 @@ module.exports = function (svc, loggedOutSvc) {
});
}
};
};
};