Skip to content

Commit 82dd470

Browse files
docs: fixing documentation (#836)
- Updated the md files for proper reference. - Added missing brackets Fixes #834
1 parent b789bb4 commit 82dd470

File tree

8 files changed

+57
-58
lines changed

8 files changed

+57
-58
lines changed

Dockerfile.tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
FROM ubuntu:latest
16+
FROM ubuntu:22.04
1717

1818
RUN mkdir -p /work/tests
1919
RUN mkdir -p /work/test-results/functional

docs/cim_compliance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ There are two ways to generate the CIM Compliance report:
2929
- Append the following to [any one of the commands](how_to_use.md#test-execution) used for executing the test cases:
3030

3131
```console
32-
--cim-report <file_name.md
32+
--cim-report <file_name.md>
3333
```
3434

3535
**2. Generating the report using the test results stored in the junit-xml file**
3636

3737
- Execute the following command:
3838

3939
```console
40-
cim-report <junit_report.xml<report.md
40+
cim-report <junit_report.xml> <report.md>
4141
```
4242

4343
## Report Generation Troubleshooting

docs/cim_tests.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ To generate test cases only for CIM compatibility, append the following marker t
4141
```
4242

4343

44-
#### Testcase Assertions:
44+
#### Testcase Assertions:
4545

4646
- There should be at least 1 event mapped with the dataset.
4747
- Each required field should be extracted in all the events mapped with the datasets.
@@ -100,13 +100,13 @@ To generate test cases only for CIM compatibility, append the following marker t
100100
- Plugin gets a list of fields whose extractions are defined in props using addon_parser.
101101
- By comparing we obtain a list of fields whose extractions are not allowed but defined.
102102

103-
**5. Testcase to check that eventtype is not be mapped with multiple datamodels.**
103+
**5. Testcase to check that eventtype is not mapped with multiple datamodels.**
104104

105105

106106
**Workflow:**
107107

108108
- Parsing tags.conf it already has a list of eventtype mapped with the datasets.
109-
- Using SPL we check that each eventtype is not be mapped with multiple datamodels.
109+
- Using SPL we check that each eventtype is not mapped with multiple datamodels.
110110

111111
## Testcase Troubleshooting
112112

@@ -122,14 +122,14 @@ If all the above conditions are satisfied, further analysis of the test is requi
122122
For every CIM validation test case there is a defined structure for the stack trace.
123123

124124
```text
125-
AssertionError: <<error_message
125+
AssertionError: <<error_message>>
126126
Source | Sourcetype | Field | Event Count | Field Count | Invalid Field Count | Invalid Values
127127
-------- | --------------- | ------| ----------- | ----------- | ------------------- | --------------
128128
str | str | str | int | int | int | str
129129
130-
Search = <Query
130+
Search = <Query>
131131
132-
Properties for the field :: <field_name
132+
Properties for the field :: <field_name>
133133
type= Required/Conditional
134134
condition= Condition for field
135135
validity= EVAL conditions

docs/field_tests.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To generate test cases only for knowledge objects, append the following marker t
3333
```
3434

3535
Testcase verifies that there are events mapped with source/sourcetype.
36-
Here <stanza is the source/sourcetype that is defined in the stanza.
36+
Here &lt;stanza&gt; is the source/sourcetype that is defined in the stanza.
3737

3838
**Workflow:**
3939

@@ -43,12 +43,12 @@ To generate test cases only for knowledge objects, append the following marker t
4343
**2. Fields mentioned under source/sourcetype should be extracted**
4444

4545
```python
46-
test_props_fields[<stanza::field::<fieldname>]
46+
test_props_fields[<stanza>::field::<fieldname>]
4747
```
4848

4949
Testcase verifies that the field should be extracted in the source/sourcetype.
50-
Here <stanza is the source/sourcetype that is defined in the stanza and
51-
<fieldname is the name of a field which is extracted under source/sourcetype.
50+
Here &lt;stanza&gt; is the source/sourcetype that is defined in the stanza and
51+
&lt;fieldname&gt; is the name of a field which is extracted under source/sourcetype.
5252

5353
**Workflow:**
5454

@@ -62,8 +62,8 @@ To generate test cases only for knowledge objects, append the following marker t
6262
```
6363

6464
Testcase verifies that the field should not have "-" (dash) or "" (empty) as a value.
65-
Here <stanza is the source/sourcetype that is defined in the stanza and
66-
<fieldname is name of field which is extracted under source/sourcetype.
65+
Here &lt;stanza&gt; is the source/sourcetype that is defined in the stanza and
66+
&lt;fieldname&gt; is name of field which is extracted under source/sourcetype.
6767

6868
**Workflow:**
6969

@@ -90,7 +90,7 @@ To generate test cases only for knowledge objects, append the following marker t
9090

9191
- While parsing the conf file when the plugin finds one of EXTRACT, REPORT, LOOKUP
9292
the plugin gets the list of fields extracted and generates a test case.
93-
- For all the fields in the test case it generates a single SPL search query including the stanza and asserts event_count 0.
93+
- For all the fields in the test case it generates a single SPL search query including the stanza and asserts event_count > 0.
9494
- This verifies that all the fields are extracted in the same event.
9595

9696
**5. Events should be present in each eventtype**
@@ -104,7 +104,7 @@ To generate test cases only for knowledge objects, append the following marker t
104104

105105
**Workflow:**
106106

107-
- For each eventtype mentioned in eventtypes.conf plugin generates an SPL search query and asserts event_count 0 for the eventtype.
107+
- For each eventtype mentioned in eventtypes.conf plugin generates an SPL search query and asserts event_count > 0 for the eventtype.
108108

109109
**6. Tags defined in tags.conf should be applied to the events.**
110110

@@ -113,13 +113,13 @@ To generate test cases only for knowledge objects, append the following marker t
113113
```
114114

115115
Test case verifies that the there are events mapped with the tag.
116-
Here <tag_stanza is a stanza mentioned in tags.conf and <tag is an individual tag
116+
Here &lt;tag_stanza&gt; is a stanza mentioned in tags.conf and &lt;tag&gt; is an individual tag
117117
applied to that stanza.
118118

119119
**Workflow:**
120120

121121
- In tags.conf for each tag defined in the stanza, the plugin generates a test case.
122-
- For each tag, the plugin generates a search query including the stanza and the tag and asserts event_count 0.
122+
- For each tag, the plugin generates a search query including the stanza and the tag and asserts event_count > 0.
123123

124124
**7. Search query should be present in each savedsearches.**
125125

@@ -133,7 +133,7 @@ To generate test cases only for knowledge objects, append the following marker t
133133
**Workflow:**
134134

135135
- In savedsearches.conf for each stanza, the plugin generates a test case.
136-
- For each stanza mentioned in savedsearches.conf plugin generates an SPL search query and asserts event_count 0 for the savedsearch.
136+
- For each stanza mentioned in savedsearches.conf plugin generates an SPL search query and asserts event_count > 0 for the savedsearch.
137137

138138
## Testcase Troubleshooting
139139

@@ -150,8 +150,8 @@ If all the above conditions are satisfied, further analysis of the test is requi
150150
For every test case failure, there is a defined structure for the stack trace.
151151

152152
```text
153-
AssertionError: <<error_message
154-
Search = <Query
153+
AssertionError: <<error_message>>
154+
Search = <Query>
155155
```
156156

157157
Get the search query from the stack trace and execute it on the Splunk instance and verify which specific type of events are causing failure.

docs/generate_conf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
- Execute the following command:
4646

4747
```console
48-
generate-indextime-conf <path-to-addon [<path-to-the-new-conf-file]
48+
generate-indextime-conf <path-to-addon> [<path-to-the-new-conf-file>]
4949
```
5050
5151
For example:

docs/how_to_use.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ There are three ways to execute the tests:
2020
Run pytest with the add-on, in an external Splunk deployment
2121

2222
```bash
23-
pytest --splunk-type=external --splunk-app=<path-to-addon-package --splunk-data-generator=<path to pytest-splunk-addon-data.conf file --splunk-host=<hostname --splunk-port=<splunk-management-port --splunk-user=<username --splunk-password=<password --splunk-hec-token=<splunk_hec_token
23+
pytest --splunk-type=external --splunk-app=<path-to-addon-package> --splunk-data-generator=<path to pytest-splunk-addon-data.conf file> --splunk-host=<hostname> --splunk-port=<splunk-management-port> --splunk-user=<username> --splunk-password=<password> --splunk-hec-token=<splunk_hec_token>
2424
```
2525

2626
**2. Running tests with docker splunk**
@@ -101,6 +101,7 @@ services:
101101
SPLUNK_APP_ID: ${SPLUNK_APP_ID}
102102
SPLUNK_APP_PACKAGE: ${SPLUNK_APP_PACKAGE}
103103
SPLUNK_VERSION: ${SPLUNK_VERSION}
104+
platform: linux/amd64
104105
ports:
105106
- "8000"
106107
- "8088"
@@ -120,6 +121,7 @@ services:
120121
SPLUNK_APP_ID: ${SPLUNK_APP_ID}
121122
SPLUNK_APP_PACKAGE: ${SPLUNK_APP_PACKAGE}
122123
SPLUNK_VERSION: ${SPLUNK_VERSION}
124+
platform: linux/amd64
123125
hostname: uf
124126
ports:
125127
- "9997"
@@ -132,13 +134,10 @@ services:
132134
volumes:
133135
- ${CURRENT_DIR}/uf_files:${CURRENT_DIR}/uf_files
134136
135-
volumes:
136-
splunk-sc4s-var:
137-
external: false
138137
```
139138
</details>
140139

141-
<details>
140+
<details id="conftest">
142141
<summary>Create conftest.py file</summary>
143142

144143
```
@@ -184,7 +183,7 @@ def docker_services_project_name(pytestconfig):
184183
Run pytest with the add-on, using the following command:
185184

186185
```bash
187-
pytest --splunk-type=docker --splunk-data-generator=<path to pytest-splunk-addon-data.conf file
186+
pytest --splunk-type=docker --splunk-data-generator=<path to pytest-splunk-addon-data.conf file>
188187
```
189188

190189
The tool assumes the Splunk Add-on is located in a folder "package" in the project root.
@@ -209,15 +208,15 @@ The tool assumes the Splunk Add-on is located in a folder "package" in the proje
209208

210209
```bash
211210
pytest --splunk-type=external # Whether you want to run the addon with docker or an external Splunk instance
212-
--splunk-app=<path-to-addon-package # Path to Splunk app package. The package should have the configuration files in the default folder.
213-
--splunk-host=<hostname # Receiver Splunk instance where events are searchable.
214-
--splunk-port=<splunk_management_port # default 8089
215-
--splunk-user=<username # default admin
216-
--splunk-password=<password # default Chang3d!
217-
--splunk-forwarder-host=<splunk_forwarder_host # Splunk instance where forwarding to receiver instance is configured.
218-
--splunk-hec-port=<splunk_forwarder_hec_port # HEC port of the forwarder instance.
219-
--splunk-hec-token=<splunk_forwarder_hec_token # HEC token configured in forwarder instance.
220-
--splunk-data-generator=<pytest_splunk_addon_conf_path # Path to pytest-splunk-addon-data.conf
211+
--splunk-app=<path-to-addon-package> # Path to Splunk app package. The package should have the configuration files in the default folder.
212+
--splunk-host=<hostname> # Receiver Splunk instance where events are searchable.
213+
--splunk-port=<splunk_management_port> # default 8089
214+
--splunk-user=<username> # default admin
215+
--splunk-password=<password> # default Chang3d!
216+
--splunk-forwarder-host=<splunk_forwarder_host> # Splunk instance where forwarding to receiver instance is configured.
217+
--splunk-hec-port=<splunk_forwarder_hec_port> # HEC port of the forwarder instance.
218+
--splunk-hec-token=<splunk_forwarder_hec_token> # HEC token configured in forwarder instance.
219+
--splunk-data-generator=<pytest_splunk_addon_conf_path> # Path to pytest-splunk-addon-data.conf
221220
```
222221

223222
> **_NOTE:_**
@@ -243,10 +242,10 @@ There are 3 types of tests included in pytest-splunk-addon are:
243242
3. To generate test cases only for index time properties, append the following marker to pytest command:
244243

245244
```console
246-
-m splunk_indextime --splunk-data-generator=<Path to the conf file
245+
-m splunk_indextime --splunk-data-generator=<Path to the conf file>
247246
```
248247
249-
For detailed information on index time test execution, please refer {ref}`here <index_time_tests`.
248+
For detailed information on index time test execution, please refer [here](./index_time_tests.md).
250249

251250
- To execute all the searchtime tests together, i.e both Knowledge objects and CIM compatibility tests,
252251
append the following marker to the pytest command:
@@ -262,19 +261,19 @@ The following optional arguments are available to modify the default settings in
262261
1. To search for events in a specific index, user can provide following additional arguments:
263262

264263
```console
265-
--search-index=<index
264+
--search-index=<index>
266265
267266
Splunk index of which the events will be searched while testing. Default value: "*, _internal".
268267
```
269268

270269
2. To increase/decrease time interval and retries for flaky tests, user can provide following additional arguments:
271270

272271
```console
273-
--search-retry=<retry
272+
--search-retry=<retry>
274273
275274
Number of retries to make if there are no events found while searching in the Splunk instance. Default value: 0.
276275
277-
--search-interval=<interval
276+
--search-interval=<interval>
278277
279278
Time interval to wait before retrying the search query.Default value: 0.
280279
```
@@ -297,7 +296,7 @@ The following optional arguments are available to modify the default settings in
297296
- **Addon related errors:** To suppress these user can create a file with the list of strings and provide the file in the **--ignore-addon-errors** param while test execution.
298297
299298
```console
300-
--ignore-addon-errors=<path_to_file
299+
--ignore-addon-errors=<path_to_file>
301300
```
302301
303302
- Sample strings in the file.
@@ -328,7 +327,7 @@ The following optional arguments are available to modify the default settings in
328327
- Default value for this parameter is *store_new*
329328

330329
```console
331-
--event-file-path=<path_to_file
330+
--event-file-path=<path_to_file>
332331
```
333332

334333
- Path to tokenized events file
@@ -380,7 +379,7 @@ The following optional arguments are available to modify the default settings in
380379

381380
**3. Setup test environment before executing the test cases**
382381

383-
If any setup is required in the Splunk/test environment before executing the test cases, implement a fixture in {ref}`conftest.py <conftest_file`.
382+
If any setup is required in the Splunk/test environment before executing the test cases, implement a fixture in [conftest.py](#conftest).
384383

385384
```python
386385
@pytest.fixture(scope="session")

docs/index_time_tests.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
### Prerequisites
1515

1616
- `pytest-splunk-addon-data.conf` file which contains all the required data
17-
executing the tests. The conf file should follow the specifications as mentioned {ref}`here <conf_spec`.
17+
executing the tests. The conf file should follow the specifications as mentioned [here](./sample_generator.md#pytest-splunk-addon-dataconfspec).
1818

1919
______________________________________________________________________
2020

2121

2222
To generate test cases only for index time properties, append the following marker to pytest command:
2323

2424
```console
25-
-m splunk_indextime --splunk-data-generator=<Path to the conf file
25+
-m splunk_indextime --splunk-data-generator=<Path to the conf file>
2626
```
2727

2828
> **_NOTE:_** --splunk-data-generator should contain the path to *pytest-splunk-addon-data.conf*,
@@ -55,7 +55,7 @@ To generate test cases only for index time properties, append the following mark
5555
- This test case will not be generated if there are no key fields specified for the event.
5656
- Key field can be assign to token using field property. `i.e token.n.field = <KEY_FIELD>`
5757

58-
Testcase assertions:
58+
#### Testcase Assertions:
5959

6060
- There should be at least 1 event with the sourcetype and host.
6161
- The values of the key fields obtained from the event
@@ -72,7 +72,7 @@ To generate test cases only for index time properties, append the following mark
7272

7373
- Execute the SPL query in a Splunk instance.
7474

75-
- Assert the test case results as mentioned in {ref}`testcase assertions<test_assertions_key_field`.
75+
- Assert the test case results as mentioned in [testcase assertions](#testcase-assertions).
7676

7777
**2. Test case for _time property:**
7878

@@ -141,8 +141,8 @@ If all the above conditions are satisfied, further analysis of the test is requi
141141
For every test case failure, there is a defined structure for the stack trace.
142142

143143
```text
144-
AssertionError: <<error_message
145-
Search = <Query
144+
AssertionError: <<error_message>>
145+
Search = <Query>
146146
```
147147

148148
Get the search query from the stack trace and execute it on the Splunk instance and verify which specific type of events are causing failure.
@@ -229,9 +229,9 @@ Get the search query from the stack trace and execute it on the Splunk instance
229229
230230
- No test would generate to test Key Fields for that particular stanza and thus won't be correctly tested.
231231
232-
8. When do I assign token.\<n.field = \<field_name to test the Key Fields for an event?
232+
8. When do I assign token.&lt;n&gt;.field = &lt;field_name&gt; to test the Key Fields for an event?
233233
234-
- When there props configurations written in props to extract any of the field present in Key Fields list, you should add `token.<n.field = <field_name` to the token for that field value.
234+
- When there props configurations written in props to extract any of the field present in Key Fields list, you should add `token.<n>.field = <field_name>` to the token for that field value.
235235
- Example:
236236
: For this sample, there is report written in props that extracts `127.0.0.1` as `src`,
237237

0 commit comments

Comments
 (0)