diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecorator.kt index a224fe4f25..3e880bd6fd 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecorator.kt @@ -23,6 +23,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext +import software.amazon.smithy.rust.codegen.core.smithy.PublicImportSymbolProvider import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.Instantiator @@ -50,12 +51,6 @@ class SmokeTestsDecorator : ClientCodegenDecorator { logger.warning("skipping smoketest `${smokeTestCase.id}` with unsupported vendorParam `sigv4aRegionSet`") return false } - // TODO(https://github.com/smithy-lang/smithy-rs/issues/3776) Once Account ID routing is supported, - // update the vendorParams setter and remove this check. - if (vendorParams.useAccountIdRouting()) { - logger.warning("skipping smoketest `${smokeTestCase.id}` with unsupported vendorParam `useAccountIdRouting`") - return false - } } AwsSmokeTestModel.getS3VendorParams(smokeTestCase)?.orNull()?.let { s3VendorParams -> if (s3VendorParams.useGlobalEndpoint()) { @@ -138,7 +133,7 @@ class SmokeTestsBuilderKindBehavior(val codegenContext: CodegenContext) : Instan } class SmokeTestsInstantiator(private val codegenContext: ClientCodegenContext) : Instantiator( - codegenContext.symbolProvider, + PublicImportSymbolProvider(codegenContext.symbolProvider, codegenContext.moduleUseName()), codegenContext.model, codegenContext.runtimeConfig, SmokeTestsBuilderKindBehavior(codegenContext), @@ -147,9 +142,16 @@ class SmokeTestsInstantiator(private val codegenContext: ClientCodegenContext) : writer: RustWriter, testCase: SmokeTestCase, ) { - writer.rust("let conf = config::Builder::new()") + writer.rust( + "let config = #{T}::load_defaults(config::BehaviorVersion::latest()).await;", + AwsCargoDependency.awsConfig(codegenContext.runtimeConfig).toType(), + ) + writer.rust("let conf = config::Config::from(&config).to_builder()") writer.indent() - writer.rust(".behavior_version(config::BehaviorVersion::latest())") + + // TODO(https://github.com/smithy-lang/smithy-rs/issues/3776) Once Account ID routing is supported, + // reflect the config setting here, especially to disable it if needed, as it is enabled by default in + // `AwsVendorParams`. val vendorParams = AwsSmokeTestModel.getAwsVendorParams(testCase) vendorParams.orNull()?.let { params -> diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecoratorTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecoratorTest.kt deleted file mode 100644 index 8a4180aeb0..0000000000 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/SmokeTestsDecoratorTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -package software.amazon.smithy.rustsdk - -import org.junit.jupiter.api.Test -import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel - -class SmokeTestsDecoratorTest { - companion object { - // Can't use the dollar sign in a multiline string with doing it like this. - private const val PREFIX = "\$version: \"2\"" - val model = - """ - $PREFIX - namespace test - - use aws.api#service - use smithy.test#smokeTests - use aws.auth#sigv4 - use aws.protocols#restJson1 - use smithy.rules#endpointRuleSet - - @service(sdkId: "dontcare") - @restJson1 - @sigv4(name: "dontcare") - @auth([sigv4]) - @endpointRuleSet({ - "version": "1.0", - "rules": [{ "type": "endpoint", "conditions": [], "endpoint": { "url": "https://example.com" } }], - "parameters": { - "Region": { "required": false, "type": "String", "builtIn": "AWS::Region" }, - } - }) - service TestService { - version: "2023-01-01", - operations: [SomeOperation] - } - - @smokeTests([ - { - id: "SomeOperationSuccess", - params: {} - vendorParams: { - region: "us-west-2" - } - expect: { success: {} } - } - { - id: "SomeOperationFailure", - params: {} - vendorParams: { - region: "us-west-2" - } - expect: { failure: {} } - } - { - id: "SomeOperationFailureExplicitShape", - params: {} - vendorParams: { - region: "us-west-2" - } - expect: { - failure: { errorId: FooException } - } - } - ]) - @http(uri: "/SomeOperation", method: "POST") - @optionalAuth - operation SomeOperation { - input: SomeInput, - output: SomeOutput, - errors: [FooException] - } - - @input - structure SomeInput {} - - @output - structure SomeOutput {} - - @error("server") - structure FooException { } - """.asSmithyModel() - } - - @Test - fun smokeTestSdkCodegen() { - awsSdkIntegrationTest(model) { _, _ -> - // It should compile. We can't run the tests - // because they don't target a real service. - } - } -}