You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/03/20 09:42:05 UTC

[GitHub] WillemJiang closed pull request #156: SCB-390 Update to introduece the byteman to the acceptance tests

WillemJiang closed pull request #156: SCB-390 Update to introduece the byteman to the acceptance tests
URL: https://github.com/apache/incubator-servicecomb-saga/pull/156
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/acceptance-tests/acceptance-pack/pom.xml b/acceptance-tests/acceptance-pack/pom.xml
index 49bd70bb..232c73b2 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 a433f65d..2646b1b9 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.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 PackStepdefs() {
       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 8445c76a..8e62bbd4 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 98f5f59f..624eb320 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 9e7a05c5..95db68d1 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 56f1d1c7..a8285e44 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 2fb54fa9..804f5367 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>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services