This guide is intended for DLTK developers and anyone who wants to create and run DLTK tests.
The main script for running tests is test/test.py
, located in the root of the repository. The following sections describe possible ways for executing the test script.
The most straightforward approach is running the test/test.bash shell script.
The following illustrates the how to run the tests:
cd $DLTK_REPO/test
./test.bash
Requirements:
$SPLUNK_HOME
on the same hostSPLUNK_PASSWORD
is set to the password of the admin user of the Splunk instanceapp
folder to SPLUNK_HOME/etc/apps/dltk
)DLTK_ENVIRONMENT
is set to the name of the Kubernetes execution environmentDLTK_APP_NAME
is set to the name of the DLTK Splunk app (defaults to dltk
)This repository contains Visual Stop Code configuration, including a Task definition (see .vscode/tasks.json) for running the tests.
Use the keyboard shortcut Ctrl+Shift+P
to open the command palette and enter Tasks: Run Test Task
.
Optionally, environment variables (like DLTK_ENVIRONMENT
and SPLUNK_PASSWORD
) can be defined in the file run.env
, located in the test/ folder. For example:
DLTK_ENVIRONMENT="my-kubernetes-cluster"
SPLUNK_PASSWORD="changeme"`
Note: Since the task wraps the test/test.bash shell script, the same requirements apply here.
One of the steps that are part of the DLTK build process is running the tests.
If you are looking for documentation on how to build DLTK, please see the Build Guide.
If you want to create and add tests for DLTK, create the test_*.py file in the module that contains the code that you want to test.
Tests are build using the https://docs.python.org/3/library/unittest.html Python testing framework.
TODO: Explain the different type of tests and provide a examples