发布

  • [NA] [BE] Make TemplateUtilsTest more resilient with Awaitility (#4272)

    frostbyte_neo 发布于 2025-12-01 10:21:32 +00:00

    • [NA] test: Make TemplateUtilsTest more resilient with Awaitility
    • 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() to just trigger GC 5 times with delays
    • 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.

    • Revision 2: Update JavaDoc to accurately reflect implementation

    Fix performGCAndWaitForStability() documentation to match the actual
    implementation which triggers GC 5 times with delays, rather than
    using Awaitility for memory stabilization.

    • Revision 3: Simplify implementation by removing performGCAndWaitForStability
    • Remove performGCAndWaitForStability() helper method entirely
    • Just call System.gc() directly before and after template creation
    • Let Awaitility handle the waiting for GC to complete in assertions
    • Revert test description comments to original wording
    • Revert memory tolerance ranges to original values (1-100 MB, 2-3 GB)

    This is much simpler and clearer - Awaitility does all the work.

    下载附件