diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index eca6eabb..3bb12b15 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -11,17 +11,22 @@ on: jobs: create_release: - runs-on: ubuntu-20.04 # newest available distribution, aka focal + runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: # Prevent use of implicit GitHub Actions read-only token GITHUB_TOKEN. We don't deploy on # the tag MAJOR.MINOR.PATCH event, but we still need to deploy the maven-release-plugin master commit. token: ${{ secrets.GH_TOKEN }} fetch-depth: 1 # only need the HEAD commit as license check isn't run + - name: Setup java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' # zulu as it supports a wide version range + java-version: '11' # earliest LTS and last that can compile the 1.6 release profile. - name: Cache local Maven repository - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6a9e4fec..1d7ba5f2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,20 +14,29 @@ on: jobs: deploy: - runs-on: ubuntu-20.04 # newest available distribution, aka focal + runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: - fetch-depth: 1 # only needed to get the sha label + # Prevent use of implicit GitHub Actions read-only token GITHUB_TOKEN. + # We push Javadocs to the gh-pages branch on commit. + token: ${{ secrets.GH_TOKEN }} + fetch-depth: 0 # allow build-bin/idl_to_gh_pages to get the full history + - name: Setup java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' # zulu as it supports a wide version range + java-version: '11' # earliest LTS and last that can compile the 1.6 release profile. - name: Cache local Maven repository - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-maven- - # We can't cache Docker without using buildx because GH actions restricts /var/lib/docker - # That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway. + # Don't attempt to cache Docker. Sensitive information can be stolen + # via forks, and login session ends up in ~/.docker. This is ok because + # we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner. - name: Deploy env: # GH_USER= @@ -51,7 +60,7 @@ jobs: # - referenced in .settings.xml SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} # DOCKERHUB_USER= - # - only push top-level projects: zipkin zipkin-aws zipkin-dependencies zipkin-aws to Docker Hub, only on release + # - only push top-level projects: zipkin zipkin-aws zipkin-dependencies zipkin-gcp to Docker Hub, only on release # - login like this: echo "$DOCKERHUB_TOKEN"| docker login -u "$DOCKERHUB_USER" --password-stdin DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} # DOCKERHUB_TOKEN= diff --git a/.github/workflows/docker_push.yml b/.github/workflows/docker_push.yml index 64a83bc5..14dd23c9 100644 --- a/.github/workflows/docker_push.yml +++ b/.github/workflows/docker_push.yml @@ -11,14 +11,15 @@ on: jobs: docker_push: - runs-on: ubuntu-20.04 # newest available distribution, aka focal + runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 # only needed to get the sha label - # We can't cache Docker without using buildx because GH actions restricts /var/lib/docker - # That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway. + # Don't attempt to cache Docker. Sensitive information can be stolen + # via forks, and login session ends up in ~/.docker. This is ok because + # we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner. - name: Docker Push run: | # GITHUB_REF will be refs/tags/docker-MAJOR.MINOR.PATCH build-bin/git/login_git && diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49040c10..472dad6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,21 +15,58 @@ on: paths-ignore: '**/*.md' jobs: + test-javadoc: + name: Test JavaDoc Builds + runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish + if: "!contains(github.event.head_commit.message, 'maven-release-plugin')" + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # full git history for license check + - name: Setup java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' # zulu as it supports a wide version range + java-version: '11' # earliest LTS and last that can compile the 1.6 release profile. + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-jdk-11-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-jdk-11-maven- + - name: Build JavaDoc + run: ./mvnw clean javadoc:aggregate -Prelease + test: - runs-on: ubuntu-20.04 # newest available distribution, aka focal + name: test (JDK ${{ matrix.java_version }}) + runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish if: "!contains(github.event.head_commit.message, 'maven-release-plugin')" + strategy: + fail-fast: false # don't fail fast as sometimes failures are operating system specific + matrix: # use latest available versions and be consistent on all workflows! + include: + - java_version: 11 # Last that can compile zipkin core to 1.6 for zipkin-reporter + maven_args: -Prelease -Dgpg.skip -Dmaven.javadoc.skip=true + - java_version: 21 # Most recent LTS steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + fetch-depth: 0 # full git history for license check + - name: Setup java + uses: actions/setup-java@v4 with: - fetch-depth: 0 # full git history for license check + distribution: 'zulu' # zulu as it supports a wide version range + java-version: ${{ matrix.java_version }} - name: Cache local Maven repository - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven- - # We can't cache Docker without using buildx because GH actions restricts /var/lib/docker - # That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway. + key: ${{ runner.os }}-jdk-${{ matrix.java_version }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-jdk-${{ matrix.java_version }}-maven- + # Don't attempt to cache Docker. Sensitive information can be stolen + # via forks, and login session ends up in ~/.docker. This is ok because + # we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner. - name: Test run: build-bin/configure_test && build-bin/test diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 2cc7d4a5..cb28b0e3 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 642d572c..346d645f 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,18 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +# 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. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/aws-junit/pom.xml b/aws-junit/pom.xml index e09f5057..79c49751 100644 --- a/aws-junit/pom.xml +++ b/aws-junit/pom.xml @@ -39,22 +39,21 @@ - com.amazonaws - aws-java-sdk-sqs - ${aws-java-sdk.version} + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} - junit - junit - ${junit.version} - compile + com.amazonaws + aws-java-sdk-sqs + ${aws-java-sdk.version} org.elasticmq elasticmq-server_2.13 - 1.0.0 + 1.5.4 ch.qos.logback @@ -63,19 +62,4 @@ - - - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - - - none - - - - - diff --git a/aws-junit/src/main/java/zipkin2/junit/aws/AmazonSQSRule.java b/aws-junit/src/main/java/zipkin2/junit/aws/AmazonSQSExtension.java similarity index 72% rename from aws-junit/src/main/java/zipkin2/junit/aws/AmazonSQSRule.java rename to aws-junit/src/main/java/zipkin2/junit/aws/AmazonSQSExtension.java index fadf7fc1..89f07664 100644 --- a/aws-junit/src/main/java/zipkin2/junit/aws/AmazonSQSRule.java +++ b/aws-junit/src/main/java/zipkin2/junit/aws/AmazonSQSExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2024 The OpenZipkin Authors * * Licensed 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 @@ -30,28 +30,28 @@ import org.elasticmq.StrictSQSLimits$; import org.elasticmq.rest.sqs.SQSRestServer; import org.elasticmq.rest.sqs.SQSRestServerBuilder; -import org.junit.rules.ExternalResource; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; import zipkin2.Span; import zipkin2.codec.SpanBytesDecoder; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Collections.singletonList; -public class AmazonSQSRule extends ExternalResource { +public class AmazonSQSExtension implements BeforeEachCallback, AfterEachCallback { SQSRestServer server; int serverPort; AmazonSQS client; String queueUrl; - public AmazonSQSRule() { + public AmazonSQSExtension() { } - // TODO: this shouldn't be called explicity. at some point, we should change this to jupiter and - // inject the queue URL as a parameter when used this way. - public AmazonSQSRule start() { + @Override public void beforeEach(ExtensionContext extensionContext) { if (server == null) { - server = SQSRestServerBuilder.withDynamicPort() - .withSQSLimits(StrictSQSLimits$.MODULE$).start(); + server = + SQSRestServerBuilder.withDynamicPort().withSQSLimits(StrictSQSLimits$.MODULE$).start(); serverPort = server.waitUntilStarted().localAddress().getPort(); } @@ -59,33 +59,34 @@ public AmazonSQSRule start() { client = AmazonSQSClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))) .withEndpointConfiguration( - new EndpointConfiguration(String.format("http://localhost:%d", serverPort), - null)) + new EndpointConfiguration(String.format("http://localhost:%d", serverPort), null)) .build(); queueUrl = client.createQueue("zipkin").getQueueUrl(); } - return this; - } - - public String queueUrl() { - return queueUrl; - } - - @Override protected void before() { + if (client != null && queueUrl != null) { client.purgeQueue(new PurgeQueueRequest(queueUrl)); } } - @Override protected void after() { - if (server != null) { + @Override public void afterEach(ExtensionContext extensionContext) { + if (client != null) { + client.shutdown(); + client = null; + } + + if (server == null) { server.stopAndWait(); + server = null; } } + public String queueUrl() { + return queueUrl; + } + public int queueCount() { - String count = client - .getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessages")) + String count = client.getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessages")) .getAttributes() .get("ApproximateNumberOfMessages"); @@ -93,10 +94,10 @@ public int queueCount() { } public int notVisibleCount() { - String count = client - .getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessagesNotVisible")) - .getAttributes() - .get("ApproximateNumberOfMessagesNotVisible"); + String count = + client.getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessagesNotVisible")) + .getAttributes() + .get("ApproximateNumberOfMessagesNotVisible"); return Integer.parseInt(count); } @@ -113,14 +114,13 @@ public List getSpans(boolean delete) { while (result != null && result.getMessages().size() > 0) { - spans = - Stream.concat(spans, result.getMessages().stream().flatMap(AmazonSQSRule::decodeSpans)); + spans = Stream.concat(spans, + result.getMessages().stream().flatMap(AmazonSQSExtension::decodeSpans)); result = client.receiveMessage(queueUrl); if (delete) { - List deletes = result - .getMessages() + List deletes = result.getMessages() .stream() .map(m -> new DeleteMessageRequest(queueUrl, m.getReceiptHandle())) .collect(Collectors.toList()); @@ -136,9 +136,8 @@ public void send(String body) { } static Stream decodeSpans(Message m) { - byte[] bytes = m.getBody().charAt(0) == '[' - ? m.getBody().getBytes(UTF_8) - : Base64.decode(m.getBody()); + byte[] bytes = + m.getBody().charAt(0) == '[' ? m.getBody().getBytes(UTF_8) : Base64.decode(m.getBody()); if (bytes[0] == '[') { return SpanBytesDecoder.JSON_V2.decodeList(bytes).stream(); } diff --git a/brave/instrumentation-aws-java-sdk-core/pom.xml b/brave/instrumentation-aws-java-sdk-core/pom.xml index d0ca5656..18371301 100644 --- a/brave/instrumentation-aws-java-sdk-core/pom.xml +++ b/brave/instrumentation-aws-java-sdk-core/pom.xml @@ -1,7 +1,7 @@ io.zipkin.zipkin2 - 2.23.16 - 2.16.3 - 2.4.1 - 2.12.0 + 2.25.2 + 2.17.1 + 2.7.18 + 2.16.0 com.linecorp.armeria - 1.3.0 + 1.26.4 - 4.1.54.Final + 4.1.100.Final io.zipkin.brave - 5.13.7 + 5.17.0 - 1.11.926 - 2.15.53 + 1.12.620 + 2.22.0 - 2.17.0 - 4.9.0 + 2.22.0 + 4.12.0 - 3.18.1 - 4.0.3 - 4.13.1 - 5.7.0 - 3.6.28 + 3.25.1 + 4.2.0 + 5.10.1 + 5.8.0 - 2.4.0 + 2.23.0 + 1.10.4 ${skipTests} - 1.19 + 1.23 1.2.8 - 4.0.rc2 - 3.8.1 + 4.3 + 3.11.0 - 3.1.2 - 3.0.0-M1 - 3.0.0-M3 + 3.6.1 + 3.1.1 + 3.4.1 - 3.2.0 - 3.0.0-M1 - 3.2.0 - 3.2.0 - 3.0.0-M1 - 3.2.4 - 3.2.1 - 3.0.0-M5 - 1.6.8 + 3.4.0 + 3.1.1 + 3.6.2 + 3.3.0 + 3.0.1 + 3.5.1 + 3.3.0 + 3.2.2 + 1.6.13 Zipkin Amazon Web Services (Parent) @@ -145,7 +145,7 @@ https://github.com/openzipkin/zipkin-aws scm:git:https://github.com/openzipkin/zipkin-aws.git scm:git:https://github.com/openzipkin/zipkin-aws.git - 0.23.4 + HEAD @@ -170,16 +170,23 @@ causing problems for end users difficult to unravel. --> - ${zipkin.groupId} - zipkin-tests - ${zipkin.version} + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} test - - junit - junit - ${junit.version} + ${zipkin.groupId} + zipkin-tests + ${zipkin.version} test @@ -227,16 +234,6 @@ - - - io.takari - maven - 0.7.7 - - 3.6.3 - - - de.qaware.maven @@ -331,14 +328,14 @@ ${maven-compiler-plugin.version} true - 1.8 - 1.8 + ${main.java.version} + ${main.java.version} true + 8 true - maven-surefire-plugin ${maven-surefire-plugin.version} @@ -352,6 +349,15 @@ + + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + + @@ -418,7 +424,9 @@ - [11,16) + + [11,12),[17,18),[21,22) @@ -518,14 +526,23 @@ - error-prone + error-prone-11+ - true + + [11,12),[17,18),[21,22) maven-compiler-plugin + ${maven-compiler-plugin.version} + true + + ${main.java.version} + ${main.java.version} + true + true + @@ -539,6 +556,17 @@ -XDcompilePolicy=simple -Xplugin:ErrorProne ${errorprone.args} + + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED @@ -546,6 +574,13 @@ error_prone_core ${errorprone.version} + + + com.google.auto.value + auto-value + ${auto-value.version} + @@ -566,9 +601,10 @@ ossrh https://oss.sonatype.org/ - - 10 + + 20 + 30 true @@ -576,7 +612,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.1.0 sign-artifacts diff --git a/reporter/reporter-xray-udp/src/test/java/zipkin2/reporter/xray_udp/XRayUDPReporterTest.java b/reporter/reporter-xray-udp/src/test/java/zipkin2/reporter/xray_udp/XRayUDPReporterTest.java index 7f0f48c3..1ed6165e 100644 --- a/reporter/reporter-xray-udp/src/test/java/zipkin2/reporter/xray_udp/XRayUDPReporterTest.java +++ b/reporter/reporter-xray-udp/src/test/java/zipkin2/reporter/xray_udp/XRayUDPReporterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2023 The OpenZipkin Authors * * Licensed 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 @@ -26,17 +26,17 @@ import java.net.InetSocketAddress; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import zipkin2.Span; import zipkin2.TestObjects; import zipkin2.storage.xray_udp.InternalStorageAccess; import static org.assertj.core.api.Assertions.assertThat; -public class XRayUDPReporterTest { +class XRayUDPReporterTest { private static EventLoopGroup workerGroup; private static Channel serverChannel; @@ -44,7 +44,7 @@ public class XRayUDPReporterTest { private static XRayUDPReporter reporter; - @BeforeClass + @BeforeAll public static void startServer() { workerGroup = new NioEventLoopGroup(); receivedPayloads = new LinkedBlockingQueue<>(); @@ -70,20 +70,18 @@ public static void startServer() { .create("localhost:" + ((InetSocketAddress) serverChannel.localAddress()).getPort()); } - @AfterClass + @AfterAll public static void stopServer() { reporter.close(); serverChannel.close().syncUninterruptibly(); workerGroup.shutdownGracefully(); } - @Before - public void setUp() { + @BeforeEach void setUp() { receivedPayloads.clear(); } - @Test - public void sendSingleSpan() throws Exception { + @Test void sendSingleSpan() throws Exception { reporter.report(TestObjects.CLIENT_SPAN); Span spanWithSdk = TestObjects.CLIENT_SPAN.toBuilder() .putTag("aws.xray.sdk", "Zipkin Brave") diff --git a/reporter/sender-awssdk-sqs/src/main/java/zipkin2/reporter/awssdk/sqs/AbstractSender.java b/reporter/sender-awssdk-sqs/src/main/java/zipkin2/reporter/awssdk/sqs/AbstractSender.java index 17b06b34..e57907a9 100644 --- a/reporter/sender-awssdk-sqs/src/main/java/zipkin2/reporter/awssdk/sqs/AbstractSender.java +++ b/reporter/sender-awssdk-sqs/src/main/java/zipkin2/reporter/awssdk/sqs/AbstractSender.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2024 The OpenZipkin Authors * * Licensed 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 @@ -63,7 +63,7 @@ abstract class AbstractSender extends Sender { boolean isAscii(byte[] encodedSpans) { for (int i = 0; i < encodedSpans.length; i++) { - if (encodedSpans[i] >= 0x80) { + if (Byte.toUnsignedInt(encodedSpans[i]) >= 0x80) { return false; } } diff --git a/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSAsyncSenderTest.java b/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSAsyncSenderTest.java index 6ae3b1bb..61bd23f2 100644 --- a/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSAsyncSenderTest.java +++ b/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSAsyncSenderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2024 The OpenZipkin Authors * * Licensed 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 @@ -18,8 +18,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; @@ -31,46 +33,47 @@ import zipkin2.Span; import zipkin2.codec.Encoding; import zipkin2.codec.SpanBytesEncoder; -import zipkin2.junit.aws.AmazonSQSRule; +import zipkin2.junit.aws.AmazonSQSExtension; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static zipkin2.TestObjects.CLIENT_SPAN; -public class SQSAsyncSenderTest { - @Rule public AmazonSQSRule sqsRule = new AmazonSQSRule().start(); +class SQSAsyncSenderTest { + @RegisterExtension AmazonSQSExtension sqs = new AmazonSQSExtension(); + + private SqsClient sqsClient; + private SQSSender sender; - SqsClient sqsClient = SqsClient.builder() + @BeforeEach public void setup() { + sqsClient = SqsClient.builder() .httpClient(UrlConnectionHttpClient.create()) .region(Region.US_EAST_1) - .endpointOverride(URI.create(sqsRule.queueUrl())) + .endpointOverride(URI.create(sqs.queueUrl())) .credentialsProvider( StaticCredentialsProvider.create(AwsBasicCredentials.create("x", "x"))) .build(); - SQSSender sender = - SQSSender.newBuilder() - .queueUrl(sqsRule.queueUrl()) - .sqsClient(sqsClient) - .build(); + sender = SQSSender.newBuilder() + .queueUrl(sqs.queueUrl()) + .sqsClient(sqsClient) + .build(); + } - @Test - public void sendsSpans() throws Exception { + @Test void sendsSpans() throws Exception { send(CLIENT_SPAN, CLIENT_SPAN).execute(); assertThat(readSpans()).containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void sendsSpans_json_unicode() throws Exception { + @Test void sendsSpans_json_unicode() throws Exception { Span unicode = CLIENT_SPAN.toBuilder().putTag("error", "\uD83D\uDCA9").build(); send(unicode).execute(); assertThat(readSpans()).containsExactly(unicode); } - @Test - public void sendsSpans_PROTO3() throws Exception { + @Test void sendsSpans_PROTO3() throws Exception { sender.close(); sender = sender.toBuilder().encoding(Encoding.PROTO3).build(); @@ -79,8 +82,7 @@ public void sendsSpans_PROTO3() throws Exception { assertThat(readSpans()).containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void outOfBandCancel() throws Exception { + @Test void outOfBandCancel() throws Exception { SQSSender.SQSCall call = (SQSSender.SQSCall) send(CLIENT_SPAN, CLIENT_SPAN); assertThat(call.isCanceled()).isFalse(); // sanity check @@ -103,8 +105,7 @@ public void onError(Throwable throwable) { assertThat(call.isCanceled()).isTrue(); } - @Test - public void checkOk() { + @Test void checkOk() { assertThat(sender.check()).isEqualTo(CheckResult.OK); } @@ -115,7 +116,7 @@ Call send(Span... spans) { } List readSpans() { - assertThat(sqsRule.queueCount()).isEqualTo(1); - return sqsRule.getSpans(); + assertThat(sqs.queueCount()).isEqualTo(1); + return sqs.getSpans(); } } diff --git a/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSSenderTest.java b/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSSenderTest.java index 10f11d29..d0d63be4 100644 --- a/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSSenderTest.java +++ b/reporter/sender-awssdk-sqs/src/test/java/zipkin2/reporter/awssdk/sqs/SQSSenderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2024 The OpenZipkin Authors * * Licensed 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 @@ -18,8 +18,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient; @@ -31,45 +33,47 @@ import zipkin2.Span; import zipkin2.codec.Encoding; import zipkin2.codec.SpanBytesEncoder; -import zipkin2.junit.aws.AmazonSQSRule; +import zipkin2.junit.aws.AmazonSQSExtension; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static zipkin2.TestObjects.CLIENT_SPAN; -public class SQSSenderTest { - @Rule public AmazonSQSRule sqsRule = new AmazonSQSRule().start(); +class SQSSenderTest { + @RegisterExtension AmazonSQSExtension sqs = new AmazonSQSExtension(); + + private SqsClient sqsClient; + private SQSSender sender; - SqsClient sqsClient = SqsClient.builder() + @BeforeEach public void setup() { + sqsClient = SqsClient.builder() .httpClient(UrlConnectionHttpClient.create()) .region(Region.US_EAST_1) - .endpointOverride(URI.create(sqsRule.queueUrl())) + .endpointOverride(URI.create(sqs.queueUrl())) .credentialsProvider( StaticCredentialsProvider.create(AwsBasicCredentials.create("x", "x"))) .build(); - SQSSender sender = SQSSender.newBuilder() - .queueUrl(sqsRule.queueUrl()) + sender = SQSSender.newBuilder() + .queueUrl(sqs.queueUrl()) .sqsClient(sqsClient) .build(); + } - @Test - public void sendsSpans() throws Exception { + @Test void sendsSpans() throws Exception { send(CLIENT_SPAN, CLIENT_SPAN).execute(); assertThat(readSpans()).containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void sendsSpans_json_unicode() throws Exception { + @Test void sendsSpans_json_unicode() throws Exception { Span unicode = CLIENT_SPAN.toBuilder().putTag("error", "\uD83D\uDCA9").build(); send(unicode).execute(); assertThat(readSpans()).containsExactly(unicode); } - @Test - public void sendsSpans_PROTO3() throws Exception { + @Test void sendsSpans_PROTO3() throws Exception { sender.close(); sender = sender.toBuilder().encoding(Encoding.PROTO3).build(); @@ -78,8 +82,7 @@ public void sendsSpans_PROTO3() throws Exception { assertThat(readSpans()).containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void outOfBandCancel() throws Exception { + @Test void outOfBandCancel() throws Exception { SQSSender.SQSCall call = (SQSSender.SQSCall) send(CLIENT_SPAN, CLIENT_SPAN); assertThat(call.isCanceled()).isFalse(); // sanity check @@ -102,8 +105,7 @@ public void onError(Throwable throwable) { assertThat(call.isCanceled()).isTrue(); } - @Test - public void checkOk() { + @Test void checkOk() { assertThat(sender.check()).isEqualTo(CheckResult.OK); } @@ -114,7 +116,7 @@ Call send(Span... spans) { } List readSpans() { - assertThat(sqsRule.queueCount()).isEqualTo(1); - return sqsRule.getSpans(); + assertThat(sqs.queueCount()).isEqualTo(1); + return sqs.getSpans(); } } diff --git a/reporter/sender-kinesis/src/test/java/zipkin2/reporter/kinesis/KinesisSenderTest.java b/reporter/sender-kinesis/src/test/java/zipkin2/reporter/kinesis/KinesisSenderTest.java index 6c1bf3c6..f7787525 100644 --- a/reporter/sender-kinesis/src/test/java/zipkin2/reporter/kinesis/KinesisSenderTest.java +++ b/reporter/sender-kinesis/src/test/java/zipkin2/reporter/kinesis/KinesisSenderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2023 The OpenZipkin Authors * * Licensed 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 @@ -30,9 +30,9 @@ import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.SocketPolicy; import okio.Buffer; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import zipkin2.Call; import zipkin2.Callback; import zipkin2.CheckResult; @@ -45,15 +45,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static zipkin2.TestObjects.CLIENT_SPAN; -public class KinesisSenderTest { - @Rule public MockWebServer server = new MockWebServer(); +class KinesisSenderTest { + public MockWebServer server = new MockWebServer(); // Kinesis sends data in CBOR format ObjectMapper mapper = new ObjectMapper(new CBORFactory()); KinesisSender sender; - @Before - public void setup() { + @BeforeEach void setup() { sender = KinesisSender.newBuilder() .streamName("test") @@ -63,8 +62,7 @@ public void setup() { .build(); } - @Test - public void sendsSpans() throws Exception { + @Test void sendsSpans() throws Exception { server.enqueue(new MockResponse()); send(CLIENT_SPAN, CLIENT_SPAN).execute(); @@ -73,8 +71,7 @@ public void sendsSpans() throws Exception { .containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void sendsSpans_PROTO3() throws Exception { + @Test void sendsSpans_PROTO3() throws Exception { server.enqueue(new MockResponse()); sender.close(); @@ -86,8 +83,7 @@ public void sendsSpans_PROTO3() throws Exception { .containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void outOfBandCancel() throws Exception { + @Test void outOfBandCancel() throws Exception { server.enqueue(new MockResponse()); KinesisSender.KinesisCall call = (KinesisSender.KinesisCall) send(CLIENT_SPAN, CLIENT_SPAN); @@ -112,8 +108,7 @@ public void onError(Throwable throwable) { assertThat(call.isCanceled()).isTrue(); } - @Test - public void sendsSpans_json_unicode() throws Exception { + @Test void sendsSpans_json_unicode() throws Exception { server.enqueue(new MockResponse()); Span unicode = CLIENT_SPAN.toBuilder().putTag("error", "\uD83D\uDCA9").build(); @@ -122,8 +117,7 @@ public void sendsSpans_json_unicode() throws Exception { assertThat(extractSpans(server.takeRequest().getBody())).containsExactly(unicode); } - @Test - public void checkPasses() throws Exception { + @Test void checkPasses() throws Exception { enqueueCborResponse( mapper .createObjectNode() @@ -133,8 +127,7 @@ public void checkPasses() throws Exception { assertThat(result.ok()).isTrue(); } - @Test - public void checkFailsWithStreamNotActive() throws Exception { + @Test void checkFailsWithStreamNotActive() throws Exception { enqueueCborResponse( mapper .createObjectNode() @@ -145,8 +138,7 @@ public void checkFailsWithStreamNotActive() throws Exception { assertThat(result.error()).isInstanceOf(IllegalStateException.class); } - @Test - public void checkFailsWithException() { + @Test void checkFailsWithException() { server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_DURING_REQUEST_BODY)); // 3 retries after initial failure server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_DURING_REQUEST_BODY)); @@ -178,4 +170,8 @@ Call send(zipkin2.Span... spans) { sender.encoding() == Encoding.JSON ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3; return sender.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList())); } + + @AfterEach void afterEachTest() throws IOException { + server.close(); + } } diff --git a/reporter/sender-sqs/src/main/java/zipkin2/reporter/sqs/SQSSender.java b/reporter/sender-sqs/src/main/java/zipkin2/reporter/sqs/SQSSender.java index 518817bc..e29c08ff 100644 --- a/reporter/sender-sqs/src/main/java/zipkin2/reporter/sqs/SQSSender.java +++ b/reporter/sender-sqs/src/main/java/zipkin2/reporter/sqs/SQSSender.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2024 The OpenZipkin Authors * * Licensed 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 @@ -198,7 +198,7 @@ public Call sendSpans(List list) { static boolean isAscii(byte[] encodedSpans) { for (int i = 0; i < encodedSpans.length; i++) { - if (encodedSpans[i] >= 0x80) { + if (Byte.toUnsignedInt(encodedSpans[i]) >= 0x80) { return false; } } diff --git a/reporter/sender-sqs/src/test/java/zipkin2/reporter/sqs/SQSSenderTest.java b/reporter/sender-sqs/src/test/java/zipkin2/reporter/sqs/SQSSenderTest.java index 3e7df416..ddbff52b 100644 --- a/reporter/sender-sqs/src/test/java/zipkin2/reporter/sqs/SQSSenderTest.java +++ b/reporter/sender-sqs/src/test/java/zipkin2/reporter/sqs/SQSSenderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2024 The OpenZipkin Authors * * Licensed 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 @@ -20,48 +20,50 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import org.junit.Rule; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import zipkin2.Call; import zipkin2.Callback; import zipkin2.CheckResult; import zipkin2.Span; import zipkin2.codec.Encoding; import zipkin2.codec.SpanBytesEncoder; -import zipkin2.junit.aws.AmazonSQSRule; +import zipkin2.junit.aws.AmazonSQSExtension; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static zipkin2.TestObjects.CLIENT_SPAN; -public class SQSSenderTest { +class SQSSenderTest { + @RegisterExtension AmazonSQSExtension sqs = new AmazonSQSExtension(); - @Rule public AmazonSQSRule sqsRule = new AmazonSQSRule().start(); + private SQSSender sender; - SQSSender sender = + @BeforeEach public void setup() { + sender = SQSSender.newBuilder() - .queueUrl(sqsRule.queueUrl()) - .endpointConfiguration(new EndpointConfiguration(sqsRule.queueUrl(), "us-east-1")) + .queueUrl(sqs.queueUrl()) + .endpointConfiguration(new EndpointConfiguration(sqs.queueUrl(), "us-east-1")) .credentialsProvider(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))) .build(); + } - @Test - public void sendsSpans() throws Exception { + @Test void sendsSpans() throws Exception { send(CLIENT_SPAN, CLIENT_SPAN).execute(); assertThat(readSpans()).containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void sendsSpans_json_unicode() throws Exception { + @Test void sendsSpans_json_unicode() throws Exception { Span unicode = CLIENT_SPAN.toBuilder().putTag("error", "\uD83D\uDCA9").build(); send(unicode).execute(); assertThat(readSpans()).containsExactly(unicode); } - @Test - public void sendsSpans_PROTO3() throws Exception { + @Test void sendsSpans_PROTO3() throws Exception { sender.close(); sender = sender.toBuilder().encoding(Encoding.PROTO3).build(); @@ -70,8 +72,7 @@ public void sendsSpans_PROTO3() throws Exception { assertThat(readSpans()).containsExactly(CLIENT_SPAN, CLIENT_SPAN); } - @Test - public void outOfBandCancel() throws Exception { + @Test void outOfBandCancel() throws Exception { SQSSender.SQSCall call = (SQSSender.SQSCall) send(CLIENT_SPAN, CLIENT_SPAN); assertThat(call.isCanceled()).isFalse(); // sanity check @@ -94,8 +95,7 @@ public void onError(Throwable throwable) { assertThat(call.isCanceled()).isTrue(); } - @Test - public void checkOk() { + @Test void checkOk() { assertThat(sender.check()).isEqualTo(CheckResult.OK); } @@ -106,7 +106,7 @@ Call send(Span... spans) { } List readSpans() { - assertThat(sqsRule.queueCount()).isEqualTo(1); - return sqsRule.getSpans(); + assertThat(sqs.queueCount()).isEqualTo(1); + return sqs.getSpans(); } } diff --git a/storage/xray-udp/pom.xml b/storage/xray-udp/pom.xml index 774dad57..5b70e154 100644 --- a/storage/xray-udp/pom.xml +++ b/storage/xray-udp/pom.xml @@ -39,12 +39,12 @@ com.squareup.moshi moshi - 1.11.0 + 1.15.0 com.jayway.jsonpath json-path - 2.4.0 + 2.8.0 test diff --git a/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/UDPMessageEncoderTest.java b/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/UDPMessageEncoderTest.java index a44dcd18..21ff26f0 100644 --- a/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/UDPMessageEncoderTest.java +++ b/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/UDPMessageEncoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2023 The OpenZipkin Authors * * Licensed 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 @@ -18,14 +18,14 @@ import java.io.IOException; import java.util.Map; import okio.Buffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import zipkin2.Endpoint; import zipkin2.Span; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.MapEntry.entry; -public class UDPMessageEncoderTest { +class UDPMessageEncoderTest { Span serverSpan = Span.newBuilder() .traceId("1234567890abcdef1234567890abcdef") @@ -34,8 +34,7 @@ public class UDPMessageEncoderTest { .name("test-cemo") .build(); - @Test - public void writeJson_server_isSegment() throws Exception { + @Test void writeJson_server_isSegment() throws Exception { Span span = serverSpan; assertThat(writeJson(span)) @@ -43,8 +42,7 @@ public void writeJson_server_isSegment() throws Exception { "{\"trace_id\":\"1-12345678-90abcdef1234567890abcdef\",\"id\":\"1234567890abcdef\",\"aws\":{\"xray\":{\"sdk\":\"Zipkin\"}}}"); } - @Test - public void writeJson_origin_no_default() throws Exception { + @Test void writeJson_origin_no_default() throws Exception { Span span = serverSpan .toBuilder() @@ -54,8 +52,7 @@ public void writeJson_origin_no_default() throws Exception { assertThat(readString(json, "origin")).isNull(); } - @Test - public void writeJson_origin_custom() throws Exception { + @Test void writeJson_origin_custom() throws Exception { Span span = serverSpan .toBuilder() @@ -67,8 +64,7 @@ public void writeJson_origin_custom() throws Exception { assertThat(readString(json, "annotations.aws_origin")).isNull(); } - @Test - public void writeJson_server_localEndpointIsName() throws Exception { + @Test void writeJson_server_localEndpointIsName() throws Exception { Span span = serverSpan .toBuilder() @@ -79,16 +75,14 @@ public void writeJson_server_localEndpointIsName() throws Exception { assertThat(readString(json, "name")).isEqualTo("master"); } - @Test - public void writeJson_client_isRemote() throws Exception { + @Test void writeJson_client_isRemote() throws Exception { Span span = serverSpan.toBuilder().kind(Span.Kind.CLIENT).build(); String json = writeJson(span); assertThat(readString(json, "namespace")).isEqualTo("remote"); } - @Test - public void writeJson_client_child_isRemoteSubsegment() throws Exception { + @Test void writeJson_client_child_isRemoteSubsegment() throws Exception { Span span = serverSpan.toBuilder().parentId('1').kind(Span.Kind.CLIENT).build(); String json = writeJson(span); @@ -96,8 +90,7 @@ public void writeJson_client_child_isRemoteSubsegment() throws Exception { assertThat(readString(json, "namespace")).isEqualTo("remote"); } - @Test - public void writeJson_custom_nameIsUnknown() throws Exception { + @Test void writeJson_custom_nameIsUnknown() throws Exception { Span span = serverSpan.toBuilder() .kind(null) .name(null) @@ -107,8 +100,7 @@ public void writeJson_custom_nameIsUnknown() throws Exception { assertThat(readString(json, "name")).isEqualTo("unknown"); } - @Test - public void writeJson_custom_nameIsName() throws Exception { + @Test void writeJson_custom_nameIsName() throws Exception { Span span = serverSpan.toBuilder() .kind(null) .name("hystrix") @@ -118,8 +110,7 @@ public void writeJson_custom_nameIsName() throws Exception { assertThat(readString(json, "name")).isEqualTo("hystrix"); } - @Test - public void writeJson_client_nameIsUnknown() throws Exception { + @Test void writeJson_client_nameIsUnknown() throws Exception { Span span = Span.newBuilder() .traceId(serverSpan.traceId()).id("b") .kind(Span.Kind.CLIENT) @@ -130,8 +121,7 @@ public void writeJson_client_nameIsUnknown() throws Exception { assertThat(readString(json, "name")).isEqualTo("unknown"); } - @Test - public void writeJson_client_nameIsHost() throws Exception { + @Test void writeJson_client_nameIsHost() throws Exception { Span span = serverSpan.toBuilder() .kind(Span.Kind.CLIENT) .name("get /") @@ -143,8 +133,7 @@ public void writeJson_client_nameIsHost() throws Exception { assertThat(readString(json, "name")).isEqualTo("facebook.com"); } - @Test - public void writeJson_client_nameIsName() throws Exception { + @Test void writeJson_client_nameIsName() throws Exception { Span span = serverSpan.toBuilder() .kind(Span.Kind.CLIENT) .name("get /") @@ -155,8 +144,7 @@ public void writeJson_client_nameIsName() throws Exception { assertThat(readString(json, "name")).isEqualTo("get /"); } - @Test - public void writeJson_client_nameIsUnknownWhenNameNull() throws Exception { + @Test void writeJson_client_nameIsUnknownWhenNameNull() throws Exception { Span span = Span.newBuilder() .traceId(serverSpan.traceId()).id("b") .kind(Span.Kind.CLIENT) @@ -166,8 +154,7 @@ public void writeJson_client_nameIsUnknownWhenNameNull() throws Exception { assertThat(readString(json, "name")).isEqualTo("unknown"); } - @Test - public void writeJson_client_remoteEndpointIsName() throws Exception { + @Test void writeJson_client_remoteEndpointIsName() throws Exception { Span span = serverSpan.toBuilder() .kind(Span.Kind.CLIENT) .remoteEndpoint(Endpoint.newBuilder().serviceName("master").build()) @@ -177,8 +164,7 @@ public void writeJson_client_remoteEndpointIsName() throws Exception { assertThat(readString(json, "name")).isEqualTo("master"); } - @Test - public void writeJson_http() throws Exception { + @Test void writeJson_http() throws Exception { Span span = serverSpan .toBuilder() @@ -193,8 +179,7 @@ public void writeJson_http() throws Exception { assertThat(readMap(json, "http.response")).containsExactly(entry("status", 200)); } - @Test - public void writeJson_http_clientError() throws Exception { + @Test void writeJson_http_clientError() throws Exception { Span span = serverSpan .toBuilder() @@ -208,8 +193,7 @@ public void writeJson_http_clientError() throws Exception { assertThat(readBoolean(json, "fault")).isNull(); } - @Test - public void writeJson_http_serverError() throws Exception { + @Test void writeJson_http_serverError() throws Exception { Span span = serverSpan .toBuilder() @@ -223,16 +207,14 @@ public void writeJson_http_serverError() throws Exception { assertThat(readBoolean(json, "fault")).isTrue(); } - @Test - public void writeJson_sql() throws Exception { + @Test void writeJson_sql() throws Exception { Span span = serverSpan.toBuilder().putTag("sql.url", "jdbc:test").build(); String json = writeJson(span); assertThat(readMap(json, "sql")).containsExactly(entry("url", "jdbc:test")); } - @Test - public void writeJson_aws() throws Exception { + @Test void writeJson_aws() throws Exception { Span span = serverSpan .toBuilder() @@ -250,8 +232,7 @@ public void writeJson_aws() throws Exception { }); } - @Test - public void writeJson_sdkProvided() throws Exception { + @Test void writeJson_sdkProvided() throws Exception { Span span = serverSpan .toBuilder() @@ -264,8 +245,7 @@ public void writeJson_sdkProvided() throws Exception { }); } - @Test - public void writeJson_aws_ec2() throws Exception { + @Test void writeJson_aws_ec2() throws Exception { Span span = serverSpan .toBuilder() diff --git a/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/XRayUDPStorageTest.java b/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/XRayUDPStorageTest.java index 9209a69b..b29cb4c9 100644 --- a/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/XRayUDPStorageTest.java +++ b/storage/xray-udp/src/test/java/zipkin2/storage/xray_udp/XRayUDPStorageTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenZipkin Authors + * Copyright 2016-2023 The OpenZipkin Authors * * Licensed 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 @@ -27,17 +27,17 @@ import java.util.Collections; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import zipkin2.Span; import zipkin2.TestObjects; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -public class XRayUDPStorageTest { +class XRayUDPStorageTest { private static EventLoopGroup workerGroup; private static Channel serverChannel; @@ -45,7 +45,7 @@ public class XRayUDPStorageTest { private static XRayUDPStorage storage; - @BeforeClass + @BeforeAll public static void startServer() { workerGroup = new NioEventLoopGroup(); receivedPayloads = new LinkedBlockingQueue<>(); @@ -70,20 +70,18 @@ public static void startServer() { .build(); } - @AfterClass + @AfterAll public static void stopServer() { storage.close(); serverChannel.close().syncUninterruptibly(); workerGroup.shutdownGracefully(); } - @Before - public void setUp() { + @BeforeEach void setUp() { receivedPayloads.clear(); } - @Test - public void sendTrace() throws Exception { + @Test void sendTrace() throws Exception { storage.accept(TestObjects.TRACE).execute(); for (Span span : TestObjects.TRACE) { byte[] received = receivedPayloads.take(); @@ -92,24 +90,21 @@ public void sendTrace() throws Exception { assertThat(receivedPayloads).isEmpty(); } - @Test - public void sendSingleSpan() throws Exception { + @Test void sendSingleSpan() throws Exception { storage.accept(Collections.singletonList(TestObjects.CLIENT_SPAN)).execute(); assertThat(receivedPayloads.take()) .containsExactly(UDPMessageEncoder.encode(TestObjects.CLIENT_SPAN)); assertThat(receivedPayloads).isEmpty(); } - @Test - public void sendNoSpans() throws Exception { + @Test void sendNoSpans() throws Exception { storage.accept(Collections.emptyList()).execute(); // Give some time for any potential bugs to get sent to the server. Thread.sleep(100); assertThat(receivedPayloads).isEmpty(); } - @Test - public void sendAfterClose() throws Exception { + @Test void sendAfterClose() throws Exception { XRayUDPStorage storage = XRayUDPStorage.newBuilder() .address("localhost:" + ((InetSocketAddress)serverChannel.localAddress()).getPort()) .build();