-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change var names to be protocol test specific; add basic scaffold. * Add AWSSmokeTestGenerator that provides custom behaviors to parent class SmokeTestGenerator in smithy-swift. * Add SmokeTest package manifest generation on top of existing aws-sdk-swift package manifeset generation command. * Fix compile errors / warnings * Fix smoke tests manifest codegen bug. * Modify staging SDK logic for smoke test directories. * Add override variables for ignoring smoke test codegen by test ID or test tag. Also, add rm -rf for previously generated smoke test artifacts to codegen.sh script. * Add convenience script for running multiple test runners based on AWS_SMOKE_TEST_SERVICE_IDS environment variable. * Place holder for adding directory; will be deleted and filled with smoke tests with each new release. * temporarily disable reference to main branch for internal build test * Revert temporarily commented logic in PrepareRelease. Fix client name bug. Add convenience script for running every smoke test. * Ignore code-generated SmokeTests; don't commit them to repo. * Revert changes in GeneratePackageManifest.swift, and separate smoke tests package manifest generation to its independent subcommand GenerateSmokeTestsPackageManifest.swift. --------- Co-authored-by: Sichan Yoo <[email protected]>
- Loading branch information
Showing
19 changed files
with
362 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...WSSDKSwiftCLI/Commands/AWSSDKSwiftCLI/Subcommands/GenerateSmokeTestsPackageManifest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import ArgumentParser | ||
import Foundation | ||
import AWSCLIUtils | ||
|
||
struct GenerateSmokeTestsPackageManifestCommand: ParsableCommand { | ||
static var configuration = CommandConfiguration( | ||
commandName: "generate-smoke-tests-package-manifest", | ||
abstract: "Generates the Package.swift manifest for the aws-sdk-swift/SmokeTests package." | ||
) | ||
|
||
@Argument(help: "The path to the aws-sdk-swift repository") | ||
var repoPath: String | ||
|
||
func run() throws { | ||
let generateSmokeTestsPackageManifest = GenerateSmokeTestsPackageManifest( | ||
repoPath: repoPath | ||
) | ||
try generateSmokeTestsPackageManifest.run() | ||
} | ||
} | ||
|
||
struct GenerateSmokeTestsPackageManifest { | ||
/// The path to the package repository | ||
let repoPath: String | ||
|
||
func run() throws { | ||
try FileManager.default.changeWorkingDirectory(repoPath) | ||
// Generate package manifest for smoke tests and save it as aws-sdk-swift/SmokeTests/Package.swift | ||
let smokeTestsContents = try generateSmokeTestsPackageManifestContents() | ||
try savePackageManifest(smokeTestsContents) | ||
} | ||
|
||
// MARK: - Helpers | ||
|
||
func generateSmokeTestsPackageManifestContents() throws -> String { | ||
return [ | ||
// SmokeTests package manifest uses same prefix as one for aws-sdk-swift. | ||
try PackageManifestBuilder.contentReader(filename: "Package.Prefix")(), | ||
try generateServiceNamesArray(), | ||
try PackageManifestBuilder.contentReader(filename: "SmokeTestsPackage.Base")() | ||
].joined(separator: .newline) | ||
} | ||
|
||
func generateServiceNamesArray() throws -> String { | ||
let servicesWithSmokeTests = try FileManager.default.servicesWithSmokeTests() | ||
let formatedServiceList = servicesWithSmokeTests.map { "\t\"\($0)\"," }.joined(separator: .newline) | ||
return [ | ||
"// All services that have smoke tests generated for them.", | ||
"let serviceNames: [String] = [", | ||
formatedServiceList, | ||
"]" | ||
].joined(separator: .newline) | ||
} | ||
|
||
func savePackageManifest(_ contents: String) throws { | ||
let packageFilePath = "SmokeTests/Package.swift" | ||
log("Saving package manifest to \(packageFilePath)...") | ||
try contents.write( | ||
toFile: packageFilePath, | ||
atomically: true, | ||
encoding: .utf8 | ||
) | ||
log("Successfully saved package manifest to \(packageFilePath)") | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Resources/SmokeTestsPackage.Base.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// MARK: - Static Content | ||
|
||
extension Target.Dependency { | ||
// AWS runtime module | ||
static var awsClientRuntime: Self { .product(name: "AWSClientRuntime", package: "aws-sdk-swift") } | ||
// Smithy runtime module | ||
static var clientRuntime: Self { .product(name: "ClientRuntime", package: "smithy-swift") } | ||
} | ||
|
||
let package = Package( | ||
name: "SmokeTests", | ||
platforms: [ | ||
.macOS(.v10_15) | ||
], | ||
products: serviceNames.map(productForRunner(_:)), | ||
dependencies: [ | ||
.package(path: "../../smithy-swift"), | ||
.package(path: "../../aws-sdk-swift") | ||
], | ||
targets: serviceNames.map(targetForRunner(_:)) | ||
) | ||
|
||
// MARK: - Helper functions | ||
|
||
private func productForRunner(_ serviceName: String) -> Product { | ||
.executable(name: "\(serviceName)SmokeTestRunner", targets: ["\(serviceName)SmokeTestRunner"]) | ||
} | ||
|
||
private func targetForRunner(_ serviceName: String) -> Target { | ||
.executableTarget( | ||
name: "\(serviceName)SmokeTestRunner", | ||
dependencies: [ | ||
.clientRuntime, | ||
.awsClientRuntime, | ||
.product(name: "\(serviceName)", package: "aws-sdk-swift") | ||
], | ||
path: "\(serviceName)SmokeTestRunner" | ||
) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/AWSSmokeTestGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package software.amazon.smithy.aws.swift.codegen | ||
|
||
import software.amazon.smithy.aws.traits.ServiceTrait | ||
import software.amazon.smithy.model.node.ObjectNode | ||
import software.amazon.smithy.swift.codegen.SwiftWriter | ||
import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator | ||
import software.amazon.smithy.swift.codegen.integration.SmokeTestGenerator | ||
import software.amazon.smithy.swift.codegen.utils.toUpperCamelCase | ||
|
||
class AWSSmokeTestGenerator( | ||
private val ctx: ProtocolGenerator.GenerationContext | ||
) : SmokeTestGenerator(ctx) { | ||
// Filter out tests by name or tag at codegen time. | ||
// Each element must have the prefix "<service-name>:" before the test name or tag name. | ||
// E.g., "AWSS3:GetObjectTest" or "AWSS3:BucketTests" | ||
override val smokeTestIdsToIgnore = setOf<String>( | ||
// Add smoke test name to ignore here: | ||
// E.g., "AWSACM:GetCertificateFailure", | ||
) | ||
override val smokeTestTagsToIgnore = setOf<String>( | ||
// Add smoke test tag to ignore here: | ||
// E.g., "AWSACM:TagToIgnore", | ||
) | ||
|
||
override fun getServiceName(): String { | ||
return "AWS" + ctx.service.getTrait(ServiceTrait::class.java).get().sdkId.toUpperCamelCase() | ||
} | ||
|
||
override fun getClientName(): String { | ||
return ctx.service.getTrait(ServiceTrait::class.java).get().sdkId.toUpperCamelCase().removeSuffix("Service") + "Client" | ||
} | ||
|
||
override fun renderCustomFilePrivateVariables(writer: SwiftWriter) { | ||
writer.write("fileprivate let regionFromEnv = ProcessInfo.processInfo.environment[\"AWS_SMOKE_TEST_REGION\"]") | ||
writer.write("fileprivate let tagsToSkip = (ProcessInfo.processInfo.environment[\"AWS_SMOKE_TEST_SKIP_TAGS\"] ?? \"\").components(separatedBy: \",\")") | ||
} | ||
|
||
override fun handleVendorParams(vendorParams: ObjectNode, writer: SwiftWriter) { | ||
val nameToValueMappings = getFormattedVendorParams(vendorParams) | ||
nameToValueMappings.forEach { mapping -> | ||
writer.write("config.${mapping.key} = ${mapping.value}") | ||
} | ||
} | ||
|
||
// Converts trait definition vendor param key:value pairs to Swift SDK config field:value pairs. | ||
private fun getFormattedVendorParams(vendorParams: ObjectNode): Map<String, String> { | ||
val formattedMapping = mutableMapOf<String, String>() | ||
vendorParams.members.forEach { originalMapping -> | ||
when (originalMapping.key.value) { | ||
/* BaseAwsVendorParams members */ | ||
"region" -> { | ||
// Take region value retrieved from environment variable if present; otherwise, take from trait definition. | ||
val regionValue = "regionFromEnv ?? \"${originalMapping.value.expectStringNode().value}\"" | ||
formattedMapping.put("region", regionValue) | ||
formattedMapping.put("signingRegion", regionValue) | ||
} | ||
"sigv4aRegionSet" -> { /* no-op; setting multiple signing regions in config is unsupported atm. */ } | ||
"uri" -> { formattedMapping.put("endpoint", "\"${originalMapping.value.expectStringNode().value}\"") } | ||
"useFips" -> { formattedMapping.put("useFIPS", originalMapping.value.expectBooleanNode().value.toString()) } | ||
"useDualstack" -> { formattedMapping.put("useDualStack", originalMapping.value.expectBooleanNode().value.toString()) } | ||
"useAccountIdRouting" -> { /* no-op; setting account ID routing in config is unsupported atm. */ } | ||
|
||
/* S3VendorParams members */ | ||
"useAccelerate" -> { formattedMapping.put("accelerate", originalMapping.value.expectBooleanNode().value.toString()) } | ||
"useMultiRegionAccessPoints" -> { | ||
// Name for corresponding config in Swift SDK is: `disableMultiRegionAccessPoints`; value needs to be flipped. | ||
formattedMapping.put("disableMultiRegionAccessPoints", (!(originalMapping.value.expectBooleanNode().value)).toString()) | ||
} | ||
"useGlobalEndpoint", "forcePathStyle", "useArnRegion" -> { | ||
// No change needed for these | ||
formattedMapping.put(originalMapping.key.value, originalMapping.value.expectBooleanNode().value.toString()) | ||
} | ||
} | ||
} | ||
return formattedMapping | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.