Skip to content

chore: tests for race condition on rules.Evaluate - #5

Closed
gtkatakura wants to merge 1 commit into
mainfrom
fix/race-condition-on-rules-evaluate
Closed

gtkatakura wants to merge 1 commit into
mainfrom
fix/race-condition-on-rules-evaluate

Conversation

@gtkatakura

Copy link
Copy Markdown

Title: Add concurrent/race-condition tests and benchmarks for rule engine

📝 Summary

Adds race-condition focused tests and benchmarks for the rule evaluation engine. Introduces comprehensive concurrent test scenarios to validate thread-safety of Evaluate and adds benchmarks to measure performance under concurrent load.

  • New files:
    • race_condition_benchmark_test.go
    • race_condition_test.go

These tests/benchmarks exercise multiple concurrent evaluation patterns (same query with different contexts, different queries, mixed operations, and wait-group style concurrency) to surface potential data races and ensure correctness under high contention.

⚡ Performance Impact

  • Benchmarks included for performance changes

Note: No functional changes to the engine; benchmarks are added to measure and validate performance characteristics under concurrent usage.

✅ Checklist

  • Code follows project style
  • Self-reviewed the code
  • Tests added for new functionality
  • README updated (if required)

Important: The existing Checklist section remains unchanged per contribution guidelines.

Testing Instructions

To validate and exercise the new tests and benchmarks:

  • Run unit tests (including the race-condition tests)

    • make test
    • or go test ./... (with module-aware mode)
  • Run with race detector to explicitly surface data races

    • go test -race ./...
  • Run benchmarks (includes the new race-condition benchmarks)

    • make bench
    • or go test -bench=. -benchmem ./...
  • If you want to run specific tests/benchmarks for the rule package

    • go test -race ./rule -run TestEngine_RaceCondition_BasicQuery
    • go test -race ./rule -bench .

Notes:

  • The race-detection mode (-race) is recommended to surface concurrency issues exposed by these tests.
  • The benchmarks are designed to run quickly under typical CI environments; you can adjust the test invocation to target specific benchmarks if desired.

If you want any adjustments, such as additional test scenarios or targeted benchmark configurations, I can add them quickly.

@coderabbitai

coderabbitai Bot commented Nov 21, 2025

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/race-condition-on-rules-evaluate

Comment @coderabbitai help to get the list of available commands and usage tips.

@gtkatakura gtkatakura closed this Nov 21, 2025
@gtkatakura
gtkatakura deleted the fix/race-condition-on-rules-evaluate branch November 21, 2025 22:28
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.

1 participant