Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rfaircloth-splunk committed Feb 7, 2020
1 parent dcf48d6 commit 0ee7ebb
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 40 deletions.
10 changes: 2 additions & 8 deletions demo-with-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
#Use of this source code is governed by a BSD-2-clause-style
#license that can be found in the LICENSE-BSD2 file or at
#https://opensource.org/licenses/BSD-2-Clause
export SPLUNK=8.0
export SYSLOG=3.25.1

docker-compose build
docker-compose up -d splunk
docker-compose up -d sc4s
sleep 60
docker-compose up
docker-compose -f tests/docker-compose-ci.yml build
docker-compose -f tests/docker-compose-ci.yml up

EXIT=$0
8 changes: 4 additions & 4 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[pytest]
testpaths = tests
#addopts = --tb=long
# --force-flaky --max-runs=3 --min-passes=1
addopts =
-v --tb=long
--splunk_type=docker
filterwarnings =
ignore::DeprecationWarning
#[pytest]
#junit_family = xunit2
junit_family = xunit1
5 changes: 4 additions & 1 deletion test-with-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
#Use of this source code is governed by a BSD-2-clause-style
#license that can be found in the LICENSE-BSD2 file or at
#https://opensource.org/licenses/BSD-2-Clause
SPLUNK=8.0;SYSLOG=3.25.1 pytest --splunk_password=Changed@11
docker-compose -f tests/docker-compose-ci.yml up --abort-on-container-exit

EXIT=$0

3 changes: 2 additions & 1 deletion tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ FROM python:3.7

