Skip to content

Add unit tests for SyslogUtils#26488

Open
karimbabasf wants to merge 2 commits into
Graylog2:masterfrom
karimbabasf:test/add-syslogutils-tests
Open

Add unit tests for SyslogUtils#26488
karimbabasf wants to merge 2 commits into
Graylog2:masterfrom
karimbabasf:test/add-syslogutils-tests

Conversation

@karimbabasf

Copy link
Copy Markdown

Description

Adds unit test coverage for SyslogUtils, which previously had no tests. This is a test-only change — no production code is modified.

Motivation and Context

SyslogUtils provides the RFC 5424 syslog severity/facility name lookups (levelToString, facilityToString) and the priority decomposition helpers (levelFromPriority, facilityFromPriority) used by the pipeline processor's syslog functions. It had no test coverage, so a future change could silently break the RFC 5424 mappings without any test failing. These characterization tests pin the documented behavior.

How Has This Been Tested?

Added SyslogUtilsTest (JUnit 5 + AssertJ, matching the module's house style). 51 parameterized cases:

  • all severities 07 map to the RFC 5424 names, and out-of-range values (incl. Integer.MIN/MAX_VALUE) return "Unknown";
  • all facilities 023 map to their names, and out-of-range values return "Unknown";
  • priority decomposition, including the two RFC 5424 worked examples (PRI 34auth/Critical, PRI 165local4/Notice);
  • a round-trip property check confirming facility * 8 + level == priority for every valid PRI value 0191.

All 51 cases pass locally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Test-only change: adds coverage for existing behavior, no functional change.

Checklist

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • My change requires a change to the documentation. (n/a — test-only)

SyslogUtils had no test coverage. Add characterization tests for the
RFC 5424 level and facility lookup tables (every documented value plus
out-of-range inputs), and for the priority bit-math helpers including
the two RFC 5424 worked examples and a round-trip property check over
all valid PRI values.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jun 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants