Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-4085

Random failures in StateProviderTest due to race condition

XMLWordPrintable

    • Hide

      I can reproduced the issue 100% of the time by running the test a 1000 times:

      @Test(groups = "functional", testName = "statetransfer.StateProviderTest", invocationCount = 1000)
      public class StateProviderTest 
      
      Show
      I can reproduced the issue 100% of the time by running the test a 1000 times: @Test(groups = "functional" , testName = "statetransfer.StateProviderTest" , invocationCount = 1000) public class StateProviderTest

      In my environment the StateProviderTest .test2() fails sometimes (about 10% of the time) with the following error(s):

      Tests run: 4233, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 428.06 sec <<< FAILURE!
      test2(org.infinispan.statetransfer.StateProviderTest)  Time elapsed: 0.042 sec  <<< FAILURE!
      java.lang.AssertionError
      	at org.junit.Assert.fail(Assert.java:92)
      	at org.junit.Assert.assertTrue(Assert.java:43)
      	at org.junit.Assert.assertTrue(Assert.java:54)
      	at org.infinispan.statetransfer.StateProviderTest.test2(StateProviderTest.java:316)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      

      The reason why is that test2() feeds the StateProvider a ThreadPoolExecutorService to execute a OutboundTransfer task asynchronously and right after forcing a state transfer
      asserts that there is a StateTransfer in progress. Sometimes the executor service manages to execute the task and as a result it clear the ‘transfersByDestination’ map, and thus the test cannot assert that the state transfer is happening

      OTOH, the method test1() never fails because it users a mock executor service which never executes the task, so the state transfer map will always contain the outbound task after initiating the state transfer and thus always visible from outside

      The quick fix is to also use a mock executor test for the test2()

              anistor Adrian Nistor (Inactive)
              gfernand@redhat.com Gustavo Fernandes (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: