From commits-return-311-archive-asf-public=cust-asf.ponee.io@zipkin.apache.org Thu Jan 31 10:35:04 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 772BC18067E for ; Thu, 31 Jan 2019 11:35:03 +0100 (CET) Received: (qmail 31000 invoked by uid 500); 31 Jan 2019 10:34:54 -0000 Mailing-List: contact commits-help@zipkin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zipkin.apache.org Delivered-To: mailing list commits@zipkin.apache.org Received: (qmail 30931 invoked by uid 99); 31 Jan 2019 10:34:54 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Jan 2019 10:34:54 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 0696485783; Thu, 31 Jan 2019 10:34:53 +0000 (UTC) Date: Thu, 31 Jan 2019 10:35:20 +0000 To: "commits@zipkin.apache.org" Subject: [incubator-zipkin-brave-karaf] 28/43: Fix feature and test MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: abesto@apache.org In-Reply-To: <154893089235.20377.11323302279068900797@gitbox.apache.org> References: <154893089235.20377.11323302279068900797@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-zipkin-brave-karaf X-Git-Refname: refs/heads/jenkinsfile-tweaks X-Git-Reftype: branch X-Git-Rev: 0eb1b7a153086698595cface19429d2903fd4343 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190131103453.0696485783@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. abesto pushed a commit to branch jenkinsfile-tweaks in repository https://gitbox.apache.org/repos/asf/incubator-zipkin-brave-karaf.git commit 0eb1b7a153086698595cface19429d2903fd4343 Author: Christian Schneider AuthorDate: Wed Aug 1 14:44:51 2018 +0200 Fix feature and test --- features/src/main/resources/features.xml | 7 +-- .../java/io/zipkin/brave/itests/BraveTest.java | 55 ++++++++++++++-------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml index b8a827a..440a43a 100644 --- a/features/src/main/resources/features.xml +++ b/features/src/main/resources/features.xml @@ -31,14 +31,15 @@ brave mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.0_1 - mvn:io.zipkin.reporter2/zipkin-sender-kafka11/${zipkin.reporter.version} + mvn:io.zipkin.reporter2/zipkin-sender-kafka11/${zipkin-reporter.version} mvn:io.zipkin.brave.karaf/brave-exporter-sender-kafka/${project.version} - + brave + mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okio/1.14.0_1 mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okhttp/3.10.0_2 - mvn:io.zipkin.reporter2/zipkin-sender-okhttp3/${zipkin.reporter.version} + mvn:io.zipkin.reporter2/zipkin-sender-okhttp3/${zipkin-reporter.version} mvn:io.zipkin.brave.karaf/brave-exporter-sender-okhttp/${project.version} diff --git a/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java b/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java index 6552801..7b3f15c 100644 --- a/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java +++ b/itests/src/test/java/io/zipkin/brave/itests/BraveTest.java @@ -13,8 +13,18 @@ */ package io.zipkin.brave.itests; +import static org.ops4j.pax.exam.CoreOptions.maven; +import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; + import java.util.Collection; + import javax.inject.Inject; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,17 +37,9 @@ import org.ops4j.pax.exam.options.MavenUrlReference; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; -import zipkin2.reporter.Sender; -import static org.ops4j.pax.exam.CoreOptions.maven; -import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; +import zipkin2.reporter.Sender; @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) @@ -46,6 +48,7 @@ public class BraveTest { private static final String FILTER_OKHTTP = "(component.name=io.zipkin.sender.okhttp)"; private static final String FILTER_URLCONNECTION = "(component.name=io.zipkin.sender.urlconnection)"; + private static final long TIMEOUT = 10000; @Inject BundleContext context; @@ -53,7 +56,7 @@ public class BraveTest { @Configuration public static Option[] configuration() { MavenArtifactUrlReference karaf = maven().groupId("org.apache.karaf").artifactId("apache-karaf") - .type("zip").version("4.2.0"); + .type("zip").version("4.1.5"); MavenUrlReference brave = maven().groupId("io.zipkin.brave.karaf").artifactId("brave-features").type("xml") .classifier("features").version("0.1.0-SNAPSHOT"); @@ -62,7 +65,7 @@ public class BraveTest { configureConsole().ignoreLocalConsole(), logLevel(LogLevel.INFO), keepRuntimeFolder(), - features(brave, "brave", "brave-kafka", "brave-okhttp"), + features(brave, "brave", "brave-sender-kafka", "brave-sender-okhttp"), // Create an empty config to trigger creation of component newConfiguration("io.zipkin.sender.urlconnection").asOption(), newConfiguration("io.zipkin.sender.okhttp").asOption(), @@ -71,27 +74,39 @@ public class BraveTest { } @Test - public void checkSenderUrlConnection() throws InvalidSyntaxException { + public void checkSenderUrlConnection() { ServiceReference ref = getSingleSender(FILTER_URLCONNECTION); Assert.assertEquals(10000, ref.getProperty("connectTimeout")); } @Test - public void checkSenderKafka() throws InvalidSyntaxException { + public void checkSenderKafka() { ServiceReference ref = getSingleSender(FILTER_KAFKA); Assert.assertEquals("zipkin", ref.getProperty("topic")); } @Test - public void checkSenderOkHttp() throws InvalidSyntaxException { + public void checkSenderOkHttp() { ServiceReference ref = getSingleSender(FILTER_OKHTTP); - Assert.assertEquals("zipkin", ref.getProperty("topic")); + Assert.assertEquals("http://localhost:9411/api/v2/spans", ref.getProperty("endpoint")); } - @SuppressWarnings("rawtypes") - private ServiceReference getSingleSender(String filter) throws InvalidSyntaxException { - Collection> refs = context.getServiceReferences(Sender.class, filter); - Assert.assertEquals(1, refs.size()); - return refs.iterator().next(); + private ServiceReference getSingleSender(String filter) { + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < TIMEOUT) { + try { + Collection> allRefs = context.getServiceReferences(Sender.class, null); + System.out.println(allRefs); + Collection> refs = context.getServiceReferences(Sender.class, filter); + if (refs.size() >= 1) { + Assert.assertEquals(1, refs.size()); + return refs.iterator().next(); + } + Thread.sleep(100); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + throw new RuntimeException("Timeout finding service"); } }