You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by se...@apache.org on 2018/01/11 07:58:27 UTC

[incubator-servicecomb-saga] branch SCB-212_tx_timeout updated: SCB-212 attempted to fix test failure

This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch SCB-212_tx_timeout
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git


The following commit(s) were added to refs/heads/SCB-212_tx_timeout by this push:
     new a49b411  SCB-212 attempted to fix test failure
a49b411 is described below

commit a49b411932bda44256e0a3784bb04d04d6ab430d
Author: seanyinx <se...@huawei.com>
AuthorDate: Thu Jan 11 15:58:16 2018 +0800

    SCB-212 attempted to fix test failure
    
    Signed-off-by: seanyinx <se...@huawei.com>
---
 .../saga/alpha/server/AlphaIntegrationTest.java       | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java
index 4997c00..9f13a8f 100644
--- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java
+++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java
@@ -29,10 +29,10 @@ import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.UUID;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ConcurrentLinkedQueue;
 
 import org.apache.servicecomb.saga.alpha.core.EventType;
 import org.apache.servicecomb.saga.alpha.core.OmegaCallback;
@@ -94,7 +94,7 @@ public class AlphaIntegrationTest {
   @Autowired
   private TxConsistentService consistentService;
 
-  private static final List<GrpcCompensateCommand> receivedCommands = new CopyOnWriteArrayList<>();
+  private static final Queue<GrpcCompensateCommand> receivedCommands = new ConcurrentLinkedQueue<>();
   private final CompensateStreamObserver compensateResponseObserver = new CompensateStreamObserver();
 
   @AfterClass
@@ -219,11 +219,12 @@ public class AlphaIntegrationTest {
     blockingStub.onTxEvent(someGrpcEvent(TxAbortedEvent));
     await().atMost(1, SECONDS).until(() -> !receivedCommands.isEmpty());
 
-    assertThat(receivedCommands.get(0).getGlobalTxId(), is(globalTxId));
-    assertThat(receivedCommands.get(0).getLocalTxId(), is(localTxId));
-    assertThat(receivedCommands.get(0).getParentTxId(), is(parentTxId));
-    assertThat(receivedCommands.get(0).getCompensateMethod(), is(compensationMethod));
-    assertThat(receivedCommands.get(0).getPayloads().toByteArray(), is(payload.getBytes()));
+    GrpcCompensateCommand command = receivedCommands.poll();
+    assertThat(command.getGlobalTxId(), is(globalTxId));
+    assertThat(command.getLocalTxId(), is(localTxId));
+    assertThat(command.getParentTxId(), is(parentTxId));
+    assertThat(command.getCompensateMethod(), is(compensationMethod));
+    assertThat(command.getPayloads().toByteArray(), is(payload.getBytes()));
   }
 
   @Test
@@ -244,7 +245,7 @@ public class AlphaIntegrationTest {
     await().atMost(1, SECONDS).until(() -> !receivedCommands.isEmpty());
 
     assertThat(receivedCommands.size(), is(1));
-    assertThat(receivedCommands.get(0).getGlobalTxId(), is(globalTxId));
+    assertThat(receivedCommands.poll().getGlobalTxId(), is(globalTxId));
 
     anotherBlockingStub.onDisconnected(anotherServiceConfig);
   }

-- 
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].