Skip to content
Closed
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
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
platform: linux/amd64
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_GENERAL_TERMS=--accept-sgt-current-at-splunk-com
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.1.0/sdkappcollection.tgz
Expand All @@ -18,10 +19,10 @@ services:
timeout: 5s
retries: 20
volumes:
- "./tests/searchcommands/test_apps/eventing_app:/opt/splunk/etc/apps/eventing_app"
- "./tests/searchcommands/test_apps/generating_app:/opt/splunk/etc/apps/generating_app"
- "./tests/searchcommands/test_apps/reporting_app:/opt/splunk/etc/apps/reporting_app"
- "./tests/searchcommands/test_apps/streaming_app:/opt/splunk/etc/apps/streaming_app"
- "./tests/system/test_apps/eventing_app:/opt/splunk/etc/apps/eventing_app"
- "./tests/system/test_apps/generating_app:/opt/splunk/etc/apps/generating_app"
- "./tests/system/test_apps/reporting_app:/opt/splunk/etc/apps/reporting_app"
- "./tests/system/test_apps/streaming_app:/opt/splunk/etc/apps/streaming_app"
- "./splunklib:/opt/splunk/etc/apps/eventing_app/lib/splunklib"
- "./splunklib:/opt/splunk/etc/apps/generating_app/lib/splunklib"
- "./splunklib:/opt/splunk/etc/apps/reporting_app/lib/splunklib"
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/test_app.py → tests/integration/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.

# integration test - tests SDK usage as communication with splunk over http api to create and manage apps

import logging
from tests import testlib
from splunklib import client
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions tests/test_job.py → tests/integration/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# under the License.

from io import BytesIO
from pathlib import Path
from time import sleep

import io
Expand Down Expand Up @@ -399,7 +400,9 @@ def test_results_reader(self):
# Run jobs.export("search index=_internal | stats count",
# earliest_time="rt", latest_time="rt") and you get a
# streaming sequence of XML fragments containing results.
with io.open('data/results.xml', mode='br') as input:
test_dir = Path(__file__).parent
data_file = test_dir / 'data' / 'results.xml'
with io.open(str(data_file), mode='br') as input:
reader = results.ResultsReader(input)
self.assertFalse(reader.is_preview)
N_results = 0
Expand All @@ -419,7 +422,9 @@ def test_results_reader_with_streaming_results(self):
# Run jobs.export("search index=_internal | stats count",
# earliest_time="rt", latest_time="rt") and you get a
# streaming sequence of XML fragments containing results.
with io.open('data/streaming_results.xml', 'br') as input:
test_dir = Path(__file__).parent
data_file = test_dir / 'data' / 'streaming_results.xml'
with io.open(str(data_file), 'br') as input:
reader = results.ResultsReader(input)
N_results = 0
N_messages = 0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 6 additions & 7 deletions tests/test_logger.py → tests/integration/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,32 @@

from tests import testlib

from splunklib import client

LEVELS = ["INFO", "WARN", "ERROR", "DEBUG", "CRIT"]


class LoggerTestCase(testlib.SDKTestCase):
def check_logger(self, logger):
self.check_entity(logger)
self.assertTrue(logger['level'] in LEVELS)
self.assertTrue(logger["level"] in LEVELS)

def test_read(self):
for logger in self.service.loggers.list(count=10):
self.check_logger(logger)

def test_crud(self):
self.assertTrue('AuditLogger' in self.service.loggers)
logger = self.service.loggers['AuditLogger']
self.assertTrue("AuditLogger" in self.service.loggers)
logger = self.service.loggers["AuditLogger"]

saved = logger['level']
saved = logger["level"]
for level in LEVELS:
logger.update(level=level)
logger.refresh()
self.assertEqual(self.service.loggers['AuditLogger']['level'], level)
self.assertEqual(self.service.loggers["AuditLogger"]["level"], level)

logger.update(level=saved)
logger.refresh()
self.assertEqual(self.service.loggers['AuditLogger']['level'], saved)
self.assertEqual(self.service.loggers["AuditLogger"]["level"], saved)


