Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Add crossdock tests (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
oibe authored and yurishkuro committed Jul 27, 2016
1 parent 2669bc3 commit e309a7e
Show file tree
Hide file tree
Showing 31 changed files with 1,546 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
sudo: required

language: java

services:
- docker

env:
global:
- DOCKER_VERSION=1.11.1-0~trusty
- DOCKER_COMPOSE_VERSION=1.7.0
- COMMIT=${TRAVIS_COMMIT::8}
# SONATYPE_USERNAME=<sonatype username>
- secure: PRiEM4oGX4yjIzQlGMg+C28LdrkikUO8fsCXul0O+mJQ6Yua3b+G9HOC586UvyqAY4mFvSGP/EIefBuRLVQhFKvHpxHtfjpGg3w2Txq9KxiY5DjaYFuihKPz8Zs+PAZXd8rWqQvjZFkpHHmXdQG5I4MRSCb5Pkk/T3uwJqDCpcQeaBxWIglwVm4etM4pBxQT7BCVKvh4CJ6vNJuLPRRqn4CqgnZV9ytcrUoOF3binbdP2S2KImBqimAyLW3ThqTaJ2xkGWTKI7oc3k2NCejIFUPcf9dzzZ4aKKu9x9t94v7QSwLOE+9tQh5F0W3C89qcG9SmPVaTS7QwQhKwFP92BfMbobu056VSxSFielQ5DvPTaAiStGBzr/2Uhn+KITjSRNj6dX6tjaL9q/8TFE+g0QZIP00PhfzzNOde5Nlh8fUu3bo+4X6Y+WPXHEe8SfLdVYIb6+1zvxkNyWHQoeN+uDGIDSOgWYT74tz0HBcpt2WIrOPaSc6m6RaZKC8dOuWODY+HRZXetwvsYa/aw+Y/7aGJgh7oJqNM5/D2Cc9tp/Q81J5pGZZEjNF+lcjMX8A8COk4TKtd9SbL+a5BeNUOcu8wWJZ/5vEHi2MaghfCr0xVDqQVrKbHQS1UH/qnholpUOD35iP4wVl9r3ftee1yuH35ZNFUZIGlAmLhvZ5LQgY=
# SONATYPE_PASSWORD=<sonatype password>
- secure: gqAqV1tCjiqAzbreGsgvlcXCg9M7MLyyc+9v7/booL+eNqjevQ25CEzLSBoQQnJAKNDixHloCwCxRIbCrc3HcAl/8V6NZ8JxzUPoxKzN3yr4SPyD+KcJSNDwPqCHScKnMbuBPGKPcZFng2XyIpKAAAzqmc+zMpKRBdos4l27l5b4NdPHJUPRgFpqyL2oZY5nzeqzB/akP1c0jOZOSbfl4JVdXflYAWiXtA3zesVCJcrsYrQQ/xpL4ziETqy9UFZnMcBH9KADx6gCyoZMsf9OfVCGl0YGBb1LECIUYi/74b8TPp18+oUNYnpZScsOHmUSdmFrkIb/y714OIYPDQPhpny/aPXkBHH2ze+7AQGHNPoNJJZsG/W7/pj4AH91HGLVBxGApuA95WNFoIglHWtII+uvraeiTWaeC6VYOrwDdLHy5Aijtr1lH+zqFOfzSWGyj6Blt8x3aKsZmnFA4b8h+l0y+VjEFqmZIf9yKLlShieyhCWdZtIEwmeB120zbFIJHRfHClOs7Zwel4uE2HCJVSqP24auhA5j7uHYPBBSD/+VZRoeDiDE0qjRO0ZeXAUP6EIrplZecDWZXYZhW6XOHWpHittbCAisz2m43DEXSunISrLS5ONkjeDUfn42q24c80/gwPlG+7zLynwrJ1sO7EHECPhoPmUpilaQ+j4kmt4=
# DOCKER_USERNAME=<docker username>
- secure: q19fJLh2aO583rOALLKor4FeQr5u3EWKtUNhOyrUR9k7FLVk/9cLIrLr77DWdYxn0DE123DeHHm+GB7vEL85DmhJXUy3Bqpkjqr/eOZwtzGuCeDY9q7pO3eJJ8V3Fhw0p9rvGq1yg/nEO6S9whE+IUFxUanSIsjltM93KEfeaOGEvi5vkfKoD1etgGh8tx3d69Q17SyfHl+xRMW4KOVe3vdjUUnFPINhqmjKaYRmbsZ3yx7cuX+i6qbpW3Biypy/zjeu/35CfjQIiB8rgo8G6qtbGj9gfMzt3xmDL2LEOJtIx4nDJ3wPMVsGUGbu8LhNzX71EddbnqdWwjLnyoYAEYynu13q8rHljA+NlT8mPBP4wX00TTtJoWmwCmMnWgRcFPMS50cVBDwLLANZcVPU6iNY/+0AE4ANlzWHDLD/0pTqvYB5Z2UIVbXPuvkys7xBL5pKFnqTXVlWQuTRkSO8PXnSo24QP04AcjlkHnqNPesjkztFh4DSOfyL/6BiLebKDo6C+KNcN6Ep9SYpVfkwYDLV2qtfbiLxu4wjAgQjxPk701VGMfywmMvHaqa7UQpXQfEvHM/kTYJGknqf80WvXo/ilnvb9esANEP6cJZ3Z9h7Sq9P/ytec5NqPRaKVaMmN5bJXNY30g7MLkyD1fAMKIkaUfFdKNFzZVAAmsC7fho=
# DOCKER_PASSWORD=<docker password>
- secure: aj5LcCTpFS+e/bgOkyteSj85SplvGAgeje+Rbo8C5jgxScnHutalAEECnlXJBvxdke8OE4s+J8dX4cKoHf0XXial8hwEwfm+r/wPeTpr06L0eleBGfGsiF0dsYApIs3EmIoA+4x3LGB0BTta/XOfNzj9TFkaf3NExn6GClXAzx51tyJm3C8Yt3OP756dga8opU8iIBvKIA7bgn2pOs7xBSd2Dx7J8jBsw3uBXKtpyVLj6n7fl0EaVEVpF9Od7ASeJ0+P9x2pEkiqZhuMHm4mj+BaUqIJABRZ93PqiEDxHG/pnoJiIbXVis3LFTxFKQVYLG53eoZuww1h09TW+m1oDe6cNpkt7TanaKZ8a5oT/sgHUZHzP5Tlvv8UiqcaTQDlxaszYgcOZkfRHctMNVc0Wyr0QEft77c0jsK8lCyudzMhXKxj+MFoYxkUx61vBWQvnToJdP1YHk0c7YWzPADEIwRG2v2rXZvx1CmWcMDtxtcU+gSrtcD/8GMFuKKHDV7EAvApKSLl5OoAioHPVZLNvZbrPFaVV6dpdrGB3kkWNf+WSu6F0IG/CCGStykJbNivyBYv87Ngs6iAVKYUW2uiuICd8Eb+Ak/J2T05t1kJaZRwfzXKVGAOHdn3lloah8bSGRPhbvT3PwkRXPwYRHL/jE5g/el0Bq1LI3tn/6VyDhM=

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.thrift-build

before_install:
- apt-cache madison docker-engine
- sudo apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION}
Expand All @@ -28,8 +39,14 @@ before_install:
- sudo mv docker-compose /usr/local/bin
- docker-compose version
- bash travis/install-thrift.sh

