Skip to content

Commit 5687f7e

Browse files
committed
Cleanup, Clarity changes to test code in src
1 parent 8aae6e4 commit 5687f7e

File tree

6 files changed

+32
-26
lines changed

6 files changed

+32
-26
lines changed

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/GradleGenerator.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55
package aws.sdk.kotlin.codegen
66

7-
import aws.sdk.kotlin.codegen.model.traits.FailedResponseTrait
8-
import aws.sdk.kotlin.codegen.model.traits.SuccessResponseTrait
7+
import aws.sdk.kotlin.codegen.model.traits.testing.TestFailedResponseTrait
8+
import aws.sdk.kotlin.codegen.model.traits.testing.TestSuccessResponseTrait
99
import aws.sdk.kotlin.codegen.smoketests.smokeTestDenyList
1010
import software.amazon.smithy.kotlin.codegen.core.*
1111
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
@@ -119,8 +119,8 @@ class GradleGenerator : KotlinIntegration {
119119
* Generates a gradle task to run smoke tests
120120
*/
121121
private fun generateSmokeTestTask(writer: GradleWriter, ctx: CodegenContext) {
122-
val hasSuccessResponseTrait = ctx.model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(SuccessResponseTrait.ID)
123-
val hasFailedResponseTrait = ctx.model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(FailedResponseTrait.ID)
122+
val hasSuccessResponseTrait = ctx.model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(TestSuccessResponseTrait.ID)
123+
val hasFailedResponseTrait = ctx.model.expectShape<ServiceShape>(ctx.settings.service).hasTrait(TestFailedResponseTrait.ID)
124124
val inTestingEnvironment = hasFailedResponseTrait || hasSuccessResponseTrait
125125

126126
/**

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/model/traits/SmokeTestTraits.kt renamed to codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/model/traits/testing/SmokeTestTraits.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
package aws.sdk.kotlin.codegen.model.traits
1+
package aws.sdk.kotlin.codegen.model.traits.testing
22

33
import software.amazon.smithy.model.node.ObjectNode
44
import software.amazon.smithy.model.shapes.ShapeId
55
import software.amazon.smithy.model.traits.AnnotationTrait
66

77
/**
88
* Indicates the annotated service should always return a failed response.
9+
* IMPORTANT: This trait is intended for use in integration or E2E tests only, not in real-life smoke tests that run
10+
* against a service endpoint.
911
*/
10-
class FailedResponseTrait(node: ObjectNode) : AnnotationTrait(ID, node) {
12+
class TestFailedResponseTrait(node: ObjectNode) : AnnotationTrait(ID, node) {
1113
companion object {
1214
val ID: ShapeId = ShapeId.from("smithy.kotlin.traits#failedResponseTrait")
1315
}
1416
}
1517

1618
/**
1719
* Indicates the annotated service should always return a success response.
20+
* IMPORTANT: This trait is intended for use in integration or E2E tests only, not in real-life smoke tests that run
21+
* against a service endpoint.
1822
*/
19-
class SuccessResponseTrait(node: ObjectNode) : AnnotationTrait(ID, node) {
23+
class TestSuccessResponseTrait(node: ObjectNode) : AnnotationTrait(ID, node) {
2024
companion object {
2125
val ID: ShapeId = ShapeId.from("smithy.kotlin.traits#successResponseTrait")
2226
}

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/smoketests/SmokeTestsCodegenRegionIntegration.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import software.amazon.smithy.smoketests.traits.SmokeTestsTrait
1818
*/
1919
class SmokeTestsCodegenRegionIntegration : KotlinIntegration {
2020
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
21-
model.topDownOperations(settings.service).any { it.hasTrait<SmokeTestsTrait>() } && settings.sdkId !in smokeTestDenyList
21+
model.topDownOperations(settings.service).any { it.hasTrait<SmokeTestsTrait>() }
2222

2323
override val sectionWriters: List<SectionWriterBinding>
2424
get() = listOf(
@@ -29,8 +29,8 @@ class SmokeTestsCodegenRegionIntegration : KotlinIntegration {
2929

3030
private val envVars = SectionWriter { writer, _ ->
3131
writer.write(
32-
"private val regionOverride = #T(#S)",
33-
RuntimeTypes.Core.SmokeTests.getEnv,
32+
"private val regionOverride = #T.System.getenv(#S)",
33+
RuntimeTypes.Core.Utils.PlatformProvider,
3434
"AWS_SMOKE_TEST_REGION",
3535
)
3636
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package aws.sdk.kotlin.codegen.smoketests
1+
package aws.sdk.kotlin.codegen.smoketests.testing
22

3-
import aws.sdk.kotlin.codegen.model.traits.FailedResponseTrait
4-
import aws.sdk.kotlin.codegen.model.traits.SuccessResponseTrait
3+
import aws.sdk.kotlin.codegen.model.traits.testing.TestFailedResponseTrait
4+
import aws.sdk.kotlin.codegen.model.traits.testing.TestSuccessResponseTrait
55
import software.amazon.smithy.kotlin.codegen.KotlinSettings
66
import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes
77
import software.amazon.smithy.kotlin.codegen.core.withBlock
@@ -17,14 +17,15 @@ import software.amazon.smithy.model.shapes.ServiceShape
1717
import software.amazon.smithy.smoketests.traits.SmokeTestsTrait
1818

1919
/**
20-
* Adds [FailedResponseTrait] support to smoke tests
20+
* Adds [TestFailedResponseTrait] support to smoke tests
21+
* IMPORTANT: This integration is intended for use in integration or E2E tests only, not in real-life smoke tests that run
22+
* against a service endpoint.
2123
*/
2224
class SmokeTestFailHttpEngineIntegration : KotlinIntegration {
2325
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
2426
model.topDownOperations(settings.service).any { it.hasTrait<SmokeTestsTrait>() } &&
25-
settings.sdkId !in smokeTestDenyList &&
26-
!model.expectShape<ServiceShape>(settings.service).hasTrait(SuccessResponseTrait.ID) &&
27-
model.expectShape<ServiceShape>(settings.service).hasTrait(FailedResponseTrait.ID)
27+
!model.expectShape<ServiceShape>(settings.service).hasTrait(TestSuccessResponseTrait.ID) &&
28+
model.expectShape<ServiceShape>(settings.service).hasTrait(TestFailedResponseTrait.ID)
2829

2930
override val sectionWriters: List<SectionWriterBinding>
3031
get() = listOf(
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package aws.sdk.kotlin.codegen.smoketests
1+
package aws.sdk.kotlin.codegen.smoketests.testing
22

3-
import aws.sdk.kotlin.codegen.model.traits.FailedResponseTrait
4-
import aws.sdk.kotlin.codegen.model.traits.SuccessResponseTrait
3+
import aws.sdk.kotlin.codegen.model.traits.testing.TestFailedResponseTrait
4+
import aws.sdk.kotlin.codegen.model.traits.testing.TestSuccessResponseTrait
55
import software.amazon.smithy.kotlin.codegen.KotlinSettings
66
import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes
77
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
@@ -16,14 +16,15 @@ import software.amazon.smithy.model.shapes.ServiceShape
1616
import software.amazon.smithy.smoketests.traits.SmokeTestsTrait
1717

1818
/**
19-
* Adds [SuccessResponseTrait] support to smoke tests
19+
* Adds [TestSuccessResponseTrait] support to smoke tests
20+
* IMPORTANT: This integration is intended for use in integration or E2E tests only, not in real-life smoke tests that run
21+
* against a service endpoint.
2022
*/
2123
class SmokeTestSuccessHttpEngineIntegration : KotlinIntegration {
2224
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
2325
model.topDownOperations(settings.service).any { it.hasTrait<SmokeTestsTrait>() } &&
24-
settings.sdkId !in smokeTestDenyList &&
25-
model.expectShape<ServiceShape>(settings.service).hasTrait(SuccessResponseTrait.ID) &&
26-
!model.expectShape<ServiceShape>(settings.service).hasTrait(FailedResponseTrait.ID)
26+
model.expectShape<ServiceShape>(settings.service).hasTrait(TestSuccessResponseTrait.ID) &&
27+
!model.expectShape<ServiceShape>(settings.service).hasTrait(TestFailedResponseTrait.ID)
2728

2829
override val sectionWriters: List<SectionWriterBinding>
2930
get() = listOf(

codegen/aws-sdk-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ aws.sdk.kotlin.codegen.customization.s3.S3ExpiresIntegration
4545
aws.sdk.kotlin.codegen.BusinessMetricsIntegration
4646
aws.sdk.kotlin.codegen.smoketests.SmokeTestsDenyListIntegration
4747
aws.sdk.kotlin.codegen.smoketests.SmokeTestsCodegenRegionIntegration
48-
aws.sdk.kotlin.codegen.smoketests.SmokeTestSuccessHttpEngineIntegration
49-
aws.sdk.kotlin.codegen.smoketests.SmokeTestFailHttpEngineIntegration
48+
aws.sdk.kotlin.codegen.smoketests.testing.SmokeTestSuccessHttpEngineIntegration
49+
aws.sdk.kotlin.codegen.smoketests.testing.SmokeTestFailHttpEngineIntegration

0 commit comments

Comments
 (0)