A Dynamic test tool for Splunk Apps and Add-ons
Project description
A Dynamic test tool for Splunk Apps and Add-ons
Documentation
The detailed documentation for pytest-splunk-addon can be found here : https://pytest-splunk-addon.readthedocs.io/
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
$ git clone --recurse-submodules -j8 git@github.com:splunk/pytest-splunk-addon.git
$ #setup python venv must be 3.7
$ /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 SPLUNK_APP_PACKAGE=package
COPY deps/apps /opt/splunk/etc/apps/
COPY $SPLUNK_APP_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
For full usage instructions, please visit the pytest-splunk-addon documentation pages over at readthedocs.
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
Built Distribution
Hashes for pytest-splunk-addon-1.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b32a48482a9cef8ae6564eb912bbdba3d8a8566ba411c8e7a2ebef1f456f0fb |
|
MD5 | efa659f1b7211f5709a8e78b1327d624 |
|
BLAKE2b-256 | eaa8ea4cd19d22f67b063764d10b99fdf493ec0fb9d54b08bc1ad1c5ef6adcd9 |
Hashes for pytest_splunk_addon-1.3.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f96f1e22d307a0f1c4ebbf55b7d43b1a5fb053a6da27ce02af9fabd64c33542e |
|
MD5 | eb8716576ff081d94f8f68d9e0af6d29 |
|
BLAKE2b-256 | 23d672d2a767a132f470279ce1770820a2750bd599bc75ca7cfb6f6f5ed56577 |