if __name__ == "__main__":
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

class Tests(testlib.SDKTestCase):
def setUp(self):
# TODO: why not use super.setUp() ?
self.service = client.connect(**self.opts.kwargs)
self.storage_passwords = self.service.storage_passwords

Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions tests/test_utils.py → tests/integration/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import unittest
import os
from tests import testlib
Expand Down Expand Up @@ -92,8 +93,10 @@ def checkFilePermissions(dir_path):
else:
checkFilePermissions(path)

dir_path = os.path.join('..', 'splunklib')
checkFilePermissions(dir_path)
test_file_path = Path(__file__)
# From tests/integration/test_job.py, go up 2 levels to project root, then to splunklib
splunklib_path = test_file_path.parent.parent.parent / 'splunklib'
checkFilePermissions(str(splunklib_path))


if __name__ == "__main__":
Expand Down
File renamed without changes.
26 changes: 0 additions & 26 deletions tests/test_all.py

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import pytest

from tests.modularinput.modularinput_testlib import xml_compare, data_open
from tests.unit.modularinput.modularinput_testlib import xml_compare, data_open
from splunklib.modularinput.event import Event, ET
from splunklib.modularinput.event_writer import EventWriter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from tests.modularinput.modularinput_testlib import unittest, data_open
from tests.unit.modularinput.modularinput_testlib import unittest, data_open
from splunklib.modularinput.input_definition import InputDefinition


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# under the License.

import xml.etree.ElementTree as ET
from tests.modularinput.modularinput_testlib import unittest, xml_compare, data_open
from tests.unit.modularinput.modularinput_testlib import unittest, xml_compare, data_open
from splunklib.modularinput.scheme import Scheme
from splunklib.modularinput.argument import Argument

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from splunklib.modularinput import Script, EventWriter, Scheme, Argument, Event

from splunklib.modularinput.utils import xml_compare
from tests.modularinput.modularinput_testlib import data_open
from tests.unit.modularinput.modularinput_testlib import data_open


TEST_SCRIPT_PATH = "__IGNORED_SCRIPT_PATH__"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# under the License.


from tests.modularinput.modularinput_testlib import unittest, data_open
from tests.unit.modularinput.modularinput_testlib import unittest, data_open
from splunklib.modularinput.validation_definition import ValidationDefinition


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
2025-07-29 11:22:46,641, Level=WARNING, Pid=74394, File=search_command.py, Line=350, Missing metadata for service creation.
2025-07-30 09:39:03,387, Level=WARNING, Pid=17670, File=search_command.py, Line=350, Missing metadata for service creation.
2025-07-31 15:58:07,275, Level=WARNING, Pid=76649, File=search_command.py, Line=350, Missing metadata for service creation.
2025-08-07 11:32:52,268, Level=WARNING, Pid=99541, File=search_command.py, Line=350, Missing metadata for service creation.
2025-08-07 11:40:09,926, Level=WARNING, Pid=4064, File=search_command.py, Line=350, Missing metadata for service creation.
2025-08-07 11:40:37,027, Level=WARNING, Pid=4441, File=search_command.py, Line=350, Missing metadata for service creation.
2025-08-07 11:47:17,168, Level=WARNING, Pid=8853, File=search_command.py, Line=350, Missing metadata for service creation.
2025-08-07 11:47:22,006, Level=WARNING, Pid=8872, File=search_command.py, Line=350, Missing metadata for service creation.
2025-08-07 11:47:26,296, Level=WARNING, Pid=8905, File=search_command.py, Line=350, Missing metadata for service creation.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from splunklib.searchcommands.decorators import Configuration
from splunklib.searchcommands.search_command import SearchCommand

from tests.searchcommands import rebase_environment, package_directory
from tests.unit.searchcommands import rebase_environment, package_directory

# portable log level names
# https://stackoverflow.com/a/49724281
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from splunklib.searchcommands.internals import json_encode_string
from splunklib.searchcommands.search_command import SearchCommand

from tests.searchcommands import rebase_environment
from tests.unit.searchcommands import rebase_environment


@Configuration()
Expand Down
Loading
Loading