Search in sources :

Example 16 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class ModuleShardBackendResolverTest method testRefreshBackendInfo.

@Test
public void testRefreshBackendInfo() throws Exception {
    final CompletionStage<ShardBackendInfo> backendInfo = moduleShardBackendResolver.getBackendInfo(0L);
    // handle first connect
    contextProbe.expectMsgClass(ConnectClientRequest.class);
    final TestProbe staleBackendProbe = new TestProbe(system, "staleBackend");
    final ConnectClientSuccess msg = new ConnectClientSuccess(CLIENT_ID, 0L, staleBackendProbe.ref(), Collections.emptyList(), dataTree, 3);
    contextProbe.reply(msg);
    // get backend info
    final ShardBackendInfo staleBackendInfo = TestUtils.getWithTimeout(backendInfo.toCompletableFuture());
    // refresh
    final CompletionStage<ShardBackendInfo> refreshed = moduleShardBackendResolver.refreshBackendInfo(0L, staleBackendInfo);
    // stale backend info should be removed and new connect request issued to the context
    contextProbe.expectMsgClass(ConnectClientRequest.class);
    final TestProbe refreshedBackendProbe = new TestProbe(system, "refreshedBackend");
    final ConnectClientSuccess msg2 = new ConnectClientSuccess(CLIENT_ID, 1L, refreshedBackendProbe.ref(), Collections.emptyList(), dataTree, 3);
    contextProbe.reply(msg2);
    final ShardBackendInfo refreshedBackendInfo = TestUtils.getWithTimeout(refreshed.toCompletableFuture());
    Assert.assertEquals(staleBackendInfo.getCookie(), refreshedBackendInfo.getCookie());
    Assert.assertEquals(refreshedBackendProbe.ref(), refreshedBackendInfo.getActor());
}
Also used : ConnectClientSuccess(org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Example 17 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class RemoteProxyTransactionTest method testForwardToRemoteModifyRead.

@Test
public void testForwardToRemoteModifyRead() throws Exception {
    final TestProbe probe = createProbe();
    final ReadTransactionRequest request = new ReadTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, false);
    final ReadTransactionRequest received = testForwardToRemote(request, ReadTransactionRequest.class);
    Assert.assertEquals(request.getTarget(), received.getTarget());
    Assert.assertEquals(request.getPath(), received.getPath());
}
Also used : TestProbe(akka.testkit.TestProbe) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) Test(org.junit.Test)

Example 18 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class RemoteProxyTransactionTest method testForwardToRemoteModifyAbort.

@Test
public void testForwardToRemoteModifyAbort() throws Exception {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    builder.setSequence(0L);
    builder.setAbort();
    final ModifyTransactionRequest request = builder.build();
    final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
    Assert.assertEquals(request.getTarget(), received.getTarget());
    Assert.assertTrue(received.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
}
Also used : ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 19 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class RemoteProxyTransactionTest method testForwardToRemoteModifyPreCommit.

@Test
public void testForwardToRemoteModifyPreCommit() throws Exception {
    final TestProbe probe = createProbe();
    final TransactionPreCommitRequest request = new TransactionPreCommitRequest(TRANSACTION_ID, 0L, probe.ref());
    final TransactionPreCommitRequest received = testForwardToRemote(request, TransactionPreCommitRequest.class);
    Assert.assertEquals(request.getTarget(), received.getTarget());
}
Also used : TestProbe(akka.testkit.TestProbe) TransactionPreCommitRequest(org.opendaylight.controller.cluster.access.commands.TransactionPreCommitRequest) Test(org.junit.Test)

Example 20 with TestProbe

use of akka.testkit.TestProbe in project controller by opendaylight.

the class RemoteProxyTransactionTest method testForwardToRemoteModifyDoCommit.

@Test
public void testForwardToRemoteModifyDoCommit() throws Exception {
    final TestProbe probe = createProbe();
    final TransactionDoCommitRequest request = new TransactionDoCommitRequest(TRANSACTION_ID, 0L, probe.ref());
    final TransactionDoCommitRequest received = testForwardToRemote(request, TransactionDoCommitRequest.class);
    Assert.assertEquals(request.getTarget(), received.getTarget());
}
Also used : TransactionDoCommitRequest(org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Aggregations

TestProbe (akka.testkit.TestProbe)51 Test (org.junit.Test)30 Before (org.junit.Before)13 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)10 ClientActorContext (org.opendaylight.controller.cluster.access.client.ClientActorContext)8 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)7 Response (org.opendaylight.controller.cluster.access.concepts.Response)5 ActorContext (org.opendaylight.controller.cluster.datastore.utils.ActorContext)5 AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)4 ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)4 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)4 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)4 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)3 ExistsTransactionRequest (org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest)3 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)3 TransactionAbortRequest (org.opendaylight.controller.cluster.access.commands.TransactionAbortRequest)3 ActorRef (akka.actor.ActorRef)2 ArrayList (java.util.ArrayList)2 TransactionDoCommitRequest (org.opendaylight.controller.cluster.access.commands.TransactionDoCommitRequest)2 TransactionPreCommitRequest (org.opendaylight.controller.cluster.access.commands.TransactionPreCommitRequest)2