Repository navigation
test(spanner): unflake EndpointLifecycleManagerTest - #15055
Conversation
Wait for the initial zero-delay background probe to read CONNECTING state before mutating channel health and driving manual probe calls in EndpointLifecycleManagerTest.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a helper method registerAndAwaitInitialConnectingProbe in EndpointLifecycleManagerTest.java to register an address and wait for the background prober's initial run to read its state. It also updates KeyRangeCacheTest.java to track the number of times getState is called on FakeManagedChannel using an AtomicInteger. These changes help avoid race conditions in tests by ensuring the background prober has completed its initial check before proceeding. I have no feedback to provide as there are no review comments.
There was a problem hiding this comment.
Code Review
This pull request introduces test synchronization improvements in EndpointLifecycleManagerTest and KeyRangeCacheTest. Specifically, it adds a helper method registerAndAwaitInitialConnectingProbe to register an endpoint and wait until the background prober's initial run has read its state. To support this, FakeManagedChannel now tracks the number of times its getState method is called using an AtomicInteger. There are no review comments, and I have no feedback to provide.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration option, enableBackgroundProbing, to the EndpointLifecycleManager class, allowing background probing to be disabled during testing. A new package-private constructor annotated with @VisibleForTesting has been added to support this flag, and existing tests have been updated to disable background probing. There are no review comments, and the changes look clean and well-structured.
Problem
EndpointLifecycleManager.updateActiveAddressesschedules background endpoint creation (createAndStartProbing), which populatesendpointCachebefore callingstartProbingto schedule periodicprobeexecution withinitialDelay = 0.EndpointLifecycleManagerTest#transientFailureOscillationWithConnectingStillEvictsEndpointandEndpointLifecycleManagerTest#readyResetsTransientFailureCounterAfterRecoveryonly waited forcache.getIfPresent("server1") != nullbefore mutating the fake channel state toTRANSIENT_FAILUREand callingmanager.probe("server1")directly on the test thread.cache.getIfPresent("server1") != nullbecomes true before the zero-delay initial backgroundprobe("server1")runs, the scheduled probe can observeTRANSIENT_FAILUREconcurrently with the manualprobecall and incrementconsecutiveTransientFailurestwice (AssertionError: expected:<1> but was:<2>).Solution
@VisibleForTestingenableBackgroundProbingflag onEndpointLifecycleManager(defaulting totruein existing constructors) that skips scheduling periodicprobetasks instartProbingwhenfalse.EndpointLifecycleManagerwithenableBackgroundProbing = falseintransientFailureOscillationWithConnectingStillEvictsEndpointandreadyResetsTransientFailureCounterAfterRecoveryso background endpoint creation still runs viaregisterAddresseswhile allprobe("server1")state transitions are driven deterministically on the test thread.