pipelineBuilder_test.go
pipelineBuilder_test.go - Overview
-
Overview This file contains unit tests for the log parsing pipeline builder, specifically focusing on pipeline processor preparation and simulation. It tests scenarios such as enabling/disabling operators, handling mismatched logs, resource filters, case-insensitive filters, and attribute paths in processors.
-
Detailed Documentation
var prepareProcessorTestData
- Purpose: Defines a slice of test cases for the
getOperators
function. Each test case includes a set of pipeline operators and the expected output after processing. - Type:
[]struct
Name
(string
): Name of the test case.Operators
([]pipelinetypes.PipelineOperator
): Input slice of pipeline operators.Output
([]pipelinetypes.PipelineOperator
): Expected output slice of pipeline operators after processing.
func TestPreparePipelineProcessor(t *testing.T)
- Purpose: Tests the
getOperators
function by iterating through theprepareProcessorTestData
and comparing the actual output with the expected output. - Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
func TestNoCollectorErrorsFromProcessorsForMismatchedLogs(t *testing.T)
- Purpose: Tests that the pipeline processors do not produce errors or warnings when processing logs that do not match the processor's criteria (e.g., missing fields, invalid data).
- Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
func TestResourceFiltersWork(t *testing.T)
- Purpose: Tests that resource filters in the pipeline configuration correctly filter logs based on resource attributes.
- Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
func TestPipelineFilterWithStringOpsShouldNotSpamWarningsIfAttributeIsMissing(t *testing.T)
- Purpose: Tests that pipeline filters with string operations (contains, not contains, regex, not regex) do not generate excessive warnings when the attribute being filtered on is missing from the log.
- Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
func TestAttributePathsContainingDollarDoNotBreakCollector(t *testing.T)
- Purpose: Tests that attribute paths containing dollar signs ($) are correctly handled by the pipeline and do not cause errors in the collector.
- Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
func TestMembershipOpInProcessorFieldExpressions(t *testing.T)
- Purpose: Tests the usage of membership operators and field expressions within pipeline processor configurations, ensuring correct data extraction and transformation.
- Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
func TestContainsFilterIsCaseInsensitive(t *testing.T)
- Purpose: Tests that the "contains" and "ncontains" filter operators are case-insensitive when applied in pipeline filters.
- Parameters:
t
(*testing.T
): Testing framework object.
- Returns: None
makeTestPipeline
- Purpose: Helper function to create a
GettablePipeline
instance for testing. - Parameters:
config
([]pipelinetypes.PipelineOperator
): The configuration of pipeline operators.
- Returns:
pipelinetypes.GettablePipeline
: AGettablePipeline
instance.
makeTestLog
- Purpose: Helper function to create a
SignozLog
instance for testing. - Parameters:
body
(string
): The body of the log.attributes
(map[string]string
): The attributes of the log.
- Returns:
model.SignozLog
: ASignozLog
instance.
makeTestSignozLog
- Purpose: Helper function to create a
SignozLog
instance for testing with a flexible attribute type. - Parameters:
body
(string
): The body of the log.attributes
(map[string]interface{}
): The attributes of the log, can be any type.
- Returns:
model.SignozLog
: ASignozLog
instance.
-
Code Examples None
-
Clarity and Accuracy The documentation is based on the code provided and aims to be accurate and clear.
Include in Getting Started: NO