From 5c2c86c65da7787f1ab5e630d8aef0c5806a7221 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Sun, 23 Oct 2022 20:33:48 +0300 Subject: [PATCH] Run aws-sdk tests against 2.18.x (#6956) Resolves https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/6945 --- .../aws-sdk-2.2/javaagent/build.gradle.kts | 15 +++---- .../library-autoconfigure/build.gradle.kts | 17 ++++---- .../aws-sdk-2.2/library/build.gradle.kts | 17 ++++---- .../awssdk/v2_2/AbstractAws2ClientTest.groovy | 39 ++++++++++++------- 4 files changed, 52 insertions(+), 36 deletions(-) diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts index c17b682423a5..a17e8378186a 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts @@ -26,16 +26,17 @@ dependencies { testImplementation(project(":instrumentation:netty:netty-4.1:javaagent")) latestDepTestLibrary("software.amazon.awssdk:aws-json-protocol:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:aws-core:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:dynamodb:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:ec2:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:kinesis:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:rds:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:s3:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:sqs:2.17.+") + latestDepTestLibrary("software.amazon.awssdk:aws-core:+") + latestDepTestLibrary("software.amazon.awssdk:dynamodb:+") + latestDepTestLibrary("software.amazon.awssdk:ec2:+") + latestDepTestLibrary("software.amazon.awssdk:kinesis:+") + latestDepTestLibrary("software.amazon.awssdk:rds:+") + latestDepTestLibrary("software.amazon.awssdk:s3:+") + latestDepTestLibrary("software.amazon.awssdk:sqs:+") } tasks.withType().configureEach { + systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) // TODO run tests both with and without experimental span attributes jvmArgs("-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true") } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts index 55513c4642be..fc1764c887fb 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/build.gradle.kts @@ -12,18 +12,19 @@ dependencies { testImplementation(project(":instrumentation:aws-sdk:aws-sdk-2.2:testing")) - latestDepTestLibrary("software.amazon.awssdk:aws-core:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:aws-json-protocol:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:dynamodb:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:ec2:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:kinesis:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:rds:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:s3:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:sqs:2.17.+") + latestDepTestLibrary("software.amazon.awssdk:aws-core:+") + latestDepTestLibrary("software.amazon.awssdk:aws-json-protocol:+") + latestDepTestLibrary("software.amazon.awssdk:dynamodb:+") + latestDepTestLibrary("software.amazon.awssdk:ec2:+") + latestDepTestLibrary("software.amazon.awssdk:kinesis:+") + latestDepTestLibrary("software.amazon.awssdk:rds:+") + latestDepTestLibrary("software.amazon.awssdk:s3:+") + latestDepTestLibrary("software.amazon.awssdk:sqs:+") } tasks { test { + systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true) } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts index 526bdc0f50e6..681a92a8396e 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts @@ -10,18 +10,19 @@ dependencies { testImplementation(project(":instrumentation:aws-sdk:aws-sdk-2.2:testing")) - latestDepTestLibrary("software.amazon.awssdk:aws-core:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:aws-json-protocol:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:dynamodb:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:ec2:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:kinesis:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:rds:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:s3:2.17.+") - latestDepTestLibrary("software.amazon.awssdk:sqs:2.17.+") + latestDepTestLibrary("software.amazon.awssdk:aws-core:+") + latestDepTestLibrary("software.amazon.awssdk:aws-json-protocol:+") + latestDepTestLibrary("software.amazon.awssdk:dynamodb:+") + latestDepTestLibrary("software.amazon.awssdk:ec2:+") + latestDepTestLibrary("software.amazon.awssdk:kinesis:+") + latestDepTestLibrary("software.amazon.awssdk:rds:+") + latestDepTestLibrary("software.amazon.awssdk:s3:+") + latestDepTestLibrary("software.amazon.awssdk:sqs:+") } tasks { test { + systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true) } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy index 25273797e00d..8504091db141 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientTest.groovy @@ -384,11 +384,11 @@ abstract class AbstractAws2ClientTest extends InstrumentationSpecification { request.request().headers().get("traceparent") == null where: - service | operation | method | path | requestId | builder | call | body - "S3" | "CreateBucket" | "PUT" | "/somebucket" | "UNKNOWN" | S3Client.builder() | { c -> c.createBucket(CreateBucketRequest.builder().bucket("somebucket").build()) } | "" - "S3" | "GetObject" | "GET" | "/somebucket/somekey" | "UNKNOWN" | S3Client.builder() | { c -> c.getObject(GetObjectRequest.builder().bucket("somebucket").key("somekey").build()) } | "" - "Kinesis" | "DeleteStream" | "POST" | "" | "UNKNOWN" | KinesisClient.builder() | { c -> c.deleteStream(DeleteStreamRequest.builder().streamName("somestream").build()) } | "" - "Sqs" | "CreateQueue" | "POST" | "" | "7a62c49f-347e-4fc4-9331-6e8e7a96aa73" | SqsClient.builder() | { c -> c.createQueue(CreateQueueRequest.builder().queueName("somequeue").build()) } | """ + service | operation | method | path | requestId | builder | call | body + "S3" | "CreateBucket" | "PUT" | path("somebucket") | "UNKNOWN" | S3Client.builder() | { c -> c.createBucket(CreateBucketRequest.builder().bucket("somebucket").build()) } | "" + "S3" | "GetObject" | "GET" | path("somebucket", "somekey") | "UNKNOWN" | S3Client.builder() | { c -> c.getObject(GetObjectRequest.builder().bucket("somebucket").key("somekey").build()) } | "" + "Kinesis" | "DeleteStream" | "POST" | "" | "UNKNOWN" | KinesisClient.builder() | { c -> c.deleteStream(DeleteStreamRequest.builder().streamName("somestream").build()) } | "" + "Sqs" | "CreateQueue" | "POST" | "" | "7a62c49f-347e-4fc4-9331-6e8e7a96aa73" | SqsClient.builder() | { c -> c.createQueue(CreateQueueRequest.builder().queueName("somequeue").build()) } | """ https://queue.amazonaws.com/123456789012/MyQueue 7a62c49f-347e-4fc4-9331-6e8e7a96aa73 @@ -476,18 +476,18 @@ abstract class AbstractAws2ClientTest extends InstrumentationSpecification { request.request().headers().get("traceparent") == null where: - service | operation | method | path | requestId | builder | call | body - "S3" | "CreateBucket" | "PUT" | "/somebucket" | "UNKNOWN" | S3AsyncClient.builder() | { c -> c.createBucket(CreateBucketRequest.builder().bucket("somebucket").build()) } | "" - "S3" | "GetObject" | "GET" | "/somebucket/somekey" | "UNKNOWN" | S3AsyncClient.builder() | { c -> c.getObject(GetObjectRequest.builder().bucket("somebucket").key("somekey").build(), AsyncResponseTransformer.toBytes()) } | "1234567890" + service | operation | method | path | requestId | builder | call | body + "S3" | "CreateBucket" | "PUT" | path("somebucket") | "UNKNOWN" | S3AsyncClient.builder() | { c -> c.createBucket(CreateBucketRequest.builder().bucket("somebucket").build()) } | "" + "S3" | "GetObject" | "GET" | path("somebucket", "somekey") | "UNKNOWN" | S3AsyncClient.builder() | { c -> c.getObject(GetObjectRequest.builder().bucket("somebucket").key("somekey").build(), AsyncResponseTransformer.toBytes()) } | "1234567890" // Kinesis seems to expect an http2 response which is incompatible with our test server. // "Kinesis" | "DeleteStream" | "POST" | "/" | "UNKNOWN" | KinesisAsyncClient.builder() | { c -> c.deleteStream(DeleteStreamRequest.builder().streamName("somestream").build()) } | "" - "Sqs" | "CreateQueue" | "POST" | "" | "7a62c49f-347e-4fc4-9331-6e8e7a96aa73" | SqsAsyncClient.builder() | { c -> c.createQueue(CreateQueueRequest.builder().queueName("somequeue").build()) } | """ + "Sqs" | "CreateQueue" | "POST" | "" | "7a62c49f-347e-4fc4-9331-6e8e7a96aa73" | SqsAsyncClient.builder() | { c -> c.createQueue(CreateQueueRequest.builder().queueName("somequeue").build()) } | """ https://queue.amazonaws.com/123456789012/MyQueue 7a62c49f-347e-4fc4-9331-6e8e7a96aa73 """ - "Sqs" | "SendMessage" | "POST" | "" | "27daac76-34dd-47df-bd01-1f6e873584a0" | SqsAsyncClient.builder() | { c -> c.sendMessage(SendMessageRequest.builder().queueUrl("someurl").messageBody("").build()) } | """ + "Sqs" | "SendMessage" | "POST" | "" | "27daac76-34dd-47df-bd01-1f6e873584a0" | SqsAsyncClient.builder() | { c -> c.sendMessage(SendMessageRequest.builder().queueUrl("someurl").messageBody("").build()) } | """ d41d8cd98f00b204e9800998ecf8427e @@ -497,14 +497,14 @@ abstract class AbstractAws2ClientTest extends InstrumentationSpecification { 27daac76-34dd-47df-bd01-1f6e873584a0 """ - "Ec2" | "AllocateAddress" | "POST" | "" | "59dbff89-35bd-4eac-99ed-be587EXAMPLE" | Ec2AsyncClient.builder() | { c -> c.allocateAddress() } | """ + "Ec2" | "AllocateAddress" | "POST" | "" | "59dbff89-35bd-4eac-99ed-be587EXAMPLE" | Ec2AsyncClient.builder() | { c -> c.allocateAddress() } | """ 59dbff89-35bd-4eac-99ed-be587EXAMPLE 192.0.2.1 standard """ - "Rds" | "DeleteOptionGroup" | "POST" | "" | "0ac9cda2-bbf4-11d3-f92b-31fa5e8dbc99" | RdsAsyncClient.builder() | { c -> c.deleteOptionGroup(DeleteOptionGroupRequest.builder().build()) } | """ + "Rds" | "DeleteOptionGroup" | "POST" | "" | "0ac9cda2-bbf4-11d3-f92b-31fa5e8dbc99" | RdsAsyncClient.builder() | { c -> c.deleteOptionGroup(DeleteOptionGroupRequest.builder().build()) } | """ 0ac9cda2-bbf4-11d3-f92b-31fa5e8dbc99 @@ -535,6 +535,7 @@ abstract class AbstractAws2ClientTest extends InstrumentationSpecification { then: thrown SdkClientException + def path = path("somebucket", "somekey") assertTraces(1) { trace(0, 1) { span(0) { @@ -547,7 +548,7 @@ abstract class AbstractAws2ClientTest extends InstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" server.httpPort() - "$SemanticAttributes.HTTP_URL" "${server.httpUri()}/somebucket/somekey" + "$SemanticAttributes.HTTP_URL" "${server.httpUri()}${path}" "$SemanticAttributes.HTTP_METHOD" "GET" "$SemanticAttributes.HTTP_FLAVOR" "1.1" "$SemanticAttributes.RPC_SYSTEM" "aws-api" @@ -560,4 +561,16 @@ abstract class AbstractAws2ClientTest extends InstrumentationSpecification { } } } + + static String path(String bucket, String path = null) { + def result = "" + // since 2.18.0 bucket name is not present in request path + if (!Boolean.getBoolean("testLatestDeps") && !bucket.isEmpty()) { + result = "/" + bucket + } + if (path != null && !path.isEmpty()) { + result += "/" + path + } + return result + } }