Skip to content
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

Merged
merged 17 commits into from
Nov 7, 2024
Merged

misc: smoke tests fixes #1160

merged 17 commits into from
Nov 7, 2024

Conversation

0marperez
Copy link
Contributor

@0marperez 0marperez commented Oct 9, 2024

Issue #

Description of changes

  • Fixes operation parameter rendering
  • Smoke test runner generator refactoring
  • Changes used downstream

Companion PR: awslabs/aws-sdk-kotlin#1437

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This comment has been minimized.

This comment has been minimized.

@0marperez 0marperez marked this pull request as ready for review October 9, 2024 15:27
@0marperez 0marperez requested a review from a team as a code owner October 9, 2024 15:27
{
"id": "c376a9ee-568d-4638-8f4f-2e9a54f2869c",
"type": "feature",
"description": "Failed smoke tests now print exception stack trace"
Copy link
Contributor

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

object SmokeTestUriValue : SectionId {
val EndpointProvider: SectionKey<Symbol> = SectionKey("EndpointProvider")
val EndpointParameters: SectionKey<Symbol> = SectionKey("EndpointParameters")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

organization/style: Namespace these sections under another object SmokeTestSectionId

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: My comment here is still valid

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 SectionKeys?

write("#L = #L", vendorParam.key.value.toCamelCase(), vendorParam.value.format())
when (vendorParam.key.value) {
"region" -> {
writeInline("#L = ", vendorParam.key.value.toCamelCase())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: repeated vendorParam.key.value.toCamelCase() can be stored in a local variable

declareSection(SmokeTestRegionDefault)
write("#L", vendorParam.value.format())
}
"sigv4aRegionSet" -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctness: smithy-kotlin should not know anything about AWS-specific config options. region was fine because we've treated it like a generic client config option, but is there any way to lift the handling of these AWS-specific vendor params out of smithy-kotlin?

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?

@0marperez 0marperez added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Nov 5, 2024

This comment has been minimized.

1 similar comment

This comment has been minimized.

@0marperez 0marperez changed the title misc: smoke tests vendor params section ids & smoke test failed test case exception logging misc: smoke tests fixes Nov 5, 2024
testCase.operationParameters.forEach { param ->
val paramName = param.key.value.toCamelCase()
writer.writeInline("#L = ", paramName)
renderOperationParameter(paramName, param.value, paramsToShapes, testCase)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify: You shouldn't need to pass the entire paramsToShapes map to this function, just passing paramsToShapes[paramName] should work

testCase: SmokeTestCase,
shapeOverride: Shape? = null,
) {
val shape = shapeOverride ?: shapes[paramName] ?: throw Exception("Unable to find shape for operation parameter '$paramName' in smoke test '${testCase.functionName}'.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a better exception type available like IllegalArgumentException or IllegalStateException. Same applies for other Exception below

Comment on lines +250 to +251
// Everything else
else -> writer.write("#L", node.format())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support "anything else" or should we be throwing an exception if we reach this else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we support "simple" types i.e. Node. If we encounter an unknown Node type we throw an exception.

Comment on lines 325 to 336
// Section IDs
object AdditionalEnvironmentVariables : SectionId
object DefaultClientConfig : SectionId
object HttpEngineOverride : SectionId
object ServiceFilter : SectionId
object SkipTags : SectionId
object ClientConfig : SectionId {
val Name: SectionKey<String> = SectionKey("aws.smithy.kotlin#SmokeTestClientConfigName")
val Value: SectionKey<String> = SectionKey("aws.smithy.kotlin#SmokeTestClientConfigValue")
val EndpointProvider: SectionKey<Symbol> = SectionKey("aws.smithy.kotlin#SmokeTestEndpointProvider")
val EndpointParams: SectionKey<Symbol> = SectionKey("aws.smithy.kotlin#SmokeTestClientEndpointParams")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be top-level values, not class members

Comment on lines 338 to 358
// Constants
private val model = ctx.model
private val settings = ctx.settings
private val sdkId = settings.sdkId
private val symbolProvider = ctx.symbolProvider
private val service = symbolProvider.toSymbol(model.expectShape(settings.service))
private val operations = model.topDownOperations(settings.service).filter { it.hasTrait<SmokeTestsTrait>() }
}

/**
* Derives a function name for a [SmokeTestCase]
* Env var for smoke test runners.
* Should be a comma-delimited list of strings that correspond to tags on the test cases.
* If a test case is tagged with one of the tags indicated by SMOKE_TEST_SKIP_TAGS, it MUST be skipped by the smoke test runner.
*/
const val SKIP_TAGS = "SMOKE_TEST_SKIP_TAGS"

/**
* Env var for smoke test runners.
* Should be a comma-separated list of service identifiers to test.
*/
private val SmokeTestCase.functionName: String
get() = this.id.toCamelCase()
const val SERVICE_FILTER = "SMOKE_TEST_SERVICE_IDS"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: These should all go at the top of the class / file

This comment has been minimized.

object SmokeTestUriValue : SectionId {
val EndpointProvider: SectionKey<Symbol> = SectionKey("EndpointProvider")
val EndpointParameters: SectionKey<Symbol> = SectionKey("EndpointParameters")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: My comment here is still valid

Copy link

github-actions bot commented Nov 6, 2024

Affected Artifacts

Changed in size
Artifact Pull Request (bytes) Latest Release (bytes) Delta (bytes) Delta (percentage)
http-client-jvm.jar 314,811 313,978 833 0.27%
runtime-core-jvm.jar 810,925 808,803 2,122 0.26%

@0marperez 0marperez merged commit 3acc85f into main Nov 7, 2024
16 checks passed
@0marperez 0marperez deleted the smoke-tests-trait branch November 7, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants