From: Tom Pantelis Date: Thu, 10 Sep 2015 17:24:01 +0000 (-0400) Subject: CDS: Fix intermittent DistributedDataStoreRemotingIntegrationTest failure X-Git-Tag: release/beryllium~318 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=7fd01f9dc19ef8f02c1b70973fcb091dc0ad8b1e CDS: Fix intermittent DistributedDataStoreRemotingIntegrationTest failure I've seen the testReadyLocalTransactionForwardedToLeader test fail several times both locally and in jenkins: DistributedDataStoreRemotingIntegrationTest.testReadyLocalTransactionForwardedToLeader:535 assertion failed: expected class org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages$CommitTransactionReply, found class akka.actor.Status$Failure It's a timing issue where the follower may not yet have the leader. After this patch the test ran 100 times w/o failure. Change-Id: I542a7e87516e8d1f846cda6e2abc4d473e3de961 Signed-off-by: Tom Pantelis --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java index 90600f9529..c29cc4eea1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java @@ -514,6 +514,7 @@ public class DistributedDataStoreRemotingIntegrationTest { @Test public void testReadyLocalTransactionForwardedToLeader() throws Exception { initDatastores("testReadyLocalTransactionForwardedToLeader"); + followerTestKit.waitUntilLeader(followerDistributedDataStore.getActorContext(), "cars"); Optional carsFollowerShard = followerDistributedDataStore.getActorContext().findLocalShard("cars"); assertEquals("Cars follower shard found", true, carsFollowerShard.isPresent()); @@ -532,7 +533,13 @@ public class DistributedDataStoreRemotingIntegrationTest { ReadyLocalTransaction readyLocal = new ReadyLocalTransaction(transactionID , modification, true); carsFollowerShard.get().tell(readyLocal, followerTestKit.getRef()); - followerTestKit.expectMsgClass(CommitTransactionReply.SERIALIZABLE_CLASS); + Object resp = followerTestKit.expectMsgClass(Object.class); + if(resp instanceof akka.actor.Status.Failure) { + throw new AssertionError("Unexpected failure response", ((akka.actor.Status.Failure)resp).cause()); + } + + assertTrue("Expected response of type " + CommitTransactionReply.SERIALIZABLE_CLASS, + CommitTransactionReply.SERIALIZABLE_CLASS.equals(resp.getClass())); verifyCars(leaderDistributedDataStore.newReadOnlyTransaction(), car); }