-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc: smoke tests fixes #1160
misc: smoke tests fixes #1160
Changes from 7 commits
8cc53c3
d1fee9e
31c0a8f
2c6edb6
73d7bad
434eb22
2f47ed3
e7ac93f
b298270
5442f76
ffa8c50
1336afb
82c46e9
9c08472
d3abcca
44dfed5
04933e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"id": "c376a9ee-568d-4638-8f4f-2e9a54f2869c", | ||
"type": "feature", | ||
"description": "Failed smoke tests now print exception stack trace" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,13 @@ package software.amazon.smithy.kotlin.codegen.rendering.smoketests | |
import software.amazon.smithy.codegen.core.Symbol | ||
import software.amazon.smithy.kotlin.codegen.core.* | ||
import software.amazon.smithy.kotlin.codegen.integration.SectionId | ||
import software.amazon.smithy.kotlin.codegen.integration.SectionKey | ||
import software.amazon.smithy.kotlin.codegen.model.getTrait | ||
import software.amazon.smithy.kotlin.codegen.model.hasTrait | ||
import software.amazon.smithy.kotlin.codegen.rendering.endpoints.EndpointParametersGenerator | ||
import software.amazon.smithy.kotlin.codegen.rendering.endpoints.EndpointProviderGenerator | ||
import software.amazon.smithy.kotlin.codegen.rendering.smoketests.SmokeTestUriValue.EndpointParameters | ||
import software.amazon.smithy.kotlin.codegen.rendering.smoketests.SmokeTestUriValue.EndpointProvider | ||
import software.amazon.smithy.kotlin.codegen.rendering.util.format | ||
import software.amazon.smithy.kotlin.codegen.utils.dq | ||
import software.amazon.smithy.kotlin.codegen.utils.toCamelCase | ||
|
@@ -18,7 +23,21 @@ object SmokeTestsRunner : SectionId | |
object SmokeTestAdditionalEnvVars : SectionId | ||
object SmokeTestDefaultConfig : SectionId | ||
object SmokeTestRegionDefault : SectionId | ||
object SmokeTestUseDualStackKey : SectionId | ||
object SmokeTestSigv4aRegionSetKey : SectionId | ||
object SmokeTestSigv4aRegionSetValue : SectionId | ||
object SmokeTestAccountIdBasedRoutingKey : SectionId | ||
object SmokeTestAccountIdBasedRoutingValue : SectionId | ||
object SmokeTestHttpEngineOverride : SectionId | ||
object SmokeTestUseAccelerateKey : SectionId | ||
object SmokeTestUseMultiRegionAccessPointsKey : SectionId | ||
object SmokeTestUseMultiRegionAccessPointsValue : SectionId | ||
object SmokeTestUseGlobalEndpoint : SectionId | ||
object SmokeTestUriKey : SectionId | ||
object SmokeTestUriValue : SectionId { | ||
val EndpointProvider: SectionKey<Symbol> = SectionKey("EndpointProvider") | ||
val EndpointParameters: SectionKey<Symbol> = SectionKey("EndpointParameters") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. organization/style: Namespace these sections under another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: My comment here is still valid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't part of the diff anymore. But do you mean the |
||
|
||
const val SKIP_TAGS = "AWS_SMOKE_TEST_SKIP_TAGS" | ||
const val SERVICE_FILTER = "AWS_SMOKE_TEST_SERVICE_IDS" | ||
|
@@ -31,10 +50,11 @@ class SmokeTestsRunnerGenerator( | |
ctx: CodegenContext, | ||
) { | ||
private val model = ctx.model | ||
private val sdkId = ctx.settings.sdkId | ||
private val settings = ctx.settings | ||
private val sdkId = settings.sdkId | ||
private val symbolProvider = ctx.symbolProvider | ||
private val service = symbolProvider.toSymbol(model.expectShape(ctx.settings.service)) | ||
private val operations = ctx.model.topDownOperations(ctx.settings.service).filter { it.hasTrait<SmokeTestsTrait>() } | ||
private val service = symbolProvider.toSymbol(model.expectShape(settings.service)) | ||
private val operations = model.topDownOperations(settings.service).filter { it.hasTrait<SmokeTestsTrait>() } | ||
|
||
internal fun render() { | ||
writer.declareSection(SmokeTestsRunner) { | ||
|
@@ -108,12 +128,72 @@ class SmokeTestsRunnerGenerator( | |
writer.withInlineBlock("#L {", "}", service) { | ||
if (testCase.vendorParams.isPresent) { | ||
testCase.vendorParams.get().members.forEach { vendorParam -> | ||
if (vendorParam.key.value == "region") { | ||
writeInline("#L = ", vendorParam.key.value.toCamelCase()) | ||
declareSection(SmokeTestRegionDefault) | ||
write("#L", vendorParam.value.format()) | ||
} else { | ||
write("#L = #L", vendorParam.key.value.toCamelCase(), vendorParam.value.format()) | ||
when (vendorParam.key.value) { | ||
"region" -> { | ||
writeInline("#L = ", vendorParam.key.value.toCamelCase()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: repeated |
||
declareSection(SmokeTestRegionDefault) | ||
write("#L", vendorParam.value.format()) | ||
} | ||
"sigv4aRegionSet" -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correctness: smithy-kotlin should not know anything about AWS-specific config options. I'm not sure there is, since this implementation heavily relies on sections, but something to consider. Can a single "vendor params" section be declared and the name of the vendor param (i.e. sigv4aRegionSet) be passed in context to aws-sdk-kotlin? |
||
declareSection(SmokeTestSigv4aRegionSetKey) { | ||
writeInline("#L", vendorParam.key.value.toCamelCase()) | ||
} | ||
writeInline(" = ") | ||
declareSection(SmokeTestSigv4aRegionSetValue) { | ||
write("#L", vendorParam.value.format()) | ||
} | ||
} | ||
"uri" -> { | ||
declareSection(SmokeTestUriKey) { | ||
writeInline("#L", vendorParam.key.value.toCamelCase()) | ||
} | ||
writeInline(" = ") | ||
declareSection( | ||
SmokeTestUriValue, | ||
mapOf( | ||
EndpointProvider to EndpointProviderGenerator.getSymbol(settings), | ||
EndpointParameters to EndpointParametersGenerator.getSymbol(settings), | ||
), | ||
) { | ||
write("#L", vendorParam.value.format()) | ||
} | ||
} | ||
"useDualstack" -> { | ||
declareSection(SmokeTestUseDualStackKey) { | ||
writeInline("#L", vendorParam.key.value.toCamelCase()) | ||
} | ||
write(" = #L", vendorParam.value.format()) | ||
} | ||
"useAccountIdRouting" -> { | ||
declareSection(SmokeTestAccountIdBasedRoutingKey) { | ||
writeInline("#L", vendorParam.key.value.toCamelCase()) | ||
} | ||
writeInline(" = ") | ||
declareSection(SmokeTestAccountIdBasedRoutingValue) { | ||
write("#L", vendorParam.value.format()) | ||
} | ||
} | ||
"useAccelerate" -> { | ||
declareSection(SmokeTestUseAccelerateKey) { | ||
writeInline("#L", vendorParam.key.value.toCamelCase()) | ||
} | ||
write(" = #L", vendorParam.value.format()) | ||
} | ||
"useMultiRegionAccessPoints" -> { | ||
declareSection(SmokeTestUseMultiRegionAccessPointsKey) { | ||
writeInline("#L", vendorParam.key.value.toCamelCase()) | ||
} | ||
writeInline(" = ") | ||
declareSection(SmokeTestUseMultiRegionAccessPointsValue) { | ||
write("#L", vendorParam.value.format()) | ||
} | ||
} | ||
"useGlobalEndpoint" -> { | ||
declareSection(SmokeTestUseGlobalEndpoint) { | ||
write("#L = #L", vendorParam.key.value.toCamelCase(), vendorParam.value.format()) | ||
} | ||
} | ||
else -> write("#L = #L", vendorParam.key.value.toCamelCase(), vendorParam.value.format()) | ||
} | ||
} | ||
} else { | ||
|
@@ -133,8 +213,10 @@ class SmokeTestsRunnerGenerator( | |
writer.withBlock(".#T { client ->", "}", RuntimeTypes.Core.IO.use) { | ||
withBlock("client.#L(", ")", operation.defaultName()) { | ||
withBlock("#L {", "}", operationSymbol) { | ||
testCase.params.get().members.forEach { member -> | ||
write("#L = #L", member.key.value.toCamelCase(), member.value.format()) | ||
if (testCase.params.isPresent) { | ||
testCase.params.get().members.forEach { member -> | ||
write("#L = #L", member.key.value.toCamelCase(), member.value.format()) | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -156,6 +238,7 @@ class SmokeTestsRunnerGenerator( | |
testCase.expectation.isFailure, | ||
writer, | ||
) | ||
writer.write("if (!success) #T(e)", RuntimeTypes.Core.SmokeTests.printExceptionStackTrace) | ||
writer.write("if (!success) exitCode = 1") | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
package aws.smithy.kotlin.runtime.smoketests | ||
|
||
public expect fun exitProcess(status: Int): Nothing | ||
|
||
/** | ||
* Prints an exceptions stack trace using test anything protocol (TAP) format e.g. | ||
* | ||
* #java.lang.ArithmeticException: / by zero | ||
* # at FileKt.main(File.kt:3) | ||
* # at FileKt.main(File.kt) | ||
* # at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | ||
* # at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) | ||
* # at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) | ||
* # at java.base/java.lang.reflect.Method.invoke(Unknown Source) | ||
* # at executors.JavaRunnerExecutor$Companion.main(JavaRunnerExecutor.kt:27) | ||
* # at executors.JavaRunnerExecutor.main(JavaRunnerExecutor.kt) | ||
*/ | ||
public fun printExceptionStackTrace(exception: Exception): Unit = | ||
println(exception.stackTraceToString().split("\n").joinToString("\n") { "#$it" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/opinion: This does not need a changelog