I write a test in AlphaIntegrationTest like this,
```Java
  @Test
  public void compensateTxEndedEventAfterOtherTxAborted() {
    String sagaGlobalId = UUID.randomUUID().toString();
    String bookingApplicationLocalId = UUID.randomUUID().toString();
    String carServiceLocalId = UUID.randomUUID().toString();
    String hotelServiceLocalId = UUID.randomUUID().toString();

    asyncStub.onConnected(serviceConfig, compensateResponseObserver);

    blockingStub
            .onTxEvent(someGrpcEvent(SagaStartedEvent, sagaGlobalId, 
bookingApplicationLocalId));

    blockingStub.onTxEvent(someGrpcEvent(TxStartedEvent, sagaGlobalId, 
carServiceLocalId));
    blockingStub.onTxEvent(someGrpcEvent(TxAbortedEvent, sagaGlobalId, 
carServiceLocalId));

    blockingStub.onTxEvent(someGrpcEvent(TxStartedEvent, sagaGlobalId, 
hotelServiceLocalId));
    blockingStub.onTxEvent(someGrpcEvent(TxEndedEvent, sagaGlobalId, 
hotelServiceLocalId));

    await().atMost(30, SECONDS).until(() -> receivedCommands.size() > 0); 
//fail here
    assertThat(receivedCommands.size(), is(1));

    GrpcCompensateCommand command = receivedCommands.poll();
    assertThat(command.getGlobalTxId(), is(sagaGlobalId));
    assertThat(command.getLocalTxId(), is(hotelServiceLocalId));
    assertThat(command.getParentTxId(), is(parentTxId));
    assertThat(command.getCompensationMethod(), is(compensationMethod));
    assertThat(command.getPayloads().toByteArray(), is(payload.getBytes()));
  }

```

is it a valid testcase?

[ Full content available at: 
https://github.com/apache/incubator-servicecomb-saga/issues/281 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to