This is an automated email from the ASF dual-hosted git repository. abesto pushed a commit to branch dont-sign-snapshots in repository https://gitbox.apache.org/repos/asf/incubator-zipkin-brave-karaf.git
commit 0eb1b7a153086698595cface19429d2903fd4343 Author: Christian Schneider <[email protected]> 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 @@ <feature name="brave-sender-kafka"> <feature>brave</feature> <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.0_1</bundle> - <bundle>mvn:io.zipkin.reporter2/zipkin-sender-kafka11/${zipkin.reporter.version}</bundle> + <bundle>mvn:io.zipkin.reporter2/zipkin-sender-kafka11/${zipkin-reporter.version}</bundle> <bundle>mvn:io.zipkin.brave.karaf/brave-exporter-sender-kafka/${project.version}</bundle> </feature> - <feature name="brave-sender-okhttp`"> + <feature name="brave-sender-okhttp"> <feature>brave</feature> + <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okio/1.14.0_1</bundle> <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okhttp/3.10.0_2</bundle> - <bundle>mvn:io.zipkin.reporter2/zipkin-sender-okhttp3/${zipkin.reporter.version}</bundle> + <bundle>mvn:io.zipkin.reporter2/zipkin-sender-okhttp3/${zipkin-reporter.version}</bundle> <bundle>mvn:io.zipkin.brave.karaf/brave-exporter-sender-okhttp/${project.version}</bundle> </feature> </features> 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<Sender> ref = getSingleSender(FILTER_URLCONNECTION); Assert.assertEquals(10000, ref.getProperty("connectTimeout")); } @Test - public void checkSenderKafka() throws InvalidSyntaxException { + public void checkSenderKafka() { ServiceReference<Sender> ref = getSingleSender(FILTER_KAFKA); Assert.assertEquals("zipkin", ref.getProperty("topic")); } @Test - public void checkSenderOkHttp() throws InvalidSyntaxException { + public void checkSenderOkHttp() { ServiceReference<Sender> 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<Sender> getSingleSender(String filter) throws InvalidSyntaxException { - Collection<ServiceReference<Sender>> refs = context.getServiceReferences(Sender.class, filter); - Assert.assertEquals(1, refs.size()); - return refs.iterator().next(); + private ServiceReference<Sender> getSingleSender(String filter) { + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < TIMEOUT) { + try { + Collection<ServiceReference<Sender>> allRefs = context.getServiceReferences(Sender.class, null); + System.out.println(allRefs); + Collection<ServiceReference<Sender>> 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"); } }
