X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDistributedDataStoreIntegrationTest.java;h=fa066ee32e5973347c6ff1fc9d22b31add12bd44;hb=e970feb618c5e3793454f7f1a3974797a61c7c17;hp=9dd882f2de29d16e76d18ce6889f49e6fadc9902;hpb=5c5c980e564d2b5f6cd26821ffd26997f59af260;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java index 9dd882f2de..fa066ee32e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertEquals; @@ -608,15 +616,17 @@ public class DistributedDataStoreIntegrationTest { }}; } - private void testTransactionCommitFailureWithNoShardLeader(final boolean writeOnly) throws Throwable { + private void testTransactionCommitFailureWithNoShardLeader(final boolean writeOnly, final String testName) throws Throwable { new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{ - String testName = "testTransactionCommitFailureWithNoShardLeader"; String shardName = "default"; - // We don't want the shard to become the leader so prevent shard election from completing - // by setting the election timeout, which is based on the heartbeat interval, really high. + // We don't want the shard to become the leader so prevent shard elections. + datastoreContextBuilder.customRaftPolicyImplementation( + "org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy"); - datastoreContextBuilder.shardHeartbeatIntervalInMillis(30000); + // The ShardManager uses the election timeout for FindPrimary so reset it low so it will timeout quickly. + datastoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(1). + shardInitializationTimeout(200, TimeUnit.MILLISECONDS); DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName); @@ -624,11 +634,6 @@ public class DistributedDataStoreIntegrationTest { new FindLocalShard(shardName, true)); assertTrue("Expected LocalShardFound. Actual: " + result, result instanceof LocalShardFound); - // The ShardManager uses the election timeout for FindPrimary so reset it low so it will timeout quickly. - - datastoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(1); - dataStore.onDatastoreContextUpdated(datastoreContextBuilder.build()); - // Create the write Tx. final DOMStoreWriteTransaction writeTx = writeOnly ? dataStore.newWriteOnlyTransaction() : @@ -684,12 +689,12 @@ public class DistributedDataStoreIntegrationTest { @Test(expected=NoShardLeaderException.class) public void testWriteOnlyTransactionCommitFailureWithNoShardLeader() throws Throwable { datastoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true); - testTransactionCommitFailureWithNoShardLeader(true); + testTransactionCommitFailureWithNoShardLeader(true, "testWriteOnlyTransactionCommitFailureWithNoShardLeader"); } @Test(expected=NoShardLeaderException.class) public void testReadWriteTransactionCommitFailureWithNoShardLeader() throws Throwable { - testTransactionCommitFailureWithNoShardLeader(false); + testTransactionCommitFailureWithNoShardLeader(false, "testReadWriteTransactionCommitFailureWithNoShardLeader"); } @Test