You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Make json representation of the data models, which satisfies this [DataModelSchema](https://github.com/splunk/pytest-splunk-addon/blob/main/pytest_splunk_addon/standard_lib/cim_tests/DatamodelSchema.json).
450
+
- Make json representation of the data models, which satisfies this [DataModelSchema](https://github.com/splunk/pytest-splunk-addon/blob/main/pytest_splunk_addon/cim_tests/DatamodelSchema.json).
442
451
- Provide the path to the directory having all the data models by adding `--splunk_dm_path path_to_dir` to the pytest command
443
-
- The test cases will now be generated for the data models provided to the plugin and not for the [default data models](https://github.com/splunk/pytest-splunk-addon/tree/main/pytest_splunk_addon/standard_lib/data_models).
452
+
- The test cases will now be generated for the data models provided to the plugin and not for the [default data models](https://github.com/splunk/pytest-splunk-addon/tree/main/pytest_splunk_addon/data_models).
pytest-splunk-addon is an open-source dynamic test plugin for Splunk Apps and Add-ons
4
-
which allows the user to test knowledge objects, CIM compatibility and index time properties.
3
+
pytest-splunk-addon is an open-source dynamic test plugin for Splunk [Apps](https://docs.splunk.com/Splexicon:App) and [Add-ons](https://docs.splunk.com/Splexicon:Addon)
4
+
which allows the user to test [knowledge objects](https://docs.splunk.com/Splexicon:Knowledgeobject), [CIM](https://docs.splunk.com/Splexicon:CommonInformationModel) compatibility and [index time properties](https://docs.splunk.com/Splexicon:Indexedfield).
5
+
6
+
## Prerequisites
7
+
8
+
- Splunk App or Add-on package
9
+
- Splunk instance with App or Add-on installed (Not required if using Docker)
10
+
- Docker (Not required if using external Splunk instance)
5
11
6
12
## Support
7
13
8
14
-**Python**: 3.7
9
15
-**Platforms**: Linux, Windows and MacOS
10
16
11
-
## Features
12
-
13
-
- Generate tests for Splunk Knowledge objects in Splunk Technology Add-ons.
14
-
- Generate tests for checking CIM compatibility in Splunk Technology Add-ons.
15
-
- Generate tests for checking Splunk index-time properties in Splunk Technology Add-ons.
16
-
- Validate your add-ons using Splunk + Docker.
17
-
18
-
## Release notes
19
-
20
-
Find details about all the releases [here](https://github.com/splunk/pytest-splunk-addon/releases).
21
-
22
17
## Installation
23
18
24
19
pytest-splunk-addon can be installed via pip from PyPI:
25
20
26
21
```console
27
22
pip3 install pytest-splunk-addon
28
23
```
24
+
25
+
## Features
26
+
27
+
The pytest-splunk-addon works by dynamically generating different types of tests for Splunk apps and add-ons by parsing their configuration files. Specifically, it looks at the .conf files in the provided Splunk app/add-on to create:
28
+
29
+
1.[Knowledge Object Tests](./field_tests.md)
30
+
31
+
2.[CIM Compatibility Tests](./cim_tests.md)
32
+
33
+
3.[Index-Time Field Tests](./index_time_tests.md)
34
+
35
+
4.[Requirement Tests](./requirement_tests.md)
36
+
37
+
Refer to the [How to use](./how_to_use.md) section for detailed instructions on running the tests.
38
+
39
+
## Release notes
40
+
41
+
Find details about all the releases [here](https://github.com/splunk/pytest-splunk-addon/releases).
Testcase verifies that the event is mapped with the datamodel defined in the sample xml.
40
+
Here <datamodel> is the name of the datamodel that the event should be mapped with, <stanza> is the stanza name defined in the pytest-splunk-addon-data.conf and <host> is the host of the event
41
+
42
+
**Workflow:**
43
+
44
+
- Plugin gets the events and its expected datamodel from the sample xml
45
+
- Plugin generates a search query for that event and validates if the values of tags field are according to the datamodel defined in sample xml.
46
+
47
+
**3. All the cim recommended field should be extracted**
Testcase verifies that all the cim recommended fields of mapped datamodel are extracted for the event defined in the sample xml.
54
+
Here <datamodel> is the name of the datamodel that the event should be mapped with, <stanza> is the stanza name defined in the pytest-splunk-addon-data.conf and <host> is the host of the event
55
+
56
+
**Workflow:**
57
+
58
+
- For each events, plugin gets the list of fields defined under cim_fields and missing_recommended_fields.
59
+
- Field list retrieved from the sample xml should be equal to the list of recommended fields defined in the datamodel schema.
60
+
61
+
## Testcase Troubleshooting
62
+
63
+
In the case of test-case failure check if:
64
+
65
+
- The add-on to be tested is installed on the Splunk instance.
66
+
- Splunk licence has not expired.
67
+
- Splunk instance is up and running.
68
+
- Splunk instance's management port is accessible from the test machine.
69
+
70
+
If all the above conditions are satisfied, further analysis of the test is required.
71
+
For every test case failure, there is a defined structure for the stack trace.
72
+
73
+
```text
74
+
- test_requirements_fields
75
+
AssertionError: <<error_message>>
76
+
Field | Splunk Value | Expected Value
77
+
------| ------------ | --------------
78
+
str | str | str
79
+
Search = <Query>
80
+
81
+
- test_datamodels
82
+
AssertionError: <<error_message>>
83
+
Expected datamodel | Expected tags | Found datamodel | Found tags
Copy file name to clipboardExpand all lines: docs/sample_generator.md
+90Lines changed: 90 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,90 @@ The sample generation & ingestion takes place before executing the testcases.
5
5
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.
6
6
7
7
8
+
## Generate sample files
9
+
Pytest splunk addon supports 2 different formats of sample files
10
+
11
+
**1. Text format**
12
+
13
+
- Sample events can be generated from the live events by replacing the field values with the tokens. Token name should be enclosed with ##.
14
+
- Token replacement setting for this samples should be added to pytest-splunk-addon-data.conf to generate events
- Generate sample xml file using the format provided [here](https://github.com/splunk/pytest-splunk-addon/blob/main/pytest_splunk_addon/sample_generation/schema.xsd)
27
+
- Using xml format for the sample events, user can also execute requirement tests for the event for fields mentioned in the cim_fields and other_mappings
0 commit comments