Skip to content

Commit 6923aff

Browse files
Merge pull request #169 from splunk/feature/index-time-tests-documentation
ACD-4525: Added FAQ section in Doc
2 parents 75ce3a9 + 5752f39 commit 6923aff

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

docs/index_time_tests.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,90 @@ For every test case failure, there is a defined structure for the stack trace [1
154154
155155
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.
156156

157+
158+
FAQ
159+
----
160+
161+
1. What is the source of data used while testing with pytest-splunk-addon 1.3.0 and above?
162+
* pytest-splunk-addon relies on samples available in addon available in samples folder under path provided ``--splunk-app`` or ``--splunk-data-generator`` options.
163+
2. When do I assign timestamp_type = event to test the time extraction (_time) for a stanza?
164+
* When the Splunk assigns _time value from a timestamp present in event based on props configurations, you should assign ``timestamp_type=event`` for that sample stanza.
165+
* Example:
166+
For this sample, Splunk assigns the value ``2020-06-23T00:00:00.000Z`` to ``_time``.
167+
168+
.. code-block:: text
169+
170+
2020-06-23T00:00:00.000Z test_sample_1 test_static=##token_static_field## . . .
171+
172+
In this scenario the value ``2020-06-23T00:00:00.000Z`` should be tokenized, stanza should have ``timestamp_type=event`` and the token should also have ``token.0.field = _time`` as shown below:
173+
174+
.. code-block:: text
175+
176+
token.0.token = (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+)
177+
token.0.replacementType = timestamp
178+
token.0.replacement = %Y-%m-%dT%H:%M:%S
179+
token.0.field = _time
180+
3. When do I assign timestamp_type = plugin to test the time extraction (_time) for a stanza?
181+
* When there is no timestamp available in event or the props configurations are written to have the Splunk default timestamp assigned instead timestamp present in event, you should assign ``timestamp_type=plugin`` for that sample stanza.
182+
* No _time test generates for the sample stanza when ``timestamp_type = plugin``.
183+
* Example:
184+
For this sample, Splunk assigns the value ``2020-06-23T00:00:00.000Z`` to ``_time``.
185+
186+
.. code-block:: text
187+
188+
test_sample_1 test_static=##token_static_field## src=##token_src_ipv4## . . .
189+
190+
In this scenario, the stanza should have ``timestamp_type=plugin``.
191+
4. When do I assign host_type = plugin for a sample stanza?
192+
* When there are no configurations written in props to override the host value in event and Splunk default host value is assigned for host field instead of a value present in event, you should assign ``host_type=plugin`` for that sample stanza.
193+
5. When do I assign host_type = event for a sample stanza?
194+
* When there are some configurations written in props to override the host value for an event you should assign ``host_type=event`` for that sample stanza.
195+
* Example:
196+
For this sample, Splunk assigns the value sample_host to host based on the props configurations present in addon
197+
198+
.. code-block:: text
199+
200+
test_modinput_1 host=sample_host static_value_2=##static_value_2## . . .
201+
202+
In this scenario the value "sample_host" should be tokenized, stanza should have ``host_type=event`` and the token should also have ``token.0.field = host`` as shown below:
203+
204+
.. code-block:: text
205+
206+
token.0.token = ##host_value##
207+
token.0.replacementType = random
208+
token.0.replacement = host["host"]
209+
token.0.field = host
210+
6. Can I assign test any field present in my event as Key Field in Key Fields tests?
211+
* No, Key Fields are defined in plugin and only below fields can be validated as part of Key Field tests.
212+
213+
* src
214+
* src_port
215+
* dest
216+
* dest_port
217+
* dvc
218+
* host
219+
* user
220+
* url
221+
7. What if I don't assign any field as key_field in a particular stanza even if its present in props?
222+
* No test would generate to test Key Fields for that particular stanza and thus won't be correctly tested.
223+
8. When do I assign token.<n>.field = <field_name> to test the Key Fields for an event?
224+
* 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.
225+
* Example:
226+
For this sample, there is report written in props that extracts ``127.0.0.1`` as ``src``,
227+
228+
.. code-block:: text
229+
230+
2020-06-23T00:00:00.000Z test_sample_1 127.0.0.1
231+
232+
In this scenario the value ``127.0.0.1`` should be tokenized and the token should also have ``token.0.field = src`` as shown below:
233+
234+
.. code-block:: text
235+
236+
token.0.token = ##src_value##
237+
token.0.replacementType = random
238+
token.0.replacement = src["ipv4"]
239+
token.0.field = src
240+
157241
------------
158242

159243
.. [1] Stacktrace is the text displayed in the Exception block when the Test fails.

0 commit comments

Comments
 (0)