[NA] [BE] Make TemplateUtilsTest more resilient with Awaitility
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.
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.
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