IndexTimeTests¶
Test generation mechanism to verify the index time extractions of an Add-on
TestTemplates¶
Includes the test scenarios to check the index time properties of an Add-on.
-
class
standard_lib.index_tests.test_templates.
IndexTimeTestTemplate
[source]¶ Bases:
object
Test templates to test the index time fields of an App
-
test_indextime_key_fields
(splunk_search_util, splunk_ingest_data, splunk_setup, splunk_indextime_key_fields, record_property, caplog)[source]¶ This test case checks that a key_field has the expected values. The key fields are as follows:
src
src_port
dest
dest_port
dvc
host
user
url
- Parameters
splunk_search_util (SearchUtil) – Object that helps to search on Splunk.
splunk_ingest_data (fixture) – To ingest data into splunk.
splunk_indextime_key_fields (fixture) – Test for key fields
record_property (fixture) – Document facts of test cases.
caplog (fixture) – fixture to capture logs.
-
test_indextime_line_breaker
(splunk_search_util, splunk_ingest_data, splunk_setup, splunk_indextime_line_breaker, record_property, caplog)[source]¶ This test case checks that number of events is as expected.
- Parameters
splunk_search_util (SearchUtil) – Object that helps to search on Splunk.
splunk_ingest_data (fixture) – To ingest data into splunk.
splunk_indextime_line_breaker (fixture) – Test for event count
record_property (fixture) – Document facts of test cases.
caplog (fixture) – fixture to capture logs.
-
test_indextime_time
(splunk_search_util, splunk_ingest_data, splunk_setup, splunk_indextime_time, record_property, caplog)[source]¶ This test case checks that _time value in the events has the expected values.
- Parameters
splunk_search_util (SearchUtil) – Object that helps to search on Splunk.
splunk_ingest_data (fixture) – To ingest data into splunk.
splunk_indextime_time (fixture) – Test for _time field
record_property (fixture) – Document facts of test cases.
caplog (fixture) – fixture to capture logs.
-
TestGenerator¶
-
class
standard_lib.index_tests.test_generator.
IndexTimeTestGenerator
[source]¶ Bases:
object
Generates test cases to test the index time extraction of an Add-on.
Provides the pytest parameters to the test templates.
Supports key_fields: List of fields which should be tested for the Add-on.
-
add_host_prefix
(host_prefix, hosts)[source]¶ Returns value of host with prefix
- Parameters
host_prefix (str) – Prefix value to be added in host
hosts (list) – List of host
- Returns
Value of host with prefix
-
generate_hosts_params
(tokenized_event, hosts)[source]¶ Generates test case based on host value of the event
- Parameters
tokenized_event (SampleEvent) – Instance containing event info
hosts (list) – List of hosts for event
- Yields
pytest.params for the test templates
-
generate_identifier_params
(tokenized_event, identifier_key)[source]¶ Generates test case based on Identifier key mentioned in conf file
- Parameters
tokenized_event (SampleEvent) – Instance containing event info
identifier_key (str) – Identifier Key if mention in conf file
- Yields
pytest.params for the test templates
-
generate_line_breaker_tests
(tokenized_events)[source]¶ Generates test case for testing line breaker
- Parameters
tokenized_events (list) – List of tokenized events
- Yields
pytest.params for the test templates
-
generate_params
(tokenized_event, identifier_key, hosts)[source]¶ Generates test case based on parameters
- Parameters
tokenized_event (SampleEvent) – Instance containing event info
identifier_key (str) – Identifier Key if mention in conf file
hosts (list) – List of host for event
- Yields
pytest.params for the test templates
-
generate_tests
(store_events, app_path, config_path, test_type)[source]¶ Generates the test cases based on test_type
- Parameters
app_path (str) – Path of the app package
config_path (str) – Path of package which contains pytest-splunk-addon-data.conf
test_type (str) – Type of test case
- Yields
pytest.params for the test templates
-
get_hosts
(tokenized_event)[source]¶ Returns value of host for event
- Parameters
tokenized_event (SampleEvent) – Instance containing event info
- Returns
Value of host for event
-
get_source
(sample_event)[source]¶ Returns value of source for event
- Parameters
sample_event (SampleEvent) – Instance containing event info
- Returns
Value of source for event
-
get_sourcetype
(sample_event)[source]¶ Returns value of sourcetype for event
- Parameters
sample_event (SampleEvent) – Instance containing event info
- Returns
Value of sourcetype for event