From commits-return-1049-archive-asf-public=cust-asf.ponee.io@zipkin.apache.org Fri May 10 02:11:15 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 [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 95BD2180649 for ; Fri, 10 May 2019 04:11:14 +0200 (CEST) Received: (qmail 43018 invoked by uid 500); 10 May 2019 02:11:11 -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 42999 invoked by uid 99); 10 May 2019 02:11:10 -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; Fri, 10 May 2019 02:11:10 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id BFD3D872E6; Fri, 10 May 2019 02:11:05 +0000 (UTC) Date: Fri, 10 May 2019 02:11:06 +0000 To: "commits@zipkin.apache.org" Subject: [incubator-zipkin] 01/01: Simplifies build by bundling Scribe (still disabled by default) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: adriancole@apache.org In-Reply-To: <155745426552.1695.6894899733165176034@gitbox.apache.org> References: <155745426552.1695.6894899733165176034@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-zipkin X-Git-Refname: refs/heads/bundle-scribe X-Git-Reftype: branch X-Git-Rev: f0a561a271922949439c299d695321cd56490c2a X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190510021105.BFD3D872E6@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. adriancole pushed a commit to branch bundle-scribe in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git commit f0a561a271922949439c299d695321cd56490c2a Author: Adrian Cole AuthorDate: Fri May 10 10:08:19 2019 +0800 Simplifies build by bundling Scribe (still disabled by default) We used to bundle scribe, but due to library conflicts, moved it optional. As Armeria natively supports thrift (incidentally armeria means sea thrift), we no longer have this problem. Bundling removes one of the most complex things from our project for sites that still use Scribe (most folks who use Finagle will). --- pom.xml | 2 - zipkin-autoconfigure/README.md | 4 - zipkin-autoconfigure/collector-scribe/README.md | 75 ----------------- zipkin-autoconfigure/collector-scribe/pom.xml | 82 ------------------ .../scribe/ZipkinScribeCollectorProperties.java | 46 ---------- .../src/main/resources/META-INF/spring.factories | 2 - .../src/main/resources/zipkin-server-scribe.yml | 6 -- ...ZipkinScribeCollectorAutoConfigurationTest.java | 98 ---------------------- zipkin-autoconfigure/pom.xml | 67 --------------- zipkin-server/README.md | 10 ++- zipkin-server/pom.xml | 8 ++ .../internal/InternalZipkinConfiguration.java | 2 + .../scribe/ZipkinScribeCollectorConfiguration.java | 24 ++++-- .../src/main/resources/zipkin-server-shared.yml | 4 + .../ZipkinKafkaCollectorPropertiesOverrideTest.kt | 7 +- ...ipkinRabbitMQCollectorPropertiesOverrideTest.kt | 7 +- .../ZipkinScribeCollectorConfigurationTest.kt | 66 +++++++++++++++ 17 files changed, 107 insertions(+), 403 deletions(-) diff --git a/pom.xml b/pom.xml index 856ac6a..612b16a 100755 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,6 @@ benchmarks zipkin-storage zipkin-collector - zipkin-autoconfigure zipkin-server @@ -106,7 +105,6 @@ 3.2.1 3.0.0-M3 3.0.0-M2 - 0.0.5 Zipkin (Parent) diff --git a/zipkin-autoconfigure/README.md b/zipkin-autoconfigure/README.md deleted file mode 100644 index 1d07f75..0000000 --- a/zipkin-autoconfigure/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# zipkin-autoconfigure - -Modules in this directory are considered internal details to Zipkin's -server and are unsupported unless integrated with our [server build](../zipkin-server). diff --git a/zipkin-autoconfigure/collector-scribe/README.md b/zipkin-autoconfigure/collector-scribe/README.md deleted file mode 100644 index 5cb0ba9..0000000 --- a/zipkin-autoconfigure/collector-scribe/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Scribe Collector Auto-configure Module - -This module provides support for running the legacy Scribe collector as -a component of Zipkin server. To activate this collector, reference the -module jar when running the Zipkin server set the `SCRIBE_ENABLED=true` -environment variable or property `zipkin.collector.scribe.enabled=true`. - -## Quick start - -JRE 8 is required to run Zipkin server. - -Fetch the latest released -[executable jar for Zipkin server](https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec) -and -[autoconfigure module jar for the scribe collector](https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-autoconfigure-collector-scribe&v=LATEST&c=module). -Run Zipkin server with the Scribe collector enabled. - -For example: - -```bash -$ curl -sSL https://zipkin.io/quickstart.sh | bash -s -$ curl -sSL https://zipkin.io/quickstart.sh | bash -s io.zipkin.java:zipkin-autoconfigure-collector-scribe:LATEST:module scribe.jar -$ SCRIBE_ENABLED=true \ - java \ - -Dloader.path='scribe.jar,scribe.jar!/lib' \ - -Dspring.profiles.active=scribe \ - -cp zipkin.jar \ - org.springframework.boot.loader.PropertiesLauncher -``` - -After executing these steps, the Zipkin UI will be available -[http://localhost:9411](http://localhost:9411) or port 9411 of the remote -host the Zipkin server was started on. Scribe will be listening on port -9410. - -The Zipkin server can be further configured as described in the -[Zipkin server documentation](../../zipkin-server/README.md). - -## How this works - -The Zipkin server executable jar and the autoconfigure module jar for the -scribe collector are required. The module jar contains the code for -loading and configuring the scribe collector, and any dependencies that -are not already packaged in the Zipkin server jar. - -Using PropertiesLauncher as the main class runs the Zipkin server -executable jar the same as it would be if executed using `java -jar zipkin.jar`, -except it provides the option to load resources from outside the -executable jar into the classpath. Those external resources are specified -using the `loader.path` system property. In this case, it is configured -to load the scribe collector module jar (`zipkin-autoconfigure-collector-scribe-module.jar`) -and the jar files contained in the `lib/` directory within that module -jar (`zipkin-autoconfigure-collector-scribe-module.jar!/lib`). - -The `spring.profiles=scribe` system property causes configuration from -[zipkin-server-scribe.yml](src/main/resources/zipkin-server-scribe.yml) -to be loaded. - -For more information on how this works, see [Spring Boot's documentation on the executable jar -format](https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html). The -[section on PropertiesLauncher](https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-property-launcher-features) -has more detail on how the external module jar and the libraries it contains are loaded. - -## Configuration - -The following configuration points apply apply when `SCRIBE_ENABLED=true` -environment variable or the property `zipkin.collector.scribe.enabled=true`. -They can be configured by setting an environment variable or by setting -a java system property using the `-Dproperty.name=value` command line -argument. - -Environment Variable | Property |Description ---- | --- | --- | --- -`COLLECTOR_PORT` | `zipkin.collector.scribe.port` | The port to listen for thrift RPC scribe requests. Defaults to 9410 -`SCRIBE_CATEGORY` | `zipkin.collector.scribe.category` | Category zipkin spans will be consumed from. Defaults to `zipkin` diff --git a/zipkin-autoconfigure/collector-scribe/pom.xml b/zipkin-autoconfigure/collector-scribe/pom.xml deleted file mode 100644 index 9fa4967..0000000 --- a/zipkin-autoconfigure/collector-scribe/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - 4.0.0 - - - org.apache.zipkin - zipkin-autoconfigure-parent - 2.13.1-SNAPSHOT - - - zipkin-autoconfigure-collector-scribe - Auto Configuration: Scribe Collector - - - ${project.basedir}/../.. - - - - - ${project.groupId}.zipkin2 - zipkin-collector-scribe - ${project.version} - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - zipkin - - module - - - ${project.groupId}.zipkin2 - zipkin-collector-scribe - - - com.linecorp.armeria - armeria-thrift - - - org.apache.thrift - libthrift - - - - - - org.apache.zipkin.layout - zipkin-layout-factory - ${zipkin-layout-factory.version} - - - - - - diff --git a/zipkin-autoconfigure/collector-scribe/src/main/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorProperties.java b/zipkin-autoconfigure/collector-scribe/src/main/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorProperties.java deleted file mode 100644 index 55da895..0000000 --- a/zipkin-autoconfigure/collector-scribe/src/main/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorProperties.java +++ /dev/null @@ -1,46 +0,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. - */ -package zipkin2.autoconfigure.collector.scribe; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import zipkin2.collector.scribe.ScribeCollector; - -@ConfigurationProperties("zipkin.collector.scribe") -class ZipkinScribeCollectorProperties { - private String category = "zipkin"; - private int port = 9410; - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public ScribeCollector.Builder toBuilder() { - return ScribeCollector.newBuilder().category(category).port(port); - } -} diff --git a/zipkin-autoconfigure/collector-scribe/src/main/resources/META-INF/spring.factories b/zipkin-autoconfigure/collector-scribe/src/main/resources/META-INF/spring.factories deleted file mode 100644 index ab8a234..0000000 --- a/zipkin-autoconfigure/collector-scribe/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -zipkin2.autoconfigure.collector.scribe.ZipkinScribeCollectorAutoConfiguration diff --git a/zipkin-autoconfigure/collector-scribe/src/main/resources/zipkin-server-scribe.yml b/zipkin-autoconfigure/collector-scribe/src/main/resources/zipkin-server-scribe.yml deleted file mode 100644 index 0625cea..0000000 --- a/zipkin-autoconfigure/collector-scribe/src/main/resources/zipkin-server-scribe.yml +++ /dev/null @@ -1,6 +0,0 @@ -zipkin: - collector: - scribe: - enabled: ${SCRIBE_ENABLED:false} - category: ${SCRIBE_CATEGORY:zipkin} - port: ${COLLECTOR_PORT:9410} diff --git a/zipkin-autoconfigure/collector-scribe/src/test/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorAutoConfigurationTest.java b/zipkin-autoconfigure/collector-scribe/src/test/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorAutoConfigurationTest.java deleted file mode 100644 index c8994d2..0000000 --- a/zipkin-autoconfigure/collector-scribe/src/test/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorAutoConfigurationTest.java +++ /dev/null @@ -1,98 +0,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. - */ -package zipkin2.autoconfigure.collector.scribe; - -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import zipkin2.collector.CollectorMetrics; -import zipkin2.collector.CollectorSampler; -import zipkin2.collector.scribe.ScribeCollector; -import zipkin2.storage.InMemoryStorage; -import zipkin2.storage.StorageComponent; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ZipkinScribeCollectorAutoConfigurationTest { - - @Rule public ExpectedException thrown = ExpectedException.none(); - - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - - @After public void close() { - context.close(); - } - - @Test public void doesntProvidesCollectorComponent_byDefault() { - context.register( - PropertyPlaceholderAutoConfiguration.class, - ZipkinScribeCollectorAutoConfiguration.class, - InMemoryConfiguration.class); - context.refresh(); - - thrown.expect(NoSuchBeanDefinitionException.class); - context.getBean(ScribeCollector.class); - } - - /** Note: this will flake if you happen to be running a server on port 9410! */ - @Test public void providesCollectorComponent_whenEnabled() { - TestPropertyValues.of("zipkin.collector.scribe.enabled:true").applyTo(context); - context.register( - PropertyPlaceholderAutoConfiguration.class, - ZipkinScribeCollectorAutoConfiguration.class, - InMemoryConfiguration.class); - context.refresh(); - - assertThat(context.getBean(ScribeCollector.class)).isNotNull(); - } - - @Test public void canOverrideProperty_port() { - TestPropertyValues.of( - "zipkin.collector.scribe.enabled:true", - "zipkin.collector.scribe.port:9999") - .applyTo(context); - context.register( - PropertyPlaceholderAutoConfiguration.class, - ZipkinScribeCollectorAutoConfiguration.class, - InMemoryConfiguration.class); - context.refresh(); - - assertThat(context.getBean(ZipkinScribeCollectorProperties.class).getPort()).isEqualTo(9999); - } - - @Configuration - static class InMemoryConfiguration { - @Bean CollectorSampler sampler() { - return CollectorSampler.ALWAYS_SAMPLE; - } - - @Bean CollectorMetrics metrics() { - return CollectorMetrics.NOOP_METRICS; - } - - @Bean StorageComponent storage() { - return InMemoryStorage.newBuilder().build(); - } - } -} diff --git a/zipkin-autoconfigure/pom.xml b/zipkin-autoconfigure/pom.xml deleted file mode 100644 index 5cc3810..0000000 --- a/zipkin-autoconfigure/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - 4.0.0 - - - org.apache.zipkin - zipkin-parent - 2.13.1-SNAPSHOT - - - zipkin-autoconfigure-parent - Auto Configuration - pom - - - ${project.basedir}/.. - 1.8 - java18 - - - - collector-scribe - - - - - org.springframework.boot - spring-boot-autoconfigure - ${spring-boot.version} - - - org.springframework.boot - spring-boot-test - ${spring-boot.version} - test - - - - - - - maven-remote-resources-plugin - - false - - - - - diff --git a/zipkin-server/README.md b/zipkin-server/README.md index 7e64055..c4b38a1 100644 --- a/zipkin-server/README.md +++ b/zipkin-server/README.md @@ -283,8 +283,14 @@ Property | Environment Variable | Description `zipkin.collector.http.enabled` | `HTTP_COLLECTOR_ENABLED` | `false` disables the HTTP collector. Defaults to `true`. ### Scribe (Legacy) Collector -A collector supporting Scribe is available as an external module. See -[zipkin-autoconfigure/collector-scribe](../zipkin-autoconfigure/collector-scribe/). +A collector supporting Scribe is enabled when `SCRIBE_ENABLED=true`. New +sites are discouraged from using this collector as Scribe is an archived +technology. + +Environment Variable | Property |Description +--- | --- | --- | --- +`COLLECTOR_PORT` | `zipkin.collector.scribe.port` | The port to listen for thrift RPC scribe requests. Defaults to 9410 +`SCRIBE_CATEGORY` | `zipkin.collector.scribe.category` | Category zipkin spans will be consumed from. Defaults to `zipkin` ### Kafka Collector The Kafka collector is enabled when `KAFKA_BOOTSTRAP_SERVERS` is set to diff --git a/zipkin-server/pom.xml b/zipkin-server/pom.xml index f17dd89..d97b41c 100644 --- a/zipkin-server/pom.xml +++ b/zipkin-server/pom.xml @@ -243,6 +243,14 @@ true + + + ${project.groupId}.zipkin2 + zipkin-collector-scribe + ${project.version} + true + + io.micrometer diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/InternalZipkinConfiguration.java b/zipkin-server/src/main/java/zipkin2/server/internal/InternalZipkinConfiguration.java index e275ab9..ae7e867 100644 --- a/zipkin-server/src/main/java/zipkin2/server/internal/InternalZipkinConfiguration.java +++ b/zipkin-server/src/main/java/zipkin2/server/internal/InternalZipkinConfiguration.java @@ -26,6 +26,7 @@ import zipkin2.server.internal.kafka.ZipkinKafkaCollectorConfiguration; import zipkin2.server.internal.mysql.ZipkinMySQLStorageConfiguration; import zipkin2.server.internal.prometheus.ZipkinPrometheusMetricsConfiguration; import zipkin2.server.internal.rabbitmq.ZipkinRabbitMQCollectorConfiguration; +import zipkin2.server.internal.scribe.ZipkinScribeCollectorConfiguration; import zipkin2.server.internal.ui.ZipkinUiConfiguration; @Configuration @@ -36,6 +37,7 @@ import zipkin2.server.internal.ui.ZipkinUiConfiguration; ZipkinCassandra3StorageConfiguration.class, ZipkinElasticsearchStorageAutoConfiguration.class, ZipkinMySQLStorageConfiguration.class, + ZipkinScribeCollectorConfiguration.class, TracingConfiguration.class, ZipkinQueryApiV2.class, ZipkinHttpCollector.class, diff --git a/zipkin-autoconfigure/collector-scribe/src/main/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorAutoConfiguration.java b/zipkin-server/src/main/java/zipkin2/server/internal/scribe/ZipkinScribeCollectorConfiguration.java similarity index 75% rename from zipkin-autoconfigure/collector-scribe/src/main/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorAutoConfiguration.java rename to zipkin-server/src/main/java/zipkin2/server/internal/scribe/ZipkinScribeCollectorConfiguration.java index ca08af1..53b1789 100644 --- a/zipkin-autoconfigure/collector-scribe/src/main/java/zipkin2/autoconfigure/collector/scribe/ZipkinScribeCollectorAutoConfiguration.java +++ b/zipkin-server/src/main/java/zipkin2/server/internal/scribe/ZipkinScribeCollectorConfiguration.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package zipkin2.autoconfigure.collector.scribe; +package zipkin2.server.internal.scribe; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import zipkin2.collector.CollectorMetrics; @@ -31,16 +31,22 @@ import zipkin2.storage.StorageComponent; * asynchronously. */ @Configuration -@EnableConfigurationProperties(ZipkinScribeCollectorProperties.class) @ConditionalOnProperty(value = "zipkin.collector.scribe.enabled", havingValue = "true") -class ZipkinScribeCollectorAutoConfiguration { +public class ZipkinScribeCollectorConfiguration { /** The init method will block until the scribe port is listening, or crash on port conflict */ @Bean(initMethod = "start") ScribeCollector scribe( - ZipkinScribeCollectorProperties scribe, - CollectorSampler sampler, - CollectorMetrics metrics, - StorageComponent storage) { - return scribe.toBuilder().sampler(sampler).metrics(metrics).storage(storage).build(); + @Value("${zipkin.collector.scribe.category:zipkin}") String category, + @Value("${zipkin.collector.scribe.port:9410}") int port, + CollectorSampler sampler, + CollectorMetrics metrics, + StorageComponent storage) { + return ScribeCollector.newBuilder() + .category(category) + .port(port) + .sampler(sampler) + .metrics(metrics) + .storage(storage) + .build(); } } diff --git a/zipkin-server/src/main/resources/zipkin-server-shared.yml b/zipkin-server/src/main/resources/zipkin-server-shared.yml index 72b0fe8..4655228 100644 --- a/zipkin-server/src/main/resources/zipkin-server-shared.yml +++ b/zipkin-server/src/main/resources/zipkin-server-shared.yml @@ -37,6 +37,10 @@ zipkin: virtual-host: ${RABBIT_VIRTUAL_HOST:/} useSsl: ${RABBIT_USE_SSL:false} uri: ${RABBIT_URI:} + scribe: + enabled: ${SCRIBE_ENABLED:false} + category: ${SCRIBE_CATEGORY:zipkin} + port: ${COLLECTOR_PORT:9410} query: enabled: ${QUERY_ENABLED:true} # 1 day in millis diff --git a/zipkin-server/src/test/kotlin/zipkin2/collector/kafka/ZipkinKafkaCollectorPropertiesOverrideTest.kt b/zipkin-server/src/test/kotlin/zipkin2/collector/kafka/ZipkinKafkaCollectorPropertiesOverrideTest.kt index 32d75b9..51298e3 100644 --- a/zipkin-server/src/test/kotlin/zipkin2/collector/kafka/ZipkinKafkaCollectorPropertiesOverrideTest.kt +++ b/zipkin-server/src/test/kotlin/zipkin2/collector/kafka/ZipkinKafkaCollectorPropertiesOverrideTest.kt @@ -54,11 +54,8 @@ class ZipkinKafkaCollectorPropertiesOverrideTest( ): Array = arrayOf(propertySuffix, value, builderExtractor) } - var context = AnnotationConfigApplicationContext() - - @After fun close() { - context.close() - } + val context = AnnotationConfigApplicationContext() + @After fun closeContext() = context.close() @Test fun propertyTransferredToCollectorBuilder() { TestPropertyValues.of("zipkin.collector.kafka.$property:$value").applyTo(context) diff --git a/zipkin-server/src/test/kotlin/zipkin2/collector/rabbitmq/ZipkinRabbitMQCollectorPropertiesOverrideTest.kt b/zipkin-server/src/test/kotlin/zipkin2/collector/rabbitmq/ZipkinRabbitMQCollectorPropertiesOverrideTest.kt index bce32c2..1f0be42 100644 --- a/zipkin-server/src/test/kotlin/zipkin2/collector/rabbitmq/ZipkinRabbitMQCollectorPropertiesOverrideTest.kt +++ b/zipkin-server/src/test/kotlin/zipkin2/collector/rabbitmq/ZipkinRabbitMQCollectorPropertiesOverrideTest.kt @@ -65,11 +65,8 @@ class ZipkinRabbitMQPropertiesOverrideTest( ): Array = arrayOf(propertySuffix, value, builderExtractor) } - var context = AnnotationConfigApplicationContext() - - @After fun close() { - context.close() - } + val context = AnnotationConfigApplicationContext() + @After fun closeContext() = context.close() @Test fun propertyTransferredToCollectorBuilder() { TestPropertyValues.of("zipkin.collector.rabbitmq.$property:$value").applyTo(context) diff --git a/zipkin-server/src/test/kotlin/zipkin2/collector/scribe/ZipkinScribeCollectorConfigurationTest.kt b/zipkin-server/src/test/kotlin/zipkin2/collector/scribe/ZipkinScribeCollectorConfigurationTest.kt new file mode 100644 index 0000000..f3d5d75 --- /dev/null +++ b/zipkin-server/src/test/kotlin/zipkin2/collector/scribe/ZipkinScribeCollectorConfigurationTest.kt @@ -0,0 +1,66 @@ +/* + * 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 zipkin2.collector.scribe + +import org.assertj.core.api.Assertions.assertThat +import org.junit.After +import org.junit.Test +import org.springframework.beans.factory.NoSuchBeanDefinitionException +import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration +import org.springframework.boot.test.util.TestPropertyValues +import org.springframework.context.annotation.AnnotationConfigApplicationContext +import zipkin2.server.internal.InMemoryCollectorConfiguration +import zipkin2.server.internal.scribe.ZipkinScribeCollectorConfiguration + +class ZipkinScribeCollectorConfigurationTest { + val context = AnnotationConfigApplicationContext() + @After fun closeContext() = context.close() + + @Test(expected = NoSuchBeanDefinitionException::class) + fun doesntProvidesCollectorComponent_byDefault() { + refreshContext() + + context.getBean(ScribeCollector::class.java) + } + + /** Note: this will flake if you happen to be running a server on port 9410! */ + @Test fun providesCollectorComponent_whenEnabled() { + TestPropertyValues.of("zipkin.collector.scribe.enabled:true").applyTo(context) + refreshContext() + + assertThat(context.getBean(ScribeCollector::class.java)).isNotNull() + } + + @Test fun canOverrideProperty_port() { + TestPropertyValues.of( + "zipkin.collector.scribe.enabled:true", + "zipkin.collector.scribe.port:9999") + .applyTo(context) + refreshContext() + + assertThat(context.getBean(ScribeCollector::class.java).server.port) + .isEqualTo(9999) + } + + fun refreshContext() { + context.register( + PropertyPlaceholderAutoConfiguration::class.java, + ZipkinScribeCollectorConfiguration::class.java, + InMemoryCollectorConfiguration::class.java) + context.refresh() + } +}