Skip to content

test(golang_router): add cleanup and cross-day rolling coverage for logger#23

Merged
mouxinqq merged 1 commit intodevelopfrom
codex/add-unit-test-for-startlogcleanup
Apr 14, 2026
Merged

test(golang_router): add cleanup and cross-day rolling coverage for logger#23
mouxinqq merged 1 commit intodevelopfrom
codex/add-unit-test-for-startlogcleanup

Conversation

@mouxinqq
Copy link
Copy Markdown
Owner

Motivation

  • Ensure StartLogCleanup behavior is covered for file output, ensuring expired archived logs are removed, recent/today files are preserved, and the cleanup goroutine stops on context cancellation.
  • Validate rotating writer day-rollover behavior including the grace-period routing of late previous-day log lines and symlink update semantics.

Description

  • Added unit tests in fastdeploy/golang_router/pkg/logger/logger_test.go to exercise StartLogCleanup with a controlled nowFunc, temporary log directory, and context cancellation.
  • Added an integration-style test for rotatingWriter that simulates a cross-day transition and verifies that late previous-day lines are written to the previous-day file and that router.log symlink points to the new day file.
  • Introduced a waitForCondition helper and adjusted imports to support time control and temporary directories used by the tests.

Testing

  • Ran cd fastdeploy/golang_router && go test ./pkg/logger and the package tests passed (ok).
  • The new tests exercised TestStartLogCleanup and TestRotatingWriterCrossDayGracePeriodIntegration as part of the package test run and succeeded.

Codex Task

@mouxinqq mouxinqq merged commit f5d325b into develop Apr 14, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant