Search in sources :

Example 6 with EmptyModuleShardConfigProvider

use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.

the class ShardManagerTest method testAddShardReplicaForNonExistentShardConfig.

@Test
public void testAddShardReplicaForNonExistentShardConfig() throws Exception {
    new TestKit(getSystem()) {

        {
            ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
            shardManager.tell(new AddShardReplica("model-inventory"), getRef());
            Status.Failure resp = expectMsgClass(duration("2 seconds"), Status.Failure.class);
            assertEquals("Failure obtained", true, resp.cause() instanceof IllegalArgumentException);
        }
    };
}
Also used : EmptyModuleShardConfigProvider(org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider) FollowerInitialSyncUpStatus(org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus) ChangeShardMembersVotingStatus(org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus) Status(akka.actor.Status) ServerChangeStatus(org.opendaylight.controller.cluster.raft.messages.ServerChangeStatus) ChangeServersVotingStatus(org.opendaylight.controller.cluster.raft.messages.ChangeServersVotingStatus) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) TestKit(akka.testkit.javadsl.TestKit) AddShardReplica(org.opendaylight.controller.cluster.datastore.messages.AddShardReplica) ConfigurationImpl(org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl) Failure(akka.actor.Status.Failure) Test(org.junit.Test) AbstractShardManagerTest(org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)

Example 7 with EmptyModuleShardConfigProvider

use of org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider in project controller by opendaylight.

the class ShardManagerTest method testOnCreateShard.

@Test
public void testOnCreateShard() {
    LOG.info("testOnCreateShard starting");
    new TestKit(getSystem()) {

        {
            datastoreContextBuilder.shardInitializationTimeout(1, TimeUnit.MINUTES).persistent(true);
            ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
            SchemaContext schemaContext = TestModel.createTestContext();
            shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());
            DatastoreContext datastoreContext = DatastoreContext.newBuilder().shardElectionTimeoutFactor(100).persistent(false).build();
            Shard.Builder shardBuilder = Shard.builder();
            ModuleShardConfiguration config = new ModuleShardConfiguration(URI.create("foo-ns"), "foo-module", "foo", null, members("member-1", "member-5", "member-6"));
            shardManager.tell(new CreateShard(config, shardBuilder, datastoreContext), getRef());
            expectMsgClass(duration("5 seconds"), Success.class);
            shardManager.tell(new FindLocalShard("foo", true), getRef());
            expectMsgClass(duration("5 seconds"), LocalShardFound.class);
            assertEquals("isRecoveryApplicable", false, shardBuilder.getDatastoreContext().isPersistent());
            assertTrue("Epxected ShardPeerAddressResolver", shardBuilder.getDatastoreContext().getShardRaftConfig().getPeerAddressResolver() instanceof ShardPeerAddressResolver);
            assertEquals("peerMembers", Sets.newHashSet(ShardIdentifier.create("foo", MemberName.forName("member-5"), shardMrgIDSuffix).toString(), ShardIdentifier.create("foo", MemberName.forName("member-6"), shardMrgIDSuffix).toString()), shardBuilder.getPeerAddresses().keySet());
            assertEquals("ShardIdentifier", ShardIdentifier.create("foo", MEMBER_1, shardMrgIDSuffix), shardBuilder.getId());
            assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());
            // Send CreateShard with same name - should return Success with
            // a message.
            shardManager.tell(new CreateShard(config, shardBuilder, null), getRef());
            Success success = expectMsgClass(duration("5 seconds"), Success.class);
            assertNotNull("Success status is null", success.status());
        }
    };
    LOG.info("testOnCreateShard ending");
}
Also used : UpdateSchemaContext(org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) FindLocalShard(org.opendaylight.controller.cluster.datastore.messages.FindLocalShard) TestKit(akka.testkit.javadsl.TestKit) CreateShard(org.opendaylight.controller.cluster.datastore.messages.CreateShard) Success(akka.actor.Status.Success) EmptyModuleShardConfigProvider(org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider) DatastoreContext(org.opendaylight.controller.cluster.datastore.DatastoreContext) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) UpdateSchemaContext(org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext) CreateShard(org.opendaylight.controller.cluster.datastore.messages.CreateShard) FindLocalShard(org.opendaylight.controller.cluster.datastore.messages.FindLocalShard) Shard(org.opendaylight.controller.cluster.datastore.Shard) ConfigurationImpl(org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl) ModuleShardConfiguration(org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration) Test(org.junit.Test) AbstractShardManagerTest(org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)

Example 8 with EmptyModuleShardConfigProvider

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 ClusterWrapper cluster = new ClusterWrapperImpl(getSystem());
    final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider());
    setDataStoreName(typeName);
    final DatastoreContext datastoreContext = getDatastoreContextBuilder().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;
}
Also used : EmptyModuleShardConfigProvider(org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider) ConfigurationImpl(org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl)

Aggregations

ConfigurationImpl (org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl)8 EmptyModuleShardConfigProvider (org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider)8 ActorRef (akka.actor.ActorRef)5 TestActorRef (akka.testkit.TestActorRef)5 TestKit (akka.testkit.javadsl.TestKit)5 Test (org.junit.Test)5 AbstractShardManagerTest (org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)5 Shard (org.opendaylight.controller.cluster.datastore.Shard)3 ModuleShardConfiguration (org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration)3 CreateShard (org.opendaylight.controller.cluster.datastore.messages.CreateShard)3 FindLocalShard (org.opendaylight.controller.cluster.datastore.messages.FindLocalShard)3 UpdateSchemaContext (org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext)3 Status (akka.actor.Status)2 Failure (akka.actor.Status.Failure)2 DatastoreContext (org.opendaylight.controller.cluster.datastore.DatastoreContext)2 ChangeShardMembersVotingStatus (org.opendaylight.controller.cluster.datastore.messages.ChangeShardMembersVotingStatus)2 FollowerInitialSyncUpStatus (org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus)2 ChangeServersVotingStatus (org.opendaylight.controller.cluster.raft.messages.ChangeServersVotingStatus)2 ServerChangeStatus (org.opendaylight.controller.cluster.raft.messages.ServerChangeStatus)2 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)2