Skip to main content

A Dynamic test tool for Splunk Apps and Add-ons

Project description

PyPI version Python versions

A Dynamic test tool for Splunk Apps and Add-ons

Features

  • Generate tests for Splunk Knowledge objects in your Splunk Technology Add-ons

  • Validate your add-ons using Splunk + Docker and this test tool

Requirements

  • Docker or an external single instance Splunk deployment

Installation

You can install “pytest-splunk-addon” via pip from PyPI:

$ pip install pytest-splunk-addon

Developing

Note: Must install docker desktop, vscode or pycharm pro optional

Note2: Appinspect requires libmagic verify this has been installed correctly each time a new workstation/vm is used https://dev.splunk.com/enterprise/docs/releaseapps/appinspect/splunkappinspectclitool/installappinspect

$ #setup python venv must be 3.7 $ git clone –recurse-submodules -j8 git@github.com:splunk/pytest-splunk-addon.git

$ /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -m venv .venv

$ source .venv/bin/activate

$ pip3 install -r requirements_dev.txt

$ pip3 install https://download.splunk.com/misc/appinspect/splunk-appinspect-latest.tar.gz

$ python setup.py develop

Usage

Installation for external Splunk

pip install pytest-splunk-addon

Installation with built in docker orchestration

pip install pytest-splunk-addon[docker]

Basic project structure

The tool assumes the Splunk Add-on is located in a folder “package” in the project root

Triggering the tool:

Create a test file in the tests folder

from pytest_splunk_addon.standard_lib.addon_basic import Basic
    class Test_App(Basic):
        def empty_method():
            pass

Create a Dockerfile-splunk file

ARG SPLUNK_VERSION=latest
FROM splunk/splunk:$SPLUNK_VERSION
ARG SPLUNK_APP=TA_UNKNOWN
ARG SOURCE_PACKAGE=package
COPY deps/apps /opt/splunk/etc/apps/

COPY $SOURCE_PACKAGE /opt/splunk/etc/apps/$SPLUNK_APP

Create a docker-compose.yml update the value of SPLUNK_APP

version: "3.7"
services:
splunk:
    build:
    context: .
    dockerfile: Dockerfile-splunk
    args:
        - SPLUNK_APP=xxxxxxx
    ports:
    - "8000"
    - "8089"
    environment:
    - SPLUNK_PASSWORD=Changed@11
    - SPLUNK_START_ARGS=--accept-license

Run pytest with the add-on and SA-eventgen installed and enabled in an external Splunk deployment

Run pytest with the add-on and SA-eventgen installed and enabled in docker

Contributing

Contributions are very welcome. Tests can be run with pytest, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the Apache Software License 2.0 license, “pytest-splunk-addon” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-splunk-addon-1.1.1a4.tar.gz (123.5 kB view details)

Uploaded Source

Built Distribution

pytest_splunk_addon-1.1.1a4-py2.py3-none-any.whl (164.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-splunk-addon-1.1.1a4.tar.gz.

File metadata

  • Download URL: pytest-splunk-addon-1.1.1a4.tar.gz
  • Upload date:
  • Size: 123.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pytest-splunk-addon-1.1.1a4.tar.gz
Algorithm Hash digest
SHA256 d37e1552999c87f014ee152dfadb2795e8921e17bff1a16e689fa7c9e4fb75a8
MD5 c9e0d20efbd5e96a6a344adcfbc1b5d5
BLAKE2b-256 9cc79a5bf88a40d9603f6602a012f13118370222eb2f49125e8d2872b3f8e60a

See more details on using hashes here.

File details

Details for the file pytest_splunk_addon-1.1.1a4-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_splunk_addon-1.1.1a4-py2.py3-none-any.whl
  • Upload date:
  • Size: 164.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pytest_splunk_addon-1.1.1a4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3f8bc87a91eadf94e28a38b8d80a9be301da56cc666ea0dd2e60521f96f3e0f2
MD5 4b5b6369ea36dfe011ff1c17a57a274c
BLAKE2b-256 74d80b2760bcb3b47a2bbd0ae4f609fbd51541397773757ba26d6c71c0b723a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page