You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/01/25 10:40:31 UTC
[incubator-servicecomb-saga] branch master updated (22ea88d ->
506a10e)
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git.
from 22ea88d SCB-237 checked availability of alpha and booking before testing
new bb71db0 SCB-278 added successful compensation scenario
new 6c87b33 SCB-278 attempted to fix random test failure by waiting a bit longer
new 506a10e SCB-278 reordered expectations to fix random test failure
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/servicecomb/saga/PackStepdefs.java | 34 +++++++++++++++++-----
.../resources/pack_compensation_scenario.feature | 26 +++++++++++++++++
acceptance-tests/pom.xml | 4 +++
.../saga/alpha/server/AlphaIntegrationTest.java | 7 +++--
4 files changed, 61 insertions(+), 10 deletions(-)
create mode 100644 acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.
[incubator-servicecomb-saga] 02/03: SCB-278 attempted to fix random
test failure by waiting a bit longer
Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit 6c87b3300b6fb78319002e325e186d40fba1dc4c
Author: seanyinx <se...@huawei.com>
AuthorDate: Thu Jan 25 15:31:51 2018 +0800
SCB-278 attempted to fix random test failure by waiting a bit longer
Signed-off-by: seanyinx <se...@huawei.com>
---
.../apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java | 7 ++++---
1 file changed, 4 insertions(+), 3 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 5dddc1d..539f610 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
@@ -361,9 +361,10 @@ public class AlphaIntegrationTest {
blockingStub.onTxEvent(someGrpcEvent(TxEndedEvent, globalTxId, anotherLocalTxId));
- await().atMost(1, SECONDS).until(() -> eventRepo.count() == 8);
- List<TxEvent> events = eventRepo.findByGlobalTxId(globalTxId);
- assertThat(events.get(events.size() - 1).type(), is(SagaEndedEvent.name()));
+ await().atMost(1, SECONDS).until(() -> {
+ List<TxEvent> events = eventRepo.findByGlobalTxId(globalTxId);
+ return events.size() == 8 && events.get(events.size() - 1).type().equals(SagaEndedEvent.name());
+ });
}
private GrpcAck onCompensation(GrpcCompensateCommand command) {
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.
[incubator-servicecomb-saga] 01/03: SCB-278 added successful
compensation scenario
Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit bb71db0320b8309ae6ccb4f9d9f3acb4f0fb796a
Author: seanyinx <se...@huawei.com>
AuthorDate: Thu Jan 25 15:10:38 2018 +0800
SCB-278 added successful compensation scenario
Signed-off-by: seanyinx <se...@huawei.com>
---
.../org/apache/servicecomb/saga/PackStepdefs.java | 34 +++++++++++++++++-----
.../resources/pack_compensation_scenario.feature | 26 +++++++++++++++++
acceptance-tests/pom.xml | 4 +++
3 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/acceptance-tests/acceptance-pack/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java b/acceptance-tests/acceptance-pack/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java
index 42e9f90..a433f65 100644
--- a/acceptance-tests/acceptance-pack/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java
+++ b/acceptance-tests/acceptance-pack/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java
@@ -18,10 +18,14 @@
package org.apache.servicecomb.saga;
import static io.restassured.RestAssured.given;
-import static java.util.Arrays.asList;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.awaitility.Awaitility.await;
import static org.hamcrest.core.Is.is;
import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
@@ -69,9 +73,7 @@ public class PackStepdefs implements En {
.pathParam("rooms", rooms)
.pathParam("cars", cars)
.when()
- .post(System.getProperty("booking.service.address") + "/booking/{name}/{rooms}/{cars}")
- .then()
- .statusCode(is(200));
+ .post(System.getProperty("booking.service.address") + "/booking/{name}/{rooms}/{cars}");
});
Then("^Alpha records the following events$", (DataTable dataTable) -> {
@@ -112,6 +114,26 @@ public class PackStepdefs implements En {
@SuppressWarnings("unchecked")
private void dataMatches(String address, DataTable dataTable, Consumer<Map<String, String>[]> dataProcessor) {
+ List<Map<String, String>> expectedMaps = dataTable.asMaps(String.class, String.class);
+ List<Map<String, String>> actualMaps = new ArrayList<>();
+
+ await().atMost(2, SECONDS).until(() -> {
+ actualMaps.clear();
+ Collections.addAll(actualMaps, retrieveDataMaps(address, dataProcessor));
+
+ return expectedMaps.size() == actualMaps.size();
+ });
+
+ if (expectedMaps.isEmpty() && actualMaps.isEmpty()) {
+ return;
+ }
+
+ log.info("Retrieved data {} from service", actualMaps);
+ dataTable.diff(DataTable.create(actualMaps));
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, String>[] retrieveDataMaps(String address, Consumer<Map<String, String>[]> dataProcessor) {
Map<String, String>[] dataMap = given()
.when()
.get(address)
@@ -122,9 +144,7 @@ public class PackStepdefs implements En {
.as(Map[].class);
dataProcessor.accept(dataMap);
-
- log.info("Retrieved data {} from service", dataMap);
- dataTable.diff(DataTable.create(asList(dataMap)));
+ return dataMap;
}
private void probe(String address) {
diff --git a/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature b/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature
new file mode 100644
index 0000000..170fcfe
--- /dev/null
+++ b/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature
@@ -0,0 +1,26 @@
+Feature: Alpha records transaction events
+
+ Scenario: A sub-transaction failed and global transaction compensated
+ Given Car Service is up and running
+ And Hotel Service is up and running
+ And Booking Service is up and running
+ And Alpha is up and running
+
+ When User Sean requests to book 5 cars and 3 rooms
+
+ Then Car Service contains the following booking orders
+ | name | amount | confirmed | cancelled |
+ | Sean | 5 | false | true |
+
+ Then Hotel Service contains the following booking orders
+ | name | amount | confirmed | cancelled |
+
+ Then Alpha records the following events
+ | serviceName | type |
+ | pack-booking | SagaStartedEvent |
+ | pack-car | TxStartedEvent |
+ | pack-car | TxEndedEvent |
+ | pack-hotel | TxStartedEvent |
+ | pack-hotel | TxAbortedEvent |
+ | pack-car | TxCompensatedEvent |
+ | pack-car | SagaEndedEvent |
diff --git a/acceptance-tests/pom.xml b/acceptance-tests/pom.xml
index 7e1ebbf..24c09ca 100644
--- a/acceptance-tests/pom.xml
+++ b/acceptance-tests/pom.xml
@@ -78,6 +78,10 @@
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ </dependency>
</dependencies>
</project>
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.
[incubator-servicecomb-saga] 03/03: SCB-278 reordered expectations
to fix random test failure
Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit 506a10e9275560b2a7adc3945cbda963264921b6
Author: seanyinx <se...@gmail.com>
AuthorDate: Thu Jan 25 15:51:34 2018 +0800
SCB-278 reordered expectations to fix random test failure
Signed-off-by: seanyinx <se...@gmail.com>
---
.../src/test/resources/pack_compensation_scenario.feature | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature b/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature
index 170fcfe..81e5ac5 100644
--- a/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature
+++ b/acceptance-tests/acceptance-pack/src/test/resources/pack_compensation_scenario.feature
@@ -8,13 +8,6 @@ Feature: Alpha records transaction events
When User Sean requests to book 5 cars and 3 rooms
- Then Car Service contains the following booking orders
- | name | amount | confirmed | cancelled |
- | Sean | 5 | false | true |
-
- Then Hotel Service contains the following booking orders
- | name | amount | confirmed | cancelled |
-
Then Alpha records the following events
| serviceName | type |
| pack-booking | SagaStartedEvent |
@@ -24,3 +17,10 @@ Feature: Alpha records transaction events
| pack-hotel | TxAbortedEvent |
| pack-car | TxCompensatedEvent |
| pack-car | SagaEndedEvent |
+
+ Then Car Service contains the following booking orders
+ | name | amount | confirmed | cancelled |
+ | Sean | 5 | false | true |
+
+ Then Hotel Service contains the following booking orders
+ | name | amount | confirmed | cancelled |
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.