Skip to content

Commit

Permalink
Upgrade Smithy to 1.50.0 (#3728)
Browse files Browse the repository at this point in the history
## Motivation and Context
This PR upgrades Smithy to 1.50.0. The majority of the changes follow
`TODO` added in #3690.
Other than that, a few adjustments needed to be made:
- for the client
- added two failing tests `RestJsonClientPopulatesDefaultValuesInInput`
and `RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults` to
known failing tests for the same reason
[here](https://github.com/smithy-lang/smithy-rs/blob/main/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolTestGenerator.kt#L72)
- added one broken test (i.e. the upstream test definition is incorrect
but our implementation is correct) to known broken tests per
([smithy#2341](smithy-lang/smithy#2341),
[smithy-rs#3726](#3726 (comment)))
- for the server
- removed `rest-xml-extras.smithy` since
`RestXmlMustSupportParametersInContentType` is now available upstream
Smithy 1.50.0
- added the following to known failing tests (since the `awsJson1_0`
counterparts are already in the list, but we need the server team to
verify this assumption & provide additional `TODO` comments if
necessary)
    - `RestJsonServerPopulatesDefaultsWhenMissingInRequestBody`
    - `RestJsonServerPopulatesDefaultsInResponseWhenMissingInParams`,
-
`RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams`

## Testing
Existing tests in CI

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
  • Loading branch information
ysaito1001 and Velfi committed Jul 5, 2024
1 parent 2bf0385 commit 17545f6
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 307 deletions.
11 changes: 1 addition & 10 deletions codegen-client-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,7 @@ val allCodegenTests = listOf(
ClientTest(
"aws.protocoltests.restjson#RestJsonExtras",
"rest_json_extras",
dependsOn = listOf(
"rest-json-extras.smithy",
// TODO(https://github.com/smithy-lang/smithy/pull/2310): Can be deleted when consumed in next Smithy version.
"rest-json-extras-2310.smithy",
// TODO(https://github.com/smithy-lang/smithy/pull/2314): Can be deleted when consumed in next Smithy version.
"rest-json-extras-2314.smithy",
// TODO(https://github.com/smithy-lang/smithy/pull/2315): Can be deleted when consumed in next Smithy version.
// TODO(https://github.com/smithy-lang/smithy/pull/2331): Can be deleted when consumed in next Smithy version.
"rest-json-extras-2315.smithy",
),
dependsOn = listOf("rest-json-extras.smithy"),
),
ClientTest("aws.protocoltests.misc#MiscService", "misc", dependsOn = listOf("misc.smithy")),
ClientTest("aws.protocoltests.restxml#RestXml", "rest_xml", addMessageToErrors = false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package software.amazon.smithy.rust.codegen.client.smithy.generators.protocol

import software.amazon.smithy.model.node.NumberNode
import software.amazon.smithy.model.shapes.DoubleShape
import software.amazon.smithy.model.shapes.FloatShape
import software.amazon.smithy.model.shapes.OperationShape
Expand All @@ -27,7 +28,9 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.Broke
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.FailingTest
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTestGenerator
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.AWS_JSON_10
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ServiceShapeId.REST_JSON
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.TestCase
import software.amazon.smithy.rust.codegen.core.util.PANIC
import software.amazon.smithy.rust.codegen.core.util.dq
Expand Down Expand Up @@ -73,7 +76,38 @@ class ClientProtocolTestGenerator(
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse"),
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
FailingTest.RequestTest(AWS_JSON_10, "AwsJson10ClientPopulatesDefaultValuesInInput"),
FailingTest.RequestTest(REST_JSON, "RestJsonClientPopulatesDefaultValuesInInput"),
FailingTest.RequestTest(REST_JSON, "RestJsonClientUsesExplicitlyProvidedMemberValuesOverDefaults"),
)

private val BrokenTests:
Set<BrokenTest> =
setOf(
BrokenTest.ResponseTest(
ServiceShapeId.REST_JSON,
"RestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse",
howToFixItFn = ::fixRestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse,
inAtLeast = setOf("1.50.0"),
trackedIn =
setOf(
// TODO(https://github.com/smithy-lang/smithy/pull/2341)
"https://github.com/smithy-lang/smithy/pull/2341",
),
),
)

private fun fixRestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse(
testCase: TestCase.ResponseTest,
): TestCase.ResponseTest {
val fixedParams =
testCase.testCase.params.toBuilder().withMember("defaultTimestamp", NumberNode.from(2)).build()
return TestCase.ResponseTest(
testCase.testCase.toBuilder()
.params(fixedParams)
.build(),
testCase.targetShape,
)
}
}

override val appliesTo: AppliesTo
Expand All @@ -85,7 +119,7 @@ class ClientProtocolTestGenerator(
override val disabledTests: Set<String>
get() = emptySet()
override val brokenTests: Set<BrokenTest>
get() = emptySet()
get() = BrokenTests

override val logger: Logger = Logger.getLogger(javaClass.name)

Expand Down
35 changes: 0 additions & 35 deletions codegen-core/common-test-models/rest-json-extras-2310.smithy

This file was deleted.

39 changes: 0 additions & 39 deletions codegen-core/common-test-models/rest-json-extras-2314.smithy

This file was deleted.

133 changes: 0 additions & 133 deletions codegen-core/common-test-models/rest-json-extras-2315.smithy

This file was deleted.

7 changes: 0 additions & 7 deletions codegen-core/common-test-models/rest-json-extras.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ service RestJsonExtras {
CaseInsensitiveErrorOperation,
EmptyStructWithContentOnWireOp,
QueryPrecedence,
// TODO(https://github.com/smithy-lang/smithy/pull/2314)
HttpPayloadTraits2,
// TODO(https://github.com/smithy-lang/smithy/pull/2310)
MalformedContentTypeWithBody2,
// TODO(https://github.com/smithy-lang/smithy/pull/2315)
HttpEnumPayload2,
HttpStringPayload2,
],
errors: [ExtraError]
}
Expand Down
53 changes: 0 additions & 53 deletions codegen-core/common-test-models/rest-xml-extras.smithy

This file was deleted.

16 changes: 1 addition & 15 deletions codegen-server-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,7 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
CodegenTest(
"aws.protocoltests.restjson#RestJsonExtras",
"rest_json_extras",
imports = listOf(
"$commonModels/rest-json-extras.smithy",
// TODO(https://github.com/smithy-lang/smithy/pull/2310): Can be deleted when consumed in next Smithy version.
"$commonModels/rest-json-extras-2310.smithy",
// TODO(https://github.com/smithy-lang/smithy/pull/2314): Can be deleted when consumed in next Smithy version.
"$commonModels/rest-json-extras-2314.smithy",
// TODO(https://github.com/smithy-lang/smithy/pull/2315): Can be deleted when consumed in next Smithy version.
// TODO(https://github.com/smithy-lang/smithy/pull/2331): Can be deleted when consumed in next Smithy version.
"$commonModels/rest-json-extras-2315.smithy",
),
imports = listOf("$commonModels/rest-json-extras.smithy"),
),
CodegenTest(
"aws.protocoltests.restjson.validation#RestJsonValidation",
Expand Down Expand Up @@ -100,11 +91,6 @@ val allCodegenTests = "../codegen-core/common-test-models".let { commonModels ->
"pokemon-service-awsjson-server-sdk",
imports = listOf("$commonModels/pokemon-awsjson.smithy", "$commonModels/pokemon-common.smithy"),
),
CodegenTest(
"aws.protocoltests.restxml#RestXmlExtras",
"rest_xml_extras",
imports = listOf("$commonModels/rest-xml-extras.smithy"),
),
)
}

Expand Down
Loading

0 comments on commit 17545f6

Please sign in to comment.