script:
- make test
- make crossdock-fresh

after_success:
- ./gradlew jacocoTestReport coveralls
- ./gradlew uploadArchives -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}"

after_script:
- bash travis/publish_docker_image.sh
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

-include jaeger-java-crossdock/rules.mk

.PHONY: clean
clean:
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id "jacoco"
id "com.github.kt3k.coveralls" version "2.5.0"
id "com.github.hierynomus.license" version "0.12.1"
id "com.github.johnrengelman.shadow" version "1.2.3"
}


Expand Down
6 changes: 6 additions & 0 deletions jaeger-java-crossdock/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM maven:3.3-jdk-7
EXPOSE 8080-8082

ADD build/libs/jaeger-java-crossdock.jar /

CMD ["java", "-jar", "jaeger-java-crossdock.jar"]
66 changes: 66 additions & 0 deletions jaeger-java-crossdock/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.github.johnrengelman.shadow'


description = 'A jaeger instrumented java server meant for testing interoperability with different Jaeger clients through the use of crossdock (https://github.com/crossdock/crossdock)'
ext.jacksonVersion = '2.7.4'
shadowJar.archiveName = 'jaeger-java-crossdock.jar'

dependencies {
compile project(':jaeger-jaxrs2')

compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http', version: jerseyVersion
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: jerseyVersion
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: jerseyVersion
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: jerseyVersion
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy', version: '2.12'
compile group: 'javax.servlet', name: 'servlet-api', version: '2.5'
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.4.1'


// Testing Frameworks
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.16'
testCompile group: 'junit', name: 'junit', version: '4.12'
}

jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
html.destination "${buildDir}/jacocoHtml"
}

afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it,
exclude: [
'**/*Test*',
])
})
}
}

sourceSets {
main {
java {
srcDir 'src/main/java'
}
}

test {
java {
srcDir 'src/test/java'
}
}
}

jar {
from sourceSets.main.output
from sourceSets.test.output
manifest {
attributes('Implementation-jaeger-java-crossdock': 'jaeger-java-crossdock', 'Implementation-Version': project.version)
attributes 'Main-Class': 'com.uber.jaeger.crossdock.JerseyServer'
}
}
52 changes: 52 additions & 0 deletions jaeger-java-crossdock/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '2'

services:
crossdock:
image: crossdock/crossdock
links:
- go
- java
environment:
- WAIT_FOR=go,java

