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/03/20 09:42:07 UTC
[incubator-servicecomb-saga] branch master updated: SCB-390 Update
to introduece the byteman to the acceptance tests
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
The following commit(s) were added to refs/heads/master by this push:
new 0d04161 SCB-390 Update to introduece the byteman to the acceptance tests
0d04161 is described below
commit 0d04161b9ea1ea1793fb1a0c9c64a08103488867
Author: Zheng Feng <zh...@gmail.com>
AuthorDate: Tue Mar 20 14:05:47 2018 +0800
SCB-390 Update to introduece the byteman to the acceptance tests
---
acceptance-tests/acceptance-pack/pom.xml | 38 ++++++++++++++++++++--
.../org/apache/servicecomb/saga/PackStepdefs.java | 11 +++++++
pom.xml | 2 ++
saga-demo/booking/booking/pom.xml | 11 +++++++
saga-demo/booking/car/pom.xml | 11 +++++++
saga-demo/booking/hotel/pom.xml | 11 +++++++
saga-demo/pom.xml | 34 +++++++++++++++++++
7 files changed, 115 insertions(+), 3 deletions(-)
diff --git a/acceptance-tests/acceptance-pack/pom.xml b/acceptance-tests/acceptance-pack/pom.xml
index 49bd70b..232c73b 100644
--- a/acceptance-tests/acceptance-pack/pom.xml
+++ b/acceptance-tests/acceptance-pack/pom.xml
@@ -40,6 +40,11 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-submit</artifactId>
+ <version>${byteman.version}</version>
+ </dependency>
</dependencies>
<profiles>
@@ -111,13 +116,17 @@
<alias>car</alias>
<run>
<env>
- <JAVA_OPTS />
+ <JAVA_OPTS>
+ -Dorg.jboss.byteman.debug=true -Dorg.jboss.byteman.verbose=true
+ -javaagent:/maven/saga/byteman.jar=port:9091,address:0.0.0.0,listener:true
+ </JAVA_OPTS>
</env>
<wait>
<log>Started [a-zA-Z]+ in [0-9.]+ seconds</log>
<tcp>
<ports>
<port>8080</port>
+ <port>9091</port>
</ports>
</tcp>
<time>120000</time>
@@ -127,6 +136,7 @@
</links>
<ports>
<port>car.port:8080</port>
+ <port>car.byteman.port:9091</port>
</ports>
</run>
</image>
@@ -135,13 +145,17 @@
<alias>hotel</alias>
<run>
<env>
- <JAVA_OPTS />
+ <JAVA_OPTS>
+ -Dorg.jboss.byteman.debug=true -Dorg.jboss.byteman.verbose=true
+ -javaagent:/maven/saga/byteman.jar=port:9091,address:0.0.0.0,listener:true
+ </JAVA_OPTS>
</env>
<wait>
<log>Started [a-zA-Z]+ in [0-9.]+ seconds</log>
<tcp>
<ports>
<port>8080</port>
+ <port>9091</port>
</ports>
</tcp>
<time>120000</time>
@@ -151,6 +165,7 @@
</links>
<ports>
<port>hotel.port:8080</port>
+ <port>hotel.byteman.port:9091</port>
</ports>
</run>
</image>
@@ -159,13 +174,17 @@
<alias>booking</alias>
<run>
<env>
- <JAVA_OPTS />
+ <JAVA_OPTS>
+ -Dorg.jboss.byteman.debug=true -Dorg.jboss.byteman.verbose=true
+ -javaagent:/maven/saga/byteman.jar=port:9091,address:0.0.0.0,listener:true
+ </JAVA_OPTS>
</env>
<wait>
<log>Started [a-zA-Z]+ in [0-9.]+ seconds</log>
<tcp>
<ports>
<port>8080</port>
+ <port>9091</port>
</ports>
</tcp>
<time>120000</time>
@@ -177,6 +196,7 @@
</links>
<ports>
<port>booking.port:8080</port>
+ <port>booking.byteman.port:9091</port>
</ports>
</run>
</image>
@@ -242,6 +262,18 @@
<spring.datasource.url>
jdbc:postgresql://${docker.hostname}:${postgres.port}/saga?useSSL=false
</spring.datasource.url>
+ <byteman.address>
+ ${docker.hostname}
+ </byteman.address>
+ <car.byteman.port>
+ ${car.byteman.port}
+ </car.byteman.port>
+ <hotel.byteman.port>
+ ${hotel.byteman.port}
+ </hotel.byteman.port>
+ <booking.byteman.port>
+ ${booking.byteman.port}
+ </booking.byteman.port>
</systemPropertyVariables>
<argLine>${jacoco.failsafe.argLine}</argLine>
</configuration>
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 a433f65..2646b1b 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
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
+import org.jboss.byteman.agent.submit.Submit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,6 +66,16 @@ public class PackStepdefs implements En {
probe(System.getProperty(ALPHA_REST_ADDRESS));
});
+ Given("^Install the byteman script ([A-Za-z0-9_\\.]+) to ([A-Za-z]+) Service$", (String script, String service) -> {
+ String address = System.getProperty("byteman.address");
+ String port = System.getProperty(service.toLowerCase() + ".byteman.port");
+ log.info("Install the byteman script {} to {} service with {}:{}", script, service, address, port);
+ Submit bm = new Submit(address, Integer.parseInt(port));
+ List<String> rules = new ArrayList<>();
+ rules.add("target/test-classes/" + script);
+ bm.addRulesFromFiles(rules);
+ });
+
When("^User ([A-Za-z]+) requests to book ([0-9]+) cars and ([0-9]+) rooms$", (username, cars, rooms) -> {
log.info("Received request from user {} to book {} cars and {} rooms", username, cars, rooms);
diff --git a/pom.xml b/pom.xml
index 8445c76..8e62bbd 100755
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,8 @@
<javax.transaction.version>1.2</javax.transaction.version>
<eclipse.link.version>2.7.1</eclipse.link.version>
<jackson.version>2.9.0</jackson.version>
+ <byteman.version>4.0.1</byteman.version>
+ <maven-dependency-plugin.version>3.0.2</maven-dependency-plugin.version>
</properties>
<name>ServiceComb Saga</name>
diff --git a/saga-demo/booking/booking/pom.xml b/saga-demo/booking/booking/pom.xml
index 98f5f59..624eb32 100644
--- a/saga-demo/booking/booking/pom.xml
+++ b/saga-demo/booking/booking/pom.xml
@@ -77,6 +77,17 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>demo</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/saga-demo/booking/car/pom.xml b/saga-demo/booking/car/pom.xml
index 9e7a05c..95db68d 100644
--- a/saga-demo/booking/car/pom.xml
+++ b/saga-demo/booking/car/pom.xml
@@ -77,6 +77,17 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>demo</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/saga-demo/booking/hotel/pom.xml b/saga-demo/booking/hotel/pom.xml
index 56f1d1c..a8285e4 100644
--- a/saga-demo/booking/hotel/pom.xml
+++ b/saga-demo/booking/hotel/pom.xml
@@ -77,6 +77,17 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>demo</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/saga-demo/pom.xml b/saga-demo/pom.xml
index 2fb54fa..804f536 100644
--- a/saga-demo/pom.xml
+++ b/saga-demo/pom.xml
@@ -54,6 +54,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>${maven-dependency-plugin.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -66,6 +71,35 @@
</dependencies>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>byteman.copy</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <version>${byteman.version}</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/saga</outputDirectory>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
--
To stop receiving notification emails like this one, please contact
ningjiang@apache.org.