Commit a8c500ba authored by Zelda Hessler's avatar Zelda Hessler
Browse files

re-enable compression protocol tests

parent a4301fa4
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -36,4 +36,22 @@ references = ["aws-sdk-rust#1079"]
meta = { "breaking" = false, "bug" = true, "tada" = false }
author = "rcoh"

[[smithy-rs]]
message = """
Compression is now supported for operations modeled with the `@requestCompression` trait.

[**For more details, see the long-form changelog discussion**](https://github.com/smithy-lang/smithy-rs/discussions/3646).
"""
references = ["smithy-rs#2891"]
meta = { "breaking" = false, "bug" = false, "tada" = true, "target" = "client" }
author = "Velfi"

[[aws-sdk-rust]]
message = """
Compression is now supported for operations modeled with the `@requestCompression` trait.

[**For more details, see the long-form changelog discussion**](https://github.com/smithy-lang/smithy-rs/discussions/3646).
"""
references = ["smithy-rs#2891"]
meta = { "breaking" = false, "bug" = false, "tada" = true }
author = "Velfi"
+6 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

package software.amazon.smithy.rustsdk

import software.amazon.smithy.model.knowledge.TopDownIndex
import software.amazon.smithy.model.traits.RequestCompressionTrait
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext
import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator
@@ -23,8 +24,11 @@ class HttpRequestCompressionDecorator : ClientCodegenDecorator {
    override val name: String = "HttpRequestCompression"
    override val order: Byte = 0

    private fun usesRequestCompression(codegenContext: ClientCodegenContext): Boolean =
        codegenContext.model.isTraitApplied(RequestCompressionTrait::class.java)
    private fun usesRequestCompression(codegenContext: ClientCodegenContext): Boolean {
        val index = TopDownIndex.of(codegenContext.model)
        val ops = index.getContainedOperations(codegenContext.serviceShape.id)
        return ops.any { it.hasTrait(RequestCompressionTrait.ID) }
    }

    override fun configCustomizations(
        codegenContext: ClientCodegenContext,
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ private fun generateCargoWorkspace(
) = (
    """
    [workspace]
    resolver = "2"
    members = [
        ${tests.joinToString(",") { "\"${it.module}/$pluginName\"" }}
    ]
+4 −8
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable
import software.amazon.smithy.rust.codegen.core.rustlang.rust
import software.amazon.smithy.rust.codegen.core.rustlang.writable
import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.Companion.clientRequestCompression
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.core.util.getTrait
import java.util.logging.Logger

@@ -31,20 +31,16 @@ class RequestCompressionGenerator(
    override fun section(section: OperationSection): Writable {
        operationShape.getTrait<RequestCompressionTrait>()?.let { requestCompressionTrait ->
            val logger = Logger.getLogger("SdkSettings")

            if (requestCompressionTrait.encodings.isEmpty()) {
                logger.warning { "No encodings were specified for the requestCompressionTrait on ${operationShape.id}" }
                return emptySection
            }
            // Get the `HttpCompressionTrait`, returning early if this
            // `OperationShape` doesn't have one
            val compressionTrait = operationShape.getTrait<RequestCompressionTrait>() ?: return emptySection
            val encoding = firstSupportedEncoding(compressionTrait.encodings) ?: return emptySection
            // We can remove this once we start supporting other algos.
            val encoding = firstSupportedEncoding(requestCompressionTrait.encodings) ?: return emptySection
            // We can remove this once we start supporting other algorithms.
            // Until then, we shouldn't see anything else coming up here.
            assert(encoding == "gzip") { "Only gzip is supported but encoding was `$encoding`" }
            val runtimeConfig = codegenContext.runtimeConfig
            val compression = clientRequestCompression(runtimeConfig)
            val compression = RuntimeType.clientRequestCompression(runtimeConfig)

            return writable {
                when (section) {
+1 −16
Original line number Diff line number Diff line
@@ -592,21 +592,6 @@ class DefaultProtocolTestGenerator(

        // These tests are not even attempted to be generated, either because they will not compile
        // or because they are flaky
        private val DisableTests =
            setOf<String>(
                // TODO(https://github.com/smithy-lang/smithy-rs/issues/2891): Implement support for `@requestCompression`
                "SDKAppendedGzipAfterProvidedEncoding_restJson1",
                "SDKAppendedGzipAfterProvidedEncoding_restXml",
                "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0",
                "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1",
                "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery",
                "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query",
                "SDKAppliedContentEncoding_awsJson1_0",
                "SDKAppliedContentEncoding_awsJson1_1",
                "SDKAppliedContentEncoding_awsQuery",
                "SDKAppliedContentEncoding_ec2Query",
                "SDKAppliedContentEncoding_restJson1",
                "SDKAppliedContentEncoding_restXml",
            )
        private val DisableTests: Set<String> = setOf()
    }
}