You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by il...@apache.org on 2019/07/03 14:07:25 UTC
[dubbo-samples] branch master updated: integration test for
dubbo-samples-zipkin
This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 6abf671 integration test for dubbo-samples-zipkin
6abf671 is described below
commit 6abf671bfd0be019d8874526065d4565fb72ecbd
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Wed Jul 3 22:05:16 2019 +0800
integration test for dubbo-samples-zipkin
---
dubbo-samples-zipkin/pom.xml | 441 +++++++++------------
.../apache/dubbo/samples/client/Application.java | 4 +-
.../samples/service/greeting/Application.java | 9 +-
.../service/greeting/GreetingServiceImpl.java | 7 -
.../dubbo/samples/service/hello/Application.java | 9 +-
.../samples/service/hello/HelloServiceImpl.java | 7 -
.../src/main/resources/docker/docker-compose.yml | 10 +
.../src/main/resources/spring/client.xml | 14 +-
.../src/main/resources/spring/greeting-service.xml | 20 +-
.../src/main/resources/spring/hello-service.xml | 16 +-
.../java/org/apache/dubbo/samples/TraceIT.java | 75 ++++
11 files changed, 306 insertions(+), 306 deletions(-)
diff --git a/dubbo-samples-zipkin/pom.xml b/dubbo-samples-zipkin/pom.xml
index 4c79c3c..ee208d7 100644
--- a/dubbo-samples-zipkin/pom.xml
+++ b/dubbo-samples-zipkin/pom.xml
@@ -28,139 +28,23 @@
<properties>
<source.level>1.8</source.level>
<target.level>1.8</target.level>
+ <!-- FIXME: cannot make zipkin work on 2.7.2, we may need to provide a new filter for zipkin -->
+ <dubbo.version>2.6.6</dubbo.version>
+ <curator.version>2.12.0</curator.version>
<spring.version>4.3.16.RELEASE</spring.version>
- <dubbo.version>2.7.0</dubbo.version>
- <dubbo.rpc.version>2.7.0</dubbo.rpc.version>
- <zookeeper.version>3.4.13</zookeeper.version>
- <curator.version>4.0.1</curator.version>
- <validation-api.version>1.1.0.Final</validation-api.version>
- <hibernate-validator.version>4.2.0.Final</hibernate-validator.version>
- <resteasy.version>3.0.19.Final</resteasy.version>
- <curator-client.version>4.0.1</curator-client.version>
- <swagger.version>1.5.19</swagger.version>
- <tomcat.version>7.0.88</tomcat.version>
- <servlet.version>3.0.1</servlet.version>
- <maven_checkstyle_version>3.0.0</maven_checkstyle_version>
- <apache-rat-plugin.version>0.12</apache-rat-plugin.version>
- <spring-boot.version>1.5.13.RELEASE</spring-boot.version>
- <brave.version>5.4.2</brave.version>
- <zipkin-reporter.version>2.7.9</zipkin-reporter.version>
+ <junit.version>4.12</junit.version>
+ <docker-maven-plugin.version>0.30.0</docker-maven-plugin.version>
+ <jib-maven-plugin.version>1.2.0</jib-maven-plugin.version>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
+ <image.name>${artifactId}:${dubbo.version}</image.name>
+ <brave.version>5.6.6</brave.version>
+ <zipkin-reporter.version>2.9.0</zipkin-reporter.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-framework-bom</artifactId>
- <version>${spring.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <!-- Import dependency management from Spring Boot -->
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>4.1.16.Final</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-bom</artifactId>
- <version>${dubbo.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-rest</artifactId>
- <version>${dubbo.rpc.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zookeeper.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- <version>${validation-api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>${hibernate-validator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jackson-provider</artifactId>
- <version>${resteasy.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-client</artifactId>
- <version>${curator-client.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>${servlet.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-juli</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <!-- swagger -->
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>${swagger.version}</version>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jaxrs</artifactId>
- <version>${swagger.version}</version>
- </dependency>
- <dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-bom</artifactId>
<version>${brave.version}</version>
@@ -180,43 +64,29 @@
<dependencies>
<dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.16.Final</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
+ <version>${curator.version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-zookeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
+
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-dubbo-rpc</artifactId>
@@ -236,122 +106,193 @@
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-sender-okhttp3</artifactId>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.7.0</version>
- <configuration>
- <source>${source.level}</source>
- <target>${target.level}</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>${apache-rat-plugin.version}</version>
- <executions>
- <execution>
- <id>verify.rat</id>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <excludes>
- <exclude>**/*.versionsBackup</exclude>
- <exclude>**/.idea/</exclude>
- <exclude>**/*.iml</exclude>
- <exclude>**/*.txt</exclude>
- <exclude>**/*.load</exclude>
- <exclude>**/*.flex</exclude>
- <exclude>**/*.fc</exclude>
- <exclude>**/*.javascript</exclude>
- <exclude>**/*.properties</exclude>
- <exclude>**/*.thrift</exclude>
- <exclude>**/*.sh</exclude>
- <exclude>**/*.bat</exclude>
- <exclude>**/*.md</exclude>
- <exclude>.git/</exclude>
- <exclude>.gitignore</exclude>
- <!-- ASF jenkins box puts the Maven repo in our root directory. -->
- <exclude>.repository/</exclude>
- <exclude>**/.settings/*</exclude>
- <exclude>**/.classpath</exclude>
- <exclude>**/.project</exclude>
- <exclude>**/target/**</exclude>
- <exclude>**/*.log</exclude>
- <exclude>CODE_OF_CONDUCT.md</exclude>
- <exclude>.codecov.yml</exclude>
- <exclude>.travis.yml</exclude>
- <exclude>PULL_REQUEST_TEMPLATE.md</exclude>
- <exclude>CONTRIBUTING.md</exclude>
- <exclude>README.md</exclude>
- <exclude>**/codestyle/*</exclude>
- <exclude>**/resources/META-INF/**</exclude>
- <exclude>**/webapp/swagger/**</exclude>
- <exclude>**/org/apache/dubbo/samples/rpc/nativethrift/api/DemoService.java</exclude>
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
<profiles>
<profile>
- <id>checkstyle</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
+ <id>dubbo-integration-test</id>
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>${maven_checkstyle_version}</version>
- <dependencies>
- <dependency>
- <groupId>com.puppycrawl.tools</groupId>
- <artifactId>checkstyle</artifactId>
- <version>8.9</version>
- </dependency>
- </dependencies>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-maven-address-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
<executions>
<execution>
- <id>checkstyle-validation</id>
- <phase>validate</phase>
+ <goals>
+ <goal>local-address</goal>
+ </goals>
<configuration>
- <configLocation>../codestyle/checkstyle.xml</configLocation>
- <suppressionsLocation>../codestyle/checkstyle-suppressions.xml</suppressionsLocation>
- <encoding>UTF-8</encoding>
- <consoleOutput>true</consoleOutput>
- <failOnViolation>true</failOnViolation>
+ <localAddress>dubbo-local-address</localAddress>
</configuration>
+ <phase>initialize</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>${docker-maven-plugin.version}</version>
+ <configuration>
+ <images>
+ <image>
+ <external>
+ <type>compose</type>
+ <basedir>src/main/resources/docker</basedir>
+ <composeFile>docker-compose.yml</composeFile>
+ </external>
+ </image>
+ </images>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <phase>post-integration-test</phase>
<goals>
- <goal>check</goal>
+ <goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.6.0</version>
+ <executions>
+ <execution>
+ <id>before-sleep</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>sleep</executable>
+ <arguments>
+ <argument>20</argument>
+ </arguments>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>hello-service</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>java</executable>
+ <arguments>
+ <argument>-classpath</argument>
+ <classpath/>
+ <argument>org.apache.dubbo.samples.service.hello.Application</argument>
+ </arguments>
+ <async>true</async>
+ <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>greeting-service</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>java</executable>
+ <arguments>
+ <argument>-classpath</argument>
+ <classpath/>
+ <argument>org.apache.dubbo.samples.service.greeting.Application</argument>
+ </arguments>
+ <async>true</async>
+ <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>after-sleep</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>sleep</executable>
+ <arguments>
+ <argument>10</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${maven-failsafe-plugin.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <zookeeper.address>${dubbo-local-address}</zookeeper.address>
+ </systemPropertyVariables>
+ <includes>
+ <include>**/*IT.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
</profiles>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
diff --git a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/client/Application.java b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/client/Application.java
index c793b5a..eb692ca 100644
--- a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/client/Application.java
+++ b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/client/Application.java
@@ -27,8 +27,8 @@ public class Application {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/client.xml");
context.start();
- // get remote service proxy
- GreetingService greetingService = (GreetingService) context.getBean("greetingService");
+
+ GreetingService greetingService = context.getBean("greetingService", GreetingService.class);
System.out.println(greetingService.greeting("world"));
}
}
diff --git a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/Application.java b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/Application.java
index 628e130..d733d90 100644
--- a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/Application.java
+++ b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/Application.java
@@ -19,15 +19,14 @@ package org.apache.dubbo.samples.service.greeting;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
public class Application {
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/greeting-service.xml");
context.start();
- System.out.println("Greeting service started");
- // press any key to exit
- System.in.read();
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
}
}
diff --git a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/GreetingServiceImpl.java b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/GreetingServiceImpl.java
index d8c545b..ad386da 100644
--- a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/GreetingServiceImpl.java
+++ b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/greeting/GreetingServiceImpl.java
@@ -21,8 +21,6 @@ package org.apache.dubbo.samples.service.greeting;
import org.apache.dubbo.samples.api.GreetingService;
import org.apache.dubbo.samples.api.HelloService;
-import java.util.Random;
-
public class GreetingServiceImpl implements GreetingService {
private HelloService helloService;
@@ -33,11 +31,6 @@ public class GreetingServiceImpl implements GreetingService {
@Override
public String greeting(String message) {
- try {
- Thread.sleep(new Random(System.currentTimeMillis()).nextInt(1000));
- } catch (InterruptedException e) {
- // no op
- }
return "greeting, " + helloService.hello(message);
}
}
diff --git a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/Application.java b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/Application.java
index 9100785..da41901 100644
--- a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/Application.java
+++ b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/Application.java
@@ -19,15 +19,14 @@ package org.apache.dubbo.samples.service.hello;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
public class Application {
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hello-service.xml");
context.start();
- System.out.println("Hello service started");
- // press any key to exit
- System.in.read();
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
}
}
diff --git a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/HelloServiceImpl.java b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/HelloServiceImpl.java
index db91cba..9246cff 100644
--- a/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/HelloServiceImpl.java
+++ b/dubbo-samples-zipkin/src/main/java/org/apache/dubbo/samples/service/hello/HelloServiceImpl.java
@@ -20,16 +20,9 @@ package org.apache.dubbo.samples.service.hello;
import org.apache.dubbo.samples.api.HelloService;
-import java.util.Random;
-
public class HelloServiceImpl implements HelloService {
@Override
public String hello(String message) {
- try {
- Thread.sleep(new Random(System.currentTimeMillis()).nextInt(1000));
- } catch (InterruptedException e) {
- // no op
- }
return "hello, " + message;
}
}
diff --git a/dubbo-samples-zipkin/src/main/resources/docker/docker-compose.yml b/dubbo-samples-zipkin/src/main/resources/docker/docker-compose.yml
new file mode 100644
index 0000000..71228d5
--- /dev/null
+++ b/dubbo-samples-zipkin/src/main/resources/docker/docker-compose.yml
@@ -0,0 +1,10 @@
+version: "2"
+services:
+ zookeeper:
+ image: "zookeeper:latest"
+ ports:
+ - "2181:2181"
+ zipkin:
+ image: "openzipkin/zipkin"
+ ports:
+ - "9411:9411"
diff --git a/dubbo-samples-zipkin/src/main/resources/spring/client.xml b/dubbo-samples-zipkin/src/main/resources/spring/client.xml
index 942c7ee..3e07469 100644
--- a/dubbo-samples-zipkin/src/main/resources/spring/client.xml
+++ b/dubbo-samples-zipkin/src/main/resources/spring/client.xml
@@ -18,19 +18,17 @@
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
- <!-- consumer's application name, used for tracing dependency relationship (not a matching criterion),
- don't set it same as provider -->
<dubbo:application name="dubbo-client"/>
- <!-- use zookeeper registry center to discover service -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <!-- generate proxy for the remote service, then demoService can be used in the same way as the local regular interface -->
- <dubbo:reference id="greetingService" check="false" interface="com.alibaba.dubbo.samples.api.GreetingService" filter="tracing"/>
+ <dubbo:reference id="greetingService" check="false" interface="org.apache.dubbo.samples.api.GreetingService"
+ filter="tracing"/>
<!-- zipkin configuration -->
<bean id="sender" class="zipkin2.reporter.beans.OkHttpSenderFactoryBean">
diff --git a/dubbo-samples-zipkin/src/main/resources/spring/greeting-service.xml b/dubbo-samples-zipkin/src/main/resources/spring/greeting-service.xml
index 603de2f..99b37f7 100644
--- a/dubbo-samples-zipkin/src/main/resources/spring/greeting-service.xml
+++ b/dubbo-samples-zipkin/src/main/resources/spring/greeting-service.xml
@@ -18,29 +18,25 @@
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
- <!-- provider's application name, used for tracing dependency relationship -->
<dubbo:application name="greeting-service-provider"/>
- <!-- use zookeeper registry center to export service -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <!-- use dubbo protocol to export service on port 20881 -->
<dubbo:protocol name="dubbo" port="20881"/>
- <!-- service implementation, as same as regular local bean -->
- <bean id="greetingService" class="com.alibaba.dubbo.samples.service.greeting.GreetingServiceImpl">
+ <bean id="greetingService" class="org.apache.dubbo.samples.service.greeting.GreetingServiceImpl">
<property name="helloService" ref="helloService"/>
</bean>
- <!-- declare the service interface to be exported -->
- <dubbo:service interface="com.alibaba.dubbo.samples.api.GreetingService" ref="greetingService" filter="tracing"/>
+ <dubbo:service interface="org.apache.dubbo.samples.api.GreetingService" ref="greetingService" filter="tracing"/>
- <!-- generate proxy for the remote service, then helloService can be used in the same way as the local regular interface -->
- <dubbo:reference id="helloService" check="false" interface="com.alibaba.dubbo.samples.api.HelloService" filter="tracing"/>
+ <dubbo:reference id="helloService" check="false" interface="org.apache.dubbo.samples.api.HelloService"
+ filter="tracing"/>
<!-- zipkin configuration -->
<bean id="sender" class="zipkin2.reporter.beans.OkHttpSenderFactoryBean">
diff --git a/dubbo-samples-zipkin/src/main/resources/spring/hello-service.xml b/dubbo-samples-zipkin/src/main/resources/spring/hello-service.xml
index 518e090..af94eff 100644
--- a/dubbo-samples-zipkin/src/main/resources/spring/hello-service.xml
+++ b/dubbo-samples-zipkin/src/main/resources/spring/hello-service.xml
@@ -18,24 +18,20 @@
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
- <!-- provider's application name, used for tracing dependency relationship -->
<dubbo:application name="hello-service-provider"/>
- <!-- use zookeeper registry center to export service -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <!-- use dubbo protocol to export service on port 20880 -->
<dubbo:protocol name="dubbo" port="20880"/>
- <!-- service implementation, as same as regular local bean -->
- <bean id="helloService" class="com.alibaba.dubbo.samples.service.hello.HelloServiceImpl"/>
+ <bean id="helloService" class="org.apache.dubbo.samples.service.hello.HelloServiceImpl"/>
- <!-- declare the service interface to be exported -->
- <dubbo:service interface="com.alibaba.dubbo.samples.api.HelloService" ref="helloService" filter="tracing"/>
+ <dubbo:service interface="org.apache.dubbo.samples.api.HelloService" ref="helloService" filter="tracing"/>
<!-- zipkin configuration -->
<bean id="sender" class="zipkin2.reporter.beans.OkHttpSenderFactoryBean">
diff --git a/dubbo-samples-zipkin/src/test/java/org/apache/dubbo/samples/TraceIT.java b/dubbo-samples-zipkin/src/test/java/org/apache/dubbo/samples/TraceIT.java
new file mode 100644
index 0000000..7d277e7
--- /dev/null
+++ b/dubbo-samples-zipkin/src/test/java/org/apache/dubbo/samples/TraceIT.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.samples;
+
+import org.apache.dubbo.samples.api.GreetingService;
+
+import com.google.gson.Gson;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.List;
+import java.util.Map;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:/spring/client.xml"})
+public class TraceIT {
+ private static String zipkinAddress = "http://" + System.getProperty("zipkin.address", "localhost") + ":" +
+ Integer.getInteger("zipkin.port", 9411);
+
+ @Autowired
+ private GreetingService greetingService;
+
+ @Test
+ public void testTrace() throws Exception {
+ Assert.assertEquals("greeting, hello, world", greetingService.greeting("world"));
+
+ Thread.sleep(1000);
+
+ OkHttpClient client = new OkHttpClient();
+
+ Request request = new Request.Builder().url(zipkinAddress + "/api/v2/services").addHeader(
+ "accept", "application/json").build();
+ try (Response response = client.newCall(request).execute()) {
+ String s = response.body().string();
+ Gson gson = new Gson();
+ List services = gson.fromJson(s, List.class);
+ Assert.assertTrue(services.contains("client"));
+ Assert.assertTrue(services.contains("greeting-service"));
+ Assert.assertTrue(services.contains("hello-service"));
+ }
+
+ request = new Request.Builder().url(zipkinAddress + "/api/v2/traces?serviceName=client").addHeader(
+ "accept", "application/json").build();
+ try (Response response = client.newCall(request).execute()) {
+ String s = response.body().string();
+ Gson gson = new Gson();
+ Map[][] traces = gson.fromJson(s, Map[][].class);
+ Assert.assertTrue(traces.length > 0);
+ Map span = traces[0][0];
+ Assert.assertNotNull(span.get("traceId"));
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org