ZanderXu commented on PR #5098:
URL: https://github.com/apache/hadoop/pull/5098#issuecomment-1362283212
\
> To test the shuffling, one approach would be to call
namenodeResolver.getNamenodesForNameserviceId() 100 times in a loop and check
if ever the two observers swap positions in the list. If there is never a swap
we fail the test.
>
> The test will be probabilistic but the chance of it flaking will be
extremely low 0.5^100.
>
> ```
> List<? extends FederationNamenodeContext> observerList3 ;
> for(int i = 0; i < 100; i++) {
> observerList3 =
namenodeResolver.getNamenodesForNameserviceId(NAMESERVICES[0], true);
> assertEquals(FederationNamenodeServiceState.OBSERVER,
observerList3.get(0).getState());
> assertEquals(FederationNamenodeServiceState.OBSERVER,
observerList3.get(1).getState());
> if
(observerList3.get(0).getNamenodeId().equals(observerList2.get(1).getNamenodeId())
&&
>
observerList3.get(1).getNamenodeId().equals(observerList2.get(0).getNamenodeId()))
{
> return;
> }
> }
> Assert.fail("Observer order never changed.");
> ```
@simbadzina Thanks for your nice suggestion, I will do it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]