Skip to content

Commit

Permalink
PCLOUDS-3547 - filters tests (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-paskal-dynatrace committed Mar 28, 2024
1 parent 7efa443 commit 8536942
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,21 @@ def test_all_filters_filter_out():
os.environ["FILTER_CONFIG"] = "FILTER.GLOBAL.MIN_LOG_LEVEL=2;FILTER.GLOBAL.CONTAINS_PATTERN=*pattern*;FILTER.RESOURCE_TYPE.MIN_LOG_LEVEL.MICROSOFT.WEB/SITES=3;FILTER.RESOURCE_TYPE.CONTAINS_PATTERN.MICROSOFT.WEB/SITES=*pattern*;FILTER.RESOURCE_ID.MIN_LOG_LEVEL./SUBSCRIPTIONS/69B51384-146C-4685-9DAB-5AE01877D7B8/RESOURCEGROUPS/LOGS-INGEST-FUNCTION/PROVIDERS/MICROSOFT.WEB/SITES/INGEST-LOGS-FUNCTION=Informational;FILTER.RESOURCE_ID.CONTAINS_PATTERN./SUBSCRIPTIONS/69B51384-146C-4685-9DAB-5AE01877D7B8/RESOURCEGROUPS/LOGS-INGEST-FUNCTION/PROVIDERS/MICROSOFT.WEB/SITES/INGEST-LOGS-FUNCTION=pattern"
log_filter = LogFilter()
assert log_filter.should_filter_out_record(parsed_record)


def test_filter_global_with_bad_or_condition():
os.environ["FILTER_CONFIG"] = "FILTER.GLOBAL.MIN_LOG_LEVEL=3;FILTER.GLOBAL.CONTAINS_PATTERN=Executed* | *Functions* | *not_fitting*"
log_filter = LogFilter()
assert log_filter.should_filter_out_record(parsed_record)


def test_filter_global_with_good_or_conditions():
os.environ["FILTER_CONFIG"] = "FILTER.GLOBAL.CONTAINS_PATTERN=*logs_ingest* | *Succeeded*"
log_filter = LogFilter()
assert not log_filter.should_filter_out_record(parsed_record)


def test_filter_global_with_only_bad_conditions():
os.environ["FILTER_CONFIG"] = "FILTER.GLOBAL.CONTAINS_PATTERN=*bad* | *not_fitting_anything*"
log_filter = LogFilter()
assert log_filter.should_filter_out_record(parsed_record)

0 comments on commit 8536942

Please sign in to comment.