WIP on Zipkin V2 issue
diff --git a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/BasicZipkinTest.java b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/BasicZipkinTest.java
index fa367ce..14ce740 100644
--- a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/BasicZipkinTest.java
+++ b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/BasicZipkinTest.java
@@ -17,80 +17,87 @@
package org.apache.geronimo.microprofile.opentracing.tck.setup;
-import io.opentracing.tag.Tags;
-import org.eclipse.microprofile.config.spi.ConfigSource;
-import org.eclipse.microprofile.opentracing.tck.OpenTracingBaseTests;
-import org.eclipse.microprofile.opentracing.tck.OpenTracingSkipPatternTests;
-import org.eclipse.microprofile.opentracing.tck.application.WildcardClassService;
-import org.eclipse.microprofile.opentracing.tck.tracer.TestSpan;
-import org.eclipse.microprofile.opentracing.tck.tracer.TestSpanTree;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Rule;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.junit.Ignore;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
+import zipkin2.Span;
import zipkin2.junit.ZipkinRule;
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
-import java.util.Collections;
+import java.net.URL;
+import java.util.List;
+@Ignore
public class BasicZipkinTest extends Arquillian {
- @Rule
- private ZipkinRule zipkin = new ZipkinRule();
-
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
- .addClasses(SimpleService.class);
+ .addClasses(SimpleService.class)
+ .addAsWebInfResource(new ClassLoaderAsset("test-beans.xml"), "beans.xml")
+ .addAsServiceProvider(javax.enterprise.inject.spi.Extension.class, UseGeronimoTracerExtension.class);
}
+ private ZipkinRule zipkin;
+
+ @ArquillianResource
+ private URL serviceUrl;
+
+ @BeforeMethod
+ public void configure() {
+
+
+ }
+
+ @BeforeSuite
+ public void setup() {
+ zipkin = new ZipkinRule();
+ System.setProperty("geronimo.opentracing.span.converter.zipkin.sender", "http");
+ System.setProperty("geronimo.opentracing.span.converter.zipkin.http.collector", zipkin.httpUrl() + "/api/v2/spans");
+ System.setProperty("geronimo.opentracing.span.converter.zipkin.http.bulkSendInterval", "6000");
+ System.setProperty("geronimo.opentracing.span.converter.zipkin.http.maxSpansPerBulk", "1");
+ System.setProperty("geronimo.opentracing.span.converter.zipkin.http.maxSpansIteration","1");
+ System.setProperty("geronimo.opentracing.span.converter.zipkin.http.bufferSize","1");
+ }
+
+
/**
* Test that server endpoint is adding standard tags
*/
@Test
@RunAsClient
- private void testSimpleService() throws InterruptedException {
+ public void testSimpleService() throws Exception {
+ System.out.println(zipkin.httpUrl());
- zipkin.httpUrl()
+ Client client = ClientBuilder.newClient();
+ String url = serviceUrl.toExternalForm() + "hello";
+ WebTarget target = client.target(url);
+ Response response = target.request().get();
+ if (response.getStatus() != 200) {
+ String unexpectedResponse = response.readEntity(String.class);
+ Assert.fail("Expected HTTP response code 200 but received " + response.getStatus() + "; Response: " + unexpectedResponse);
+ }
- /*
+ Thread.sleep(10000);
- Response response = executeRemoteWebServiceRaw("wildcard/10/foo",
- "getFoo/ten", Response.Status.OK);
- response.close();
-
- TestSpanTree spans = executeRemoteWebServiceTracerTree();
-
- TestSpanTree expectedTree = new TestSpanTree(
- new TestSpanTree.TreeNode<>(
- new TestSpan(
- getOperationName(
- Tags.SPAN_KIND_SERVER,
- HttpMethod.GET,
- WildcardClassService.class,
- getEndpointMethod(WildcardClassService.class, WildcardClassService.REST_FOO_PATH)
- ),
- getExpectedSpanTags(
- Tags.SPAN_KIND_SERVER,
- HttpMethod.GET,
- "wildcard/10/foo",
- "getFoo/ten",
- null,
- Response.Status.OK.getStatusCode(),
- JAXRS_COMPONENT
- ),
- Collections.emptyList()
- )
- )
- );
- assertEqualTrees(spans, expectedTree);
-
- */
+ final List<List<Span>> traces = zipkin.getTraces();
+ Assert.assertTrue(traces.size() > 0, "Expected some traces");
}
diff --git a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/SimpleService.java b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/SimpleService.java
index 8d933e6..e0df2a0 100644
--- a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/SimpleService.java
+++ b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/SimpleService.java
@@ -2,12 +2,14 @@
import org.eclipse.microprofile.opentracing.Traced;
+import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Traced
+@RequestScoped
@Path("hello")
public class SimpleService {
diff --git a/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/UseGeronimoTracerExtension.java b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/UseGeronimoTracerExtension.java
new file mode 100644
index 0000000..1836018
--- /dev/null
+++ b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/UseGeronimoTracerExtension.java
@@ -0,0 +1,29 @@
+/*
+ * 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.geronimo.microprofile.opentracing.tck.setup;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+public class UseGeronimoTracerExtension implements Extension {
+
+ void vetoTckTracerIfScanned(@Observes final ProcessAnnotatedType<TckTracer> tckTracer) {
+ tckTracer.veto();
+ }
+
+}
diff --git a/geronimo-opentracing/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/geronimo-opentracing/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
index c34b326..5339e85 100644
--- a/geronimo-opentracing/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
+++ b/geronimo-opentracing/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -1 +1 @@
-org.apache.geronimo.microprofile.opentracing.tck.setup.SkipOpentracingApiSetup
+org.apache.geronimo.microprofile.opentracing.tck.setup.SkipOpentracingApiSetup
\ No newline at end of file
diff --git a/geronimo-opentracing/src/test/resources/test-beans.xml b/geronimo-opentracing/src/test/resources/test-beans.xml
new file mode 100644
index 0000000..f2297ba
--- /dev/null
+++ b/geronimo-opentracing/src/test/resources/test-beans.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://xmlns.jcp.org/xml/ns/javaee
+ http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
+ bean-discovery-mode="annotated"
+ version="2.0">
+ <trim/>
+</beans>