Unverified Commit fece5653 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Add integration tests for supported event stream operations (#676)



* Add support for waiting for the requests to close

* Fix excluded `aws-auth-providers` build

* Add integration test for `transcribestreaming`

* Add integration test for S3 SelectObjectContent

* Validate all request events in the Transcribe streaming test

* Added comment to `decode_frames`

* Fix `aws-config` tests

* Remove trailing whitespace

Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent 4f898068
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -195,10 +195,13 @@ impl TestEnvironment {
        self.log_info();
        self.check_results(&result);
        // todo: validate bodies
        match connector.validate(
        match connector
            .validate(
                &["CONTENT-TYPE", "x-aws-ec2-metadata-token"],
                |_expected, _actual| Ok(()),
        ) {
            )
            .await
        {
            Ok(()) => {}
            Err(e) => panic!("{}", e),
        }
+32 −5
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ package software.amazon.smithy.rustsdk
import software.amazon.smithy.rust.codegen.rustlang.CargoDependency
import software.amazon.smithy.rust.codegen.rustlang.CratesIo
import software.amazon.smithy.rust.codegen.rustlang.DependencyScope
import software.amazon.smithy.rust.codegen.rustlang.Writable
import software.amazon.smithy.rust.codegen.rustlang.writable
import software.amazon.smithy.rust.codegen.smithy.RuntimeConfig
import software.amazon.smithy.rust.codegen.smithy.customize.RustCodegenDecorator
@@ -30,11 +31,17 @@ class IntegrationTestDecorator : RustCodegenDecorator {
            "IntegrationTestDecorator expects to be run from the smithy-rs package root"
        }

        val testPackagePath = integrationTestPath.resolve(protocolConfig.moduleName.substring("aws-sdk-".length))
        val moduleName = protocolConfig.moduleName.substring("aws-sdk-".length)
        val testPackagePath = integrationTestPath.resolve(moduleName)
        return if (Files.exists(testPackagePath) && Files.exists(testPackagePath.resolve("Cargo.toml"))) {
            val hasTests = Files.exists(testPackagePath.resolve("tests"))
            val hasBenches = Files.exists(testPackagePath.resolve("benches"))
            baseCustomizations + IntegrationTestDependencies(protocolConfig.runtimeConfig, hasTests, hasBenches)
            baseCustomizations + IntegrationTestDependencies(
                moduleName,
                protocolConfig.runtimeConfig,
                hasTests,
                hasBenches
            )
        } else {
            baseCustomizations
        }
@@ -42,6 +49,7 @@ class IntegrationTestDecorator : RustCodegenDecorator {
}

class IntegrationTestDependencies(
    private val moduleName: String,
    private val runtimeConfig: RuntimeConfig,
    private val hasTests: Boolean,
    private val hasBenches: Boolean,
@@ -58,11 +66,30 @@ class IntegrationTestDependencies(
            if (hasBenches) {
                addDependency(Criterion)
            }
            for (serviceSpecific in serviceSpecificCustomizations()) {
                serviceSpecific.section(section)(this)
            }
        }
        else -> emptySection
    }

    private fun serviceSpecificCustomizations(): List<LibRsCustomization> = when (moduleName) {
        "transcribestreaming" -> listOf(TranscribeTestDependencies())
        else -> emptyList()
    }
}

class TranscribeTestDependencies : LibRsCustomization() {
    override fun section(section: LibRsSection): Writable = writable {
        addDependency(AsyncStream)
        addDependency(FuturesCore)
        addDependency(Hound)
    }
}

val Criterion = CargoDependency("criterion", CratesIo("0.3"), scope = DependencyScope.Dev)
val SerdeJson = CargoDependency("serde_json", CratesIo("1"), features = emptySet(), scope = DependencyScope.Dev)
val Tokio = CargoDependency("tokio", CratesIo("1"), features = setOf("macros", "test-util"), scope = DependencyScope.Dev)
private val AsyncStream = CargoDependency("async-stream", CratesIo("0.3"), DependencyScope.Dev)
private val Criterion = CargoDependency("criterion", CratesIo("0.3"), scope = DependencyScope.Dev)
private val FuturesCore = CargoDependency("futures-core", CratesIo("0.3"), DependencyScope.Dev)
private val Hound = CargoDependency("hound", CratesIo("3.4"), DependencyScope.Dev)
private val SerdeJson = CargoDependency("serde_json", CratesIo("1"), features = emptySet(), scope = DependencyScope.Dev)
private val Tokio = CargoDependency("tokio", CratesIo("1"), features = setOf("macros", "test-util"), scope = DependencyScope.Dev)
+2 −1
Original line number Diff line number Diff line
@@ -7,5 +7,6 @@ members = [
    "kms",
    "qldbsession",
    "s3",
    "sts"
    "sts",
    "transcribestreaming"
]
+5 −4
Original line number Diff line number Diff line
@@ -14,8 +14,9 @@ smithy-http = { path = "../../build/aws-sdk/smithy-http" }
tracing-subscriber = "0.2.18"

[dev-dependencies]
tokio  = { version = "1", features = ["full"]}
http = "0.2.3"
bytes = "1"
aws-hyper = { path = "../../build/aws-sdk/aws-hyper"}
aws-http = { path = "../../build/aws-sdk/aws-http"}
aws-hyper = { path = "../../build/aws-sdk/aws-hyper"}
bytes = "1"
http = "0.2.3"
serde_json = "1"
tokio  = { version = "1", features = ["full"]}
+117 −0
Original line number Diff line number Diff line
[
  {
    "connection_id": 0,
    "action": {
      "Request": {
        "request": {
          "uri": "https://s3.us-east-2.amazonaws.com/aws-rust-sdk/sample_data.csv?select&select-type=2&x-id=SelectObjectContent",
          "headers": {
            "x-amz-date": [
              "20210831T010050Z"
            ],
            "content-type": [
              "application/xml"
            ],
            "x-amz-content-sha256": [
              "3e2ed0bf97f28640f16193df06b497374232511cd2112b48985a306d40fb16d3"
            ],
            "content-length": [
              "799"
            ],
            "authorization": [
              "AWS4-HMAC-SHA256 Credential=test/test/us-east-2/s3/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=test"
            ],
            "user-agent": [
              "aws-sdk-rust/0.1.0 os/linux lang/rust/1.52.1"
            ],
            "x-amz-user-agent": [
              "aws-sdk-rust/0.1.0 api/s3/0.0.16-alpha os/linux lang/rust/1.52.1"
            ]
          },
          "method": "POST"
        }
      }
    }
  },
  {
    "connection_id": 0,
    "action": {
      "Data": {
        "data": {
          "Utf8": "<SelectObjectContentRequest xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><Expression xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">SELECT * FROM s3object s WHERE s.&quot;Name&quot; = &apos;Jane&apos;</Expression><ExpressionType xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">SQL</ExpressionType><InputSerialization xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><CSV xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><FileHeaderInfo xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">USE</FileHeaderInfo></CSV><CompressionType xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">NONE</CompressionType></InputSerialization><OutputSerialization xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><CSV xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"></CSV></OutputSerialization></SelectObjectContentRequest>"
        },
        "direction": "Request"
      }
    }
  },
  {
    "connection_id": 0,
    "action": {
      "Eof": {
        "ok": true,
        "direction": "Request"
      }
    }
  },
  {
    "connection_id": 0,
    "action": {
      "Response": {
        "response": {
          "Ok": {
            "status": 200,
            "version": "HTTP/1.1",
            "headers": {
              "x-amz-request-id": [
                "NVKMNP55BP15194G"
              ],
              "x-amz-id-2": [
                "geaWcKlzoJpu+EJLNG+t9uaD/9EOuQzGqcxL41SguR9xoDOVMFnjw7CFLm/yHQc3AVpHqHCo3a0="
              ],
              "transfer-encoding": [
                "chunked"
              ],
              "server": [
                "AmazonS3"
              ],
              "date": [
                "Tue, 31 Aug 2021 01:00:52 GMT"
              ]
            }
          }
        }
      }
    }
  },
  {
    "connection_id": 0,
    "action": {
      "Data": {
        "data": {
          "Base64": "AAAAjAAAAFUKNSeBDTptZXNzYWdlLXR5cGUHAAVldmVudAs6ZXZlbnQtdHlwZQcAB1JlY29yZHMNOmNvbnRlbnQtdHlwZQcAGGFwcGxpY2F0aW9uL29jdGV0LXN0cmVhbUphbmUsKDk0OSkgNTU1LTY3MDQsQ2hpY2FnbyxEZXZlbG9wZXINCuadLyI="
        },
        "direction": "Response"
      }
    }
  },
  {
    "connection_id": 0,
    "action": {
      "Data": {
        "data": {
          "Base64": "AAAA0AAAAEMDArAaDTptZXNzYWdlLXR5cGUHAAVldmVudAs6ZXZlbnQtdHlwZQcABVN0YXRzDTpjb250ZW50LXR5cGUHAAh0ZXh0L3htbDxTdGF0cyB4bWxucz0iIj48Qnl0ZXNTY2FubmVkPjMzMzwvQnl0ZXNTY2FubmVkPjxCeXRlc1Byb2Nlc3NlZD4zMzM8L0J5dGVzUHJvY2Vzc2VkPjxCeXRlc1JldHVybmVkPjM5PC9CeXRlc1JldHVybmVkPjwvU3RhdHM+Ey79egAAADgAAAAowcaE1A06bWVzc2FnZS10eXBlBwAFZXZlbnQLOmV2ZW50LXR5cGUHAANFbmTPl9OS"
        },
        "direction": "Response"
      }
    }
  },
  {
    "connection_id": 0,
    "action": {
      "Eof": {
        "ok": true,
        "direction": "Response"
      }
    }
  }
]
Loading