Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @edersonbrilhante @arys-splunk
* @arys-splunk
154 changes: 76 additions & 78 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,7 @@ jobs:
uses: returntocorp/semgrep-action@v1
with:
publishToken: ${{ secrets.SEMGREP_PUBLISH_TOKEN }}

snyk:
name: security-vuln-snyk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: snyk/actions/setup@master
- uses: actions/[email protected]
with:
go-version: "1.13"
- name: Snyk monitor
run: snyk test --sarif-file-output=snyk-scan_requirements.sarif --all-projects --print-deps --severity-threshold=high
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- uses: actions/upload-artifact@v2
if: always()
with:
name: snyk-results
path: snyk-scan_requirements.sarif


review_secrets:
name: security-detect-secrets
runs-on: ubuntu-latest
Expand All @@ -116,10 +93,59 @@ jobs:
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}


test-splunk-unit:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install
poetry run coverage run --source=./pytest_splunk_addon/standard_lib -m pytest -v tests/unit
poetry run coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
verbose: true

test-splunk-doc:
name: Test Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install and run tests
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install -E docker
poetry add --dev sphinx-rtd-theme
poetry add --dev sphinx-panels
poetry run pytest -v -m doc

test-splunk-external:
runs-on: ubuntu-latest
name: Test splunk external
needs:
- pre-commit
- compliance-dependencies
- compliance-copyrights
- test-splunk-doc
- test-splunk-unit
- review_secrets
- review-dog-misspell
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -160,31 +186,31 @@ jobs:
name: splunk ${{ matrix.splunk-version }} external test artifacts
path: |
test-results-${{ matrix.splunk-version }}

test-splunk-doc:
name: Test Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install and run tests
run: |
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
curl -sSL https://install.python-poetry.org | python3 -
poetry install -E docker
poetry run pytest -v --splunk-version=${{ matrix.splunk-version }} -m doc

test-splunk-matrix:
name: Test Matrix
needs:
- pre-commit
- compliance-dependencies
- compliance-copyrights
- test-splunk-doc
- test-splunk-unit
- review_secrets
- review-dog-misspell
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
splunk-version: [8.1, 8.2]
test-name: [
"test_splunk_connection_docker",
"test_splunk_app_fiction",
"test_splunk_app_broken",
"test_splunk_app_cim",
"test_splunk_fiction_indextime",
"test_splunk_setup_fixture",
"test_splunk_app_requirements"
]
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -195,43 +221,15 @@ jobs:
python-version: 3.7
- name: Install and run tests
run: |
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
curl -sSL https://install.python-poetry.org | python3 -
poetry install -E docker
poetry run pytest -v --splunk-version=${{ matrix.splunk-version }} -m docker

test-splunk-unit:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
curl -sSL https://install.python-poetry.org | python3 -
poetry install
poetry run coverage run --source=./pytest_splunk_addon/standard_lib -m pytest -v tests/unit
poetry run coverage html
- name: Archive test coverage results
uses: actions/upload-artifact@v2
with:
name: code-coverage-report-unit-tests
path: htmlcov
poetry run pytest -v --splunk-version=${{ matrix.splunk-version }} -m docker -k ${{ matrix.test-name }}

publish:
name: publish
needs:
- pre-commit
- compliance-dependencies
- compliance-copyrights
- test-splunk-external
- test-splunk-doc
- test-splunk-matrix
- test-splunk-unit
- review_secrets
- review-dog-misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -247,15 +245,15 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install and build
- uses: actions/download-artifact@v2
with:
name: analysis-reports
path: /tmp/analysis-reports
- name: Update Notices
run: cp -f /tmp/analysis-reports/NOTICE_summary NOTICE
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry build
- uses: actions/upload-artifact@v2
if: always()
with:
name: Package
path: dist/
- name: Semantic Release
uses: cycjimmy/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repos:
rev: v4.1.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
Expand Down
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pytest-splunk-addon Copyright (c) 2019, Splunk, Inc

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -188,7 +186,7 @@ pytest-splunk-addon Copyright (c) 2019, Splunk, Inc
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2022 Splunk Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

31 changes: 12 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,18 @@ You can install "pytest-splunk-addon" via `pip`_ from `PyPI`_::
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
Note: Must install docker desktop.

.. code:: bash

$ git clone --recurse-submodules -j8 [email protected]: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

$ cd pytest-splunk-addon

$ pip3 install -r requirements.txt

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

$ python setup.py develop

$ poetry install
$ ... (change something)
# run unit tests
$ poetry run pytest tests/unit
# run some of the docker-based tests to verify end-to-end behaviour, example:
$ poetry run pytest -v --splunk-version=8.2 -m docker tests/test_splunk_addon.py::test_splunk_app_requirements_modinput


Usage
Expand Down Expand Up @@ -90,9 +81,11 @@ Create a test file in the tests folder
.. code:: python3

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


class Test_App(Basic):
def empty_method():
pass

Create a Dockerfile-splunk file

Expand Down
6 changes: 3 additions & 3 deletions docs/api_reference/sample_generation.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
DataGenerator
------------------

EventgenParser
~~~~~~~~~~~~~~~~~~
.. automodule:: standard_lib.sample_generation.eventgen_parser
PytestSplunkAddonDataParser
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: standard_lib.sample_generation.pytest_splunk_addon_data_parser
:members:
:show-inheritance:

Expand Down
6 changes: 5 additions & 1 deletion docs/generate_conf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ Generate Conf Utility
.. _generate_conf:

Overview
""""""""""
""""""""

.. note::

This is deprecated since `pytest-splunk-addon` v1.12.0 and latest available version is v1.11.4.

* The utility helps in creating the `pytest-splunk-addon-data.conf` from the existing `eventgen.conf` of the add-on.
* The utility adds the following metadata required for the index-times tests in the new conf file:
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pytest-splunk-addon documentation
index_time_tests
sample_generator
generate_conf
release_history
api_reference/api_reference
troubleshoot

Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Features
Release notes
-------------

Find details about all the releases here: :ref:`Release History Page<release_history>`
Find details about all the releases `here <https://github.com/splunk/pytest-splunk-addon/releases>`_.

Installation
------------
Expand Down
7 changes: 0 additions & 7 deletions docs/release_history.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/sample_generator.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Data Generator
===============

To ingest samples into Splunk, plugin takes `pytest-splunk-addon-data.conf` or `eventgen.conf` as input.
To ingest samples into Splunk, plugin takes `pytest-splunk-addon-data.conf` as input.
The sample generation & ingestion takes place before executing the testcases.
For index-time test cases, there are multiple metadata required about the sample file for which `pytest-splunk-addon-data.conf` must be created and provided to the pytest command.

Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export PATH="~/.pyenv/bin:$PATH" ;\
eval "$(pyenv init -)" ;\
pyenv install 3.7.8 ;\
pyenv local 3.7.8 ;\
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
source ~/.poetry/env
sleep 15
poetry install -E docker
exec poetry run pytest -vv $@
exec poetry run pytest -vv $@
Loading