Search in sources :

Example 1 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class AbstractClientHandleTest method testAbort.

@Test
public void testAbort() throws Exception {
    doHandleOperation(handle);
    handle.abort();
    final Envelope<?> envelope = backendProbe.expectMsgClass(Envelope.class);
    final AbortLocalTransactionRequest request = (AbortLocalTransactionRequest) envelope.getMessage();
    Assert.assertEquals(TRANSACTION_ID, request.getTarget());
    checkClosed();
}
Also used : AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) Test(org.junit.Test)

Example 2 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class AbstractClientHandleTest method testLocalAbort.

@Test
public void testLocalAbort() throws Exception {
    doHandleOperation(handle);
    handle.localAbort(new RuntimeException("fail"));
    final Envelope<?> envelope = backendProbe.expectMsgClass(Envelope.class);
    final AbortLocalTransactionRequest request = (AbortLocalTransactionRequest) envelope.getMessage();
    Assert.assertEquals(TRANSACTION_ID, request.getTarget());
    checkClosed();
}
Also used : AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) Test(org.junit.Test)

Example 3 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class AbstractProxyTransactionTest method testReplayMessages.

@Test
public void testReplayMessages() throws Exception {
    final TestProbe probe = new TestProbe(system);
    final List<ConnectionEntry> entries = new ArrayList<>();
    final Consumer<Response<?, ?>> callback = createCallbackMock();
    final ReadTransactionRequest request1 = new ReadTransactionRequest(TRANSACTION_ID, 2L, probe.ref(), PATH_2, true);
    final ExistsTransactionRequest request2 = new ExistsTransactionRequest(TRANSACTION_ID, 3L, probe.ref(), PATH_3, true);
    entries.add(AccessClientUtil.createConnectionEntry(request1, callback, 0L));
    entries.add(AccessClientUtil.createConnectionEntry(request2, callback, 0L));
    final TransactionTester<RemoteProxyTransaction> successor = createRemoteProxyTransactionTester();
    final AbortLocalTransactionRequest successful1 = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
    transaction.recordSuccessfulRequest(successful1);
    final ReadTransactionRequest successful2 = new ReadTransactionRequest(TRANSACTION_ID, 1L, probe.ref(), PATH_1, true);
    transaction.recordSuccessfulRequest(successful2);
    transaction.startReconnect();
    final ProxyHistory mockSuccessor = mock(ProxyHistory.class);
    when(mockSuccessor.createTransactionProxy(TRANSACTION_ID, transaction.isSnapshotOnly(), false)).thenReturn(successor.getTransaction());
    transaction.replayMessages(mockSuccessor, entries);
    final ModifyTransactionRequest transformed = successor.expectTransactionRequest(ModifyTransactionRequest.class);
    Assert.assertNotNull(transformed);
    Assert.assertEquals(successful1.getSequence(), transformed.getSequence());
    Assert.assertTrue(transformed.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
    ReadTransactionRequest tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
    Assert.assertNotNull(tmpRead);
    Assert.assertEquals(successful2.getTarget(), tmpRead.getTarget());
    Assert.assertEquals(successful2.getSequence(), tmpRead.getSequence());
    Assert.assertEquals(successful2.getPath(), tmpRead.getPath());
    Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
    tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
    Assert.assertNotNull(tmpRead);
    Assert.assertEquals(request1.getTarget(), tmpRead.getTarget());
    Assert.assertEquals(request1.getSequence(), tmpRead.getSequence());
    Assert.assertEquals(request1.getPath(), tmpRead.getPath());
    Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
    final ExistsTransactionRequest tmpExist = successor.expectTransactionRequest(ExistsTransactionRequest.class);
    Assert.assertNotNull(tmpExist);
    Assert.assertEquals(request2.getTarget(), tmpExist.getTarget());
    Assert.assertEquals(request2.getSequence(), tmpExist.getSequence());
    Assert.assertEquals(request2.getPath(), tmpExist.getPath());
    Assert.assertEquals(successor.localActor(), tmpExist.getReplyTo());
}
Also used : ArrayList(java.util.ArrayList) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) Response(org.opendaylight.controller.cluster.access.concepts.Response) AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) ConnectionEntry(org.opendaylight.controller.cluster.access.client.ConnectionEntry) ExistsTransactionRequest(org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 4 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class LocalProxyTransactionTest method testForwardToRemoteAbort.

@Override
@Test
public void testForwardToRemoteAbort() throws Exception {
    final TestProbe probe = createProbe();
    final AbortLocalTransactionRequest request = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
    final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
    Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.ABORT, modifyRequest.getPersistenceProtocol().get());
}
Also used : AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 5 with AbortLocalTransactionRequest

use of org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest in project controller by opendaylight.

the class LocalProxyTransactionTest method testForwardToLocalAbort.

@Test
public void testForwardToLocalAbort() throws Exception {
    final TestProbe probe = createProbe();
    final AbortLocalTransactionRequest request = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
    testForwardToLocal(request, AbortLocalTransactionRequest.class);
}
Also used : AbortLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Aggregations

AbortLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest)7 Test (org.junit.Test)6 TestProbe (akka.testkit.TestProbe)4 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)3 ArrayList (java.util.ArrayList)1 ConnectionEntry (org.opendaylight.controller.cluster.access.client.ConnectionEntry)1 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)1 ExistsTransactionRequest (org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest)1 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)1 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)1 Response (org.opendaylight.controller.cluster.access.concepts.Response)1 AbstractDataTreeModificationCursor (org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)1