use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.
the class DistributedEntityOwnershipServiceTest method setUp.
@Before
public void setUp() {
DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreName(dataStoreName).shardInitializationTimeout(10, TimeUnit.SECONDS).build();
Configuration configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider()) {
@Override
public Collection<MemberName> getUniqueMemberNamesForAllShards() {
return Sets.newHashSet(MemberName.forName("member-1"));
}
};
DatastoreContextFactory mockContextFactory = mock(DatastoreContextFactory.class);
Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(), configuration, mockContextFactory, null);
dataStore.onGlobalContextUpdated(SchemaContextHelper.entityOwners());
}
use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.
the class IntegrationTestKit method setupDistributedDataStoreWithoutConfig.
public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName, final SchemaContext schemaContext, final LogicalDatastoreType storeType) {
final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());
setDataStoreName(typeName);
final DatastoreContext datastoreContext = getDatastoreContextBuilder().logicalStoreType(storeType).build();
final DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
final DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster, configuration, mockContextFactory, restoreFromSnapshot);
dataStore.onGlobalContextUpdated(schemaContext);
datastoreContextBuilder = DatastoreContext.newBuilderFrom(datastoreContext);
return dataStore;
}
use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.
the class ShardManagerTest method testOnCreateShardWithLocalMemberNotInShardConfig.
@Test
public void testOnCreateShardWithLocalMemberNotInShardConfig() {
LOG.info("testOnCreateShardWithLocalMemberNotInShardConfig starting");
new TestKit(getSystem()) {
{
datastoreContextBuilder.shardInitializationTimeout(1, TimeUnit.MINUTES).persistent(true);
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), ActorRef.noSender());
Shard.Builder shardBuilder = Shard.builder();
ModuleShardConfiguration config = new ModuleShardConfiguration(URI.create("foo-ns"), "foo-module", "foo", null, members("member-5", "member-6"));
shardManager.tell(new CreateShard(config, shardBuilder, null), getRef());
expectMsgClass(duration("5 seconds"), Success.class);
shardManager.tell(new FindLocalShard("foo", true), getRef());
expectMsgClass(duration("5 seconds"), LocalShardFound.class);
assertEquals("peerMembers size", 0, shardBuilder.getPeerAddresses().size());
assertEquals("schemaContext", DisableElectionsRaftPolicy.class.getName(), shardBuilder.getDatastoreContext().getShardRaftConfig().getCustomRaftPolicyImplementationClass());
}
};
LOG.info("testOnCreateShardWithLocalMemberNotInShardConfig ending");
}
use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.
the class ShardManagerTest method testOnCreateShardWithNoInitialSchemaContext.
@Test
public void testOnCreateShardWithNoInitialSchemaContext() {
LOG.info("testOnCreateShardWithNoInitialSchemaContext starting");
new TestKit(getSystem()) {
{
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
Shard.Builder shardBuilder = Shard.builder();
ModuleShardConfiguration config = new ModuleShardConfiguration(URI.create("foo-ns"), "foo-module", "foo", null, members("member-1"));
shardManager.tell(new CreateShard(config, shardBuilder, null), getRef());
expectMsgClass(duration("5 seconds"), Success.class);
SchemaContext schemaContext = TestModel.createTestContext();
shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());
shardManager.tell(new FindLocalShard("foo", true), getRef());
expectMsgClass(duration("5 seconds"), LocalShardFound.class);
assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());
assertNotNull("schemaContext is null", shardBuilder.getDatastoreContext());
}
};
LOG.info("testOnCreateShardWithNoInitialSchemaContext ending");
}
use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.
the class ShardManagerTest method testRemoveShardReplicaForNonExistentShard.
@Test
public void testRemoveShardReplicaForNonExistentShard() throws Exception {
new TestKit(getSystem()) {
{
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
shardManager.tell(new RemoveShardReplica("model-inventory", MEMBER_1), getRef());
Status.Failure resp = expectMsgClass(duration("10 seconds"), Status.Failure.class);
assertEquals("Failure obtained", true, resp.cause() instanceof PrimaryNotFoundException);
}
};
}
Aggregations