import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import org.mockito.Mockito;
import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
+import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
+import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener;
import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
// by setting the election timeout, which is based on the heartbeat interval, really high.
datastoreContextBuilder.shardHeartbeatIntervalInMillis(30000);
- datastoreContextBuilder.shardInitializationTimeout(300, TimeUnit.MILLISECONDS);
- // Set the leader election timeout low for the test.
+ DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName);
+
+ Object result = dataStore.getActorContext().executeOperation(dataStore.getActorContext().getShardManager(),
+ new FindLocalShard(shardName, true));
+ assertTrue("Expected LocalShardFound. Actual: " + result, result instanceof LocalShardFound);
- datastoreContextBuilder.shardLeaderElectionTimeout(1, TimeUnit.MILLISECONDS);
+ // The ShardManager uses the election timeout for FindPrimary so reset it low so it will timeout quickly.
- DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName);
+ datastoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(1);
+ dataStore.onDatastoreContextUpdated(datastoreContextBuilder.build());
// Create the write Tx.