opik icon indicating copy to clipboard operation
opik copied to clipboard

[NA] [BE] Make TemplateUtilsTest more resilient with Awaitility

Open thiagohora opened this issue 1 month ago • 1 comments

Details

This PR improves the TemplateUtilsTest memory leak tests to be more resilient in resource-constrained environments (e.g., Docker-in-Docker, CI/CD pipelines).

Key Changes:

  • Wrap main test assertions (lines 203-221) in Awaitility.await().untilAsserted() to ensure GC has completed before verifying collection counts and memory growth
  • Simplify performGCAndWaitForStability() helper method to just trigger GC 5 times with 100ms delays (removed complex stabilization logic)
  • Increase memory tolerance ranges for better stability across environments:
    • allowGCAndNotCauseMemoryLeak: 1-150 MB (was 1-100 MB)
    • preventGCAndCauseMemoryLeak: 2-4 GB (was 2-3 GB)

The critical improvement is using Awaitility around the actual assertions to wait for GC to complete, rather than complex pre-GC stabilization logic.

Change checklist

  • [ ] User facing
  • [ ] Documentation update

Issues

  • Resolves #
  • OPIK-
  • NA (no ticket - test improvement)

Testing

All 7 tests in TemplateUtilsTest pass consistently:

Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
Total time: 41.136 s
BUILD SUCCESS

Documentation

No documentation changes required - internal test improvements only.

thiagohora avatar Nov 29 '25 13:11 thiagohora

Backend Tests Results

  322 files    322 suites   49m 13s ⏱️ 5 651 tests 5 644 ✅ 7 💤 0 ❌ 5 604 runs  5 597 ✅ 7 💤 0 ❌

Results for commit bdc8a4da.

github-actions[bot] avatar Nov 29 '25 14:11 github-actions[bot]

LGTM. In addition, we could simply disable these tests.

They were very useful to reproduce the issue and demonstrate the fix.

But they aren't functional tests, no need to run on every change.

Sure @andrescrz, if it persists I will disable it

thiagohora avatar Dec 01 '25 10:12 thiagohora