- AXIS_CLIENT=go
- AXIS_S1NAME=go,java
- AXIS_SAMPLED=true,false
- AXIS_S2NAME=go,java
- AXIS_S2TRANSPORT=http,tchannel
- AXIS_S3NAME=go,java
- AXIS_S3TRANSPORT=http,tchannel

- BEHAVIOR_TRACE=client,s1name,sampled,s2name,s2transport,s3name,s3transport

- REPORT=compact
go:
image: jaegertracing/xdock-go
ports:
- "8080-8082"

java:
build: .
ports:
- "8080-8082"
# node:
# image: yarpc/yarpc-node
# ports:
# - "8080-8082"
#
# java:
# image: yarpc/yarpc-java
# ports:
# - "8080-8082"
#
# python:
# image: yarpc/yarpc-python
# ports:
# - "8080:8082"
#
# python-sync:
# image: yarpc/yarpc-python
# ports:
# - 8080
# environment:
# - SYNC=1
21 changes: 21 additions & 0 deletions jaeger-java-crossdock/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PROJCT=jaeger-java-crossdock
XDOCK_YAML=$(PROJCT)/docker-compose.yml

.PHONY: crossdock
crossdock: gradle-compile
docker-compose -f $(XDOCK_YAML) kill java
docker-compose -f $(XDOCK_YAML) rm -f java
docker-compose -f $(XDOCK_YAML) build java
docker-compose -f $(XDOCK_YAML) run crossdock 2>&1 | tee run-crossdock.log
grep 'Tests passed!' run-crossdock.log

.PHONY: crossdock-fresh
crossdock-fresh: gradle-compile
docker-compose -f $(XDOCK_YAML) kill
docker-compose -f $(XDOCK_YAML) rm --force
docker-compose -f $(XDOCK_YAML) pull
docker-compose -f $(XDOCK_YAML) build
docker-compose -f $(XDOCK_YAML) run crossdock

gradle-compile:
./gradlew clean :jaeger-java-crossdock:shadowJar
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.uber.jaeger.crossdock;

public class Constants {
public final static String BAGGAGE_KEY = "crossdock-baggage-key";
public final static String TRANSPORT_HTTP = "HTTP";
public final static String TRANSPORT_TCHANNEL = "TCHANNEL";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.uber.jaeger.crossdock;

import java.net.URI;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

import com.uber.jaeger.context.TraceContext;
import com.uber.jaeger.crossdock.resources.behavior.ExceptionMapper;
import com.uber.jaeger.crossdock.resources.behavior.http.TraceBehaviorResource;
import com.uber.jaeger.crossdock.resources.behavior.tchannel.TChannelServer;
import com.uber.jaeger.crossdock.resources.health.HealthResource;
import com.uber.jaeger.Configuration.ReporterConfiguration;
import com.uber.jaeger.Configuration.SamplerConfiguration;
import com.uber.jaeger.filters.jaxrs2.Configuration;
import com.uber.jaeger.filters.jaxrs2.TracingUtils;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;

public class JerseyServer {
private final HttpServer server;
public static Client client;
public final static String SERVICE_NAME = "java";


public JerseyServer(String hostPort, Class... resourceClasses) {
final String samplingType = SamplerConfiguration.CONST;
final Number samplingParam = 0;
final boolean disable = false;
final boolean logging = true;

final Configuration config = new Configuration(SERVICE_NAME, disable,
new SamplerConfiguration(samplingType, samplingParam),
new ReporterConfiguration(logging, null, null, null, null));

// create a resource config that scans for JAX-RS resources and providers
final ResourceConfig rc = new ResourceConfig();

for (Class clz : resourceClasses) {
rc.packages(clz.getPackage().getName());
}

rc.register(TracingUtils.serverFilter(config))
.register(LoggingFilter.class)
.register(ExceptionMapper.class)
.register(JacksonFeature.class)
.register(
new AbstractBinder() {
@Override
protected void configure() {
bind(config).to(Configuration.class);
}
});

// create and start a new instance of grizzly http server
// exposing the Jersey application at BASE_URI
String baseURI = String.format("http://%s/", hostPort);
server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseURI), rc);
client = initializeClient(config);
}

private static Client initializeClient(final Configuration config) {
return ClientBuilder.newClient()
.register(ExceptionMapper.class)
.register(TracingUtils.clientFilter(config))
.register(
new AbstractBinder() {
@Override
protected void configure() {
bind(TracingUtils.getTraceContext()).to(TraceContext.class);
}
})
.register(JacksonFeature.class);
}

public void shutdown() {
server.shutdown();
}

public static void main(String[] args) throws Exception {
new JerseyServer("0.0.0.0:8081", TraceBehaviorResource.class);
new TChannelServer(8082).start();
new JerseyServer("0.0.0.0:8080", HealthResource.class);
}
}
Loading

0 comments on commit e309a7e

Please sign in to comment.