COPY requirements.txt /
RUN pip3 install -r /requirements.txt
RUN pip3 install pytest-xdist
RUN mkdir -p /work/tests
RUN mkdir -p /work/test-results/functional
COPY entrypoint.sh /
COPY wait-for /bin/
COPY ./* /work/tests/
COPY pytest.ini /work
COPY pytest-ci.ini /work/pytest.ini
COPY ./data /work/tests/data
#WORKDIR /work
CMD /entrypoint.sh
Expand Down
19 changes: 18 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import random
import socket
import uuid
from time import sleep

import pytest
Expand Down Expand Up @@ -82,9 +83,16 @@ def pytest_addoption(parser):
'--splunk_password',
action='store',
dest='splunk_password',
default='changeme',
default='Changed@11',
help='Splunk password'
)
group.addoption(
'--splunk_hec_token',
action='store',
dest='splunk_hec_token',
default=str(uuid.uuid1()),
help='Splunk HEC token'
)
group.addoption(
'--splunk_version',
action='store',
Expand Down Expand Up @@ -112,12 +120,21 @@ def is_responsive_splunk(splunk):
return False


@pytest.fixture(scope="session")
def docker_compose_file(pytestconfig):
"""Get an absolute path to the `docker-compose.yml` file. Override this
fixture in your tests if you need a custom location."""

return os.path.join(str(pytestconfig.invocation_dir), "tests", "docker-compose.yml")

@pytest.fixture(scope="session")
def splunk(request):
if request.config.getoption('splunk_type') == 'external':
request.fixturenames.append('splunk_external')
splunk = request.getfixturevalue("splunk_external")
elif request.config.getoption('splunk_type') == 'docker':
os.environ['SPLUNK_PASSWORD'] = request.config.getoption('splunk_password')
os.environ['SPLUNK_HEC_TOKEN'] = request.config.getoption('splunk_hec_token')
request.fixturenames.append('splunk_docker')
splunk = request.getfixturevalue("splunk_docker")
else:
Expand Down
69 changes: 69 additions & 0 deletions tests/docker-compose-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#Splunk Connect for Syslog (SC4S) by Splunk, Inc.
#
#To the extent possible under law, the person who associated CC0 with
#Splunk Connect for Syslog (SC4S) has waived all copyright and related or neighboring rights
#to Splunk Connect for Syslog (SC4S).
#
#You should have received a copy of the CC0 legalcode along with this
#work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
version: "3.7"


services:
test:
build: .
image: docker.pkg.github.com/splunk/splunk-connect-for-syslog/stg-splunk-connect-for-syslog:tests-${CIRCLE_SHA1}
links:
- splunk
- sc4s
volumes:
- results:/work/test-results

sc4s:
build:
context: ../package
image: docker.pkg.github.com/splunk/splunk-connect-for-syslog/stg-splunk-connect-for-syslog:sc4s-${SYSLOG}-${CIRCLE_SHA1}
hostname: sc4s
#When this is enabled test_common will fail
# command: -det
ports:
- "514"
- "601"
- "514/udp"
- "5000-5050"
- "5000-5050/udp"
- "6514"
stdin_open: true
tty: true
links:
- splunk
environment:
- SPLUNK_HEC_URL=https://splunk:8088
- SPLUNK_HEC_TOKEN=70b6ae71-76b3-4c38-9597-0c5b37ad9630
- SC4S_SOURCE_TLS_ENABLE=no
- SC4S_DEST_SPLUNK_HEC_TLS_VERIFY=no
- SC4S_LISTEN_JUNIPER_NETSCREEN_TCP_PORT=5000
- SC4S_LISTEN_CISCO_ASA_TCP_PORT=5001
- SC4S_LISTEN_CISCO_IOS_TCP_PORT=5002
- SC4S_LISTEN_CISCO_MERAKI_TCP_PORT=5003
- SC4S_LISTEN_JUNIPER_IDP_TCP_PORT=5004
- SC4S_LISTEN_PALOALTO_PANOS_TCP_PORT=5005
- SC4S_LISTEN_PFSENSE_TCP_PORT=5006
- SC4S_ARCHIVE_GLOBAL=no
splunk:
build:
context: ../splunk
image: docker.pkg.github.com/splunk/splunk-connect-for-syslog/stg-splunk-connect-for-syslog:splunk-${SPLUNK}-${CIRCLE_SHA1}
hostname: splunk
ports:
- "8000"
- "8088"
- "8089"
environment:
- SPLUNK_HEC_TOKEN=70b6ae71-76b3-4c38-9597-0c5b37ad9630
- SPLUNK_PASSWORD=Changed@11
- SPLUNK_START_ARGS=--accept-license

volumes:
results:
external: false
22 changes: 2 additions & 20 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,9 @@ version: "3.7"


services:
test:
build: .
image: docker.pkg.github.com/splunk/splunk-connect-for-syslog/stg-splunk-connect-for-syslog:tests-${CIRCLE_SHA1}
links:
- splunk
- sc4s
environment:
- SPLUNK_USER=admin
- SPLUNK_PASSWORD=${SPLUNK_PASSWORD}
- SPLUNK_HOST=splunk
- docke=sc4s
volumes:
- results:/work/test-results

sc4s:
build:
context: ../package
image: docker.pkg.github.com/splunk/splunk-connect-for-syslog/stg-splunk-connect-for-syslog:sc4s-${SYSLOG}-${CIRCLE_SHA1}
hostname: sc4s
#When this is enabled test_common will fail
# command: -det
Expand All @@ -36,7 +21,7 @@ services:
- "601"
- "514/udp"
- "5000-5050"
- "5000-5200/udp"
- "5000-5050/udp"
- "6514"
stdin_open: true
tty: true
Expand All @@ -55,15 +40,12 @@ services:
- SC4S_LISTEN_PALOALTO_PANOS_TCP_PORT=5005
- SC4S_LISTEN_PFSENSE_TCP_PORT=5006
- SC4S_ARCHIVE_GLOBAL=no
volumes:
- ./tls:/opt/syslog-ng/tls
splunk:
build:
context: ../splunk
image: docker.pkg.github.com/splunk/splunk-connect-for-syslog/stg-splunk-connect-for-syslog:splunk-${SPLUNK}-${CIRCLE_SHA1}
hostname: splunk
ports:
- "8000:8000"
- "8000"
- "8088"
- "8089"
environment:
Expand Down
11 changes: 11 additions & 0 deletions tests/pytest-ci.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[pytest]
addopts = -v
--splunk_type=external
--splunk_password=Changed@11
--splunk_hec_token=70b6ae71-76b3-4c38-9597-0c5b37ad9630
--splunk_host=splunk
--sc4s_host=sc4s
--maxfail=5
-n 4
filterwarnings =
ignore::DeprecationWarning
5 changes: 0 additions & 5 deletions tests/pytest.ini

This file was deleted.

0 comments on commit 0ee7ebb

Please sign in to comment.