From 65634fbb8900f9b4ec73f886e9e2fce459c4a178 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Mon, 29 Apr 2019 14:28:09 +0100 Subject: [PATCH] Start building new functional test to ensure posting to ZipKin works correctly --- geronimo-opentracing/pom.xml | 6 ++ .../tck/setup/BasicZipkinTest.java | 95 +++++++++++++++++++ .../opentracing/tck/setup/SimpleService.java | 21 ++++ 3 files changed, 122 insertions(+) create mode 100644 geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/BasicZipkinTest.java create mode 100644 geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/SimpleService.java diff --git a/geronimo-opentracing/pom.xml b/geronimo-opentracing/pom.xml index 07f501a..d123533 100644 --- a/geronimo-opentracing/pom.xml +++ b/geronimo-opentracing/pom.xml @@ -122,6 +122,12 @@ 1.2 test + + io.zipkin.zipkin2 + zipkin-junit + 2.12.9 + test + 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 new file mode 100644 index 0000000..88c3ef1 --- /dev/null +++ b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/BasicZipkinTest.java @@ -0,0 +1,95 @@ +/* + * 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 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.testng.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Rule; +import org.testng.annotations.Test; +import zipkin2.junit.ZipkinRule; + +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.Response; +import java.util.Collections; + +public class BasicZipkinTest extends Arquillian { + + @Rule + private ZipkinRule zipkin = new ZipkinRule(); + + @Deployment + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class) + .addClasses(SimpleService.class); + } + + /** + * Test that server endpoint is adding standard tags + */ + @Test + @RunAsClient + private void testWildcard() throws InterruptedException { + + + /* + + 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); + + */ + } + + +} 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 new file mode 100644 index 0000000..8d933e6 --- /dev/null +++ b/geronimo-opentracing/src/test/java/org/apache/geronimo/microprofile/opentracing/tck/setup/SimpleService.java @@ -0,0 +1,21 @@ +package org.apache.geronimo.microprofile.opentracing.tck.setup; + +import org.eclipse.microprofile.opentracing.Traced; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Traced +@Path("hello") +public class SimpleService { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String sayHello() throws Exception { + return "Hello, world!"; + } + + +}