ApfTest: fix flaky testApfFilterRa.
testApfFilterRa is failing with probabiliy 1/10 ~ 1/15 on the following assert: assertDrop(program, packet, lifetime/6), for lifetime values that are multiple of 6, where 6 is the hardcoded fraction of RA lifetime to filter in ApfFilter.java. When the lifetime is not a multiple of 6, the remainder of 1 to 5 seconds gives enough margin so that when the APF program is simulated the faked lifetime of the program is less than lifetime/6 away and the packet is dropped. However for lifetimes which are exact multiples of 6, this margin is always 0s and that result in nondeterminism in the result. This is consistent with the obervation that the only failed assert was for a lifetime of 300s, the only multiple of 6. This can be observed by detecting the age limit at which the filter stops dropping packet oscillating between lifetime/6 and lifetime/6 + 1 for lifetimes which are multiple of 6. This patch fixes the flakyness by freezing the flow of time in tests so that the expected filter age threshold is consistent and stable. Test: no failure observed in 1000 runs. Bug: 32561414 Change-Id: I5251d047039f34b82ce8a5d20ae46563e1e0cce8
Loading
Please register or sign in to comment