diff --git a/.travis.yml b/.travis.yml index f37a1e22..82c423c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ - notifications: email: false @@ -17,23 +16,20 @@ before_install: - export TEST_UDP_PORT=10668 # 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 -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 - # 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 - # Additional sleep to make sure splunkd is - - sleep 30 + # 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 -env: - - SPLUNK_VERSION=7.0-sdk - - SPLUNK_VERSION=7.2-sdk language: java +env: + - SPLUNK_VERSION=7.3 + - SPLUNK_VERSION=8.0 + addons: apt: packages: @@ -41,7 +37,6 @@ addons: jdk: - openjdk8 - - openjdk11 before_script: - ant diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c50d46dd --- /dev/null +++ b/Makefile @@ -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)" + @ant test + +.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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..c4107d5d --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/scripts/test_specific.sh b/scripts/test_specific.sh new file mode 100644 index 00000000..b93c37cc --- /dev/null +++ b/scripts/test_specific.sh @@ -0,0 +1,2 @@ +echo "To run a specific test:" +echo " ant test -Dtestcase=[testclass]"