Unverified Commit 7d39bf6b authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add DynamoDB pseudo integration test (#240)

parent 9959d9b9
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
test-util = ["protocol-test-helpers"]

[dependencies]
hyper = { version = "0.14.2", features = ["client", "http1", "http2", "tcp", "runtime"] }
tower = { version = "0.4.6", features = ["util", "retry"] }
@@ -22,9 +25,12 @@ smithy-types = { path = "../../../rust-runtime/smithy-types" }
smithy-http-tower = { path = "../../../rust-runtime/smithy-http-tower" }
fastrand = "1.4.0"
tokio = { version = "1", features = ["time"] }

pin-project = "1"
tracing = "0.1.25"

protocol-test-helpers = { path = "../../../rust-runtime/protocol-test-helpers", optional = true }

[dev-dependencies]
tokio = { version = "1", features = ["full", "test-util"] }
tower-test = "0.4.0"
+1 −0
Original line number Diff line number Diff line
pub mod conn;
mod retry;
#[cfg(feature = "test-util")]
pub mod test_connection;

pub use retry::RetryConfig;
+14 −7
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
 * SPDX-License-Identifier: Apache-2.0.
 */

use http::header::HeaderName;
use http::header::{HeaderName, CONTENT_TYPE};
use http::Request;
use smithy_http::body::SdkBody;
use std::future::Ready;
@@ -11,6 +11,7 @@ use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
use tower::BoxError;
use protocol_test_helpers::{validate_body, MediaType, assert_ok};

type ConnectVec<B> = Vec<(http::Request<SdkBody>, http::Response<B>)>;

@@ -33,8 +34,14 @@ impl ValidateRequest {
        }
        let actual_str = std::str::from_utf8(actual.body().bytes().unwrap_or(&[]));
        let expected_str = std::str::from_utf8(expected.body().bytes().unwrap_or(&[]));
        let media_type = if actual.headers().get(CONTENT_TYPE).map(|v| v.to_str().unwrap().contains("json")).unwrap_or(false) {
            MediaType::Json
        } else {
            MediaType::Other("unknown".to_string())
        };
        match (actual_str, expected_str) {
            (Ok(actual), Ok(expected)) => assert_eq!(actual, expected),
            (Ok(actual), Ok(expected)) =>
                assert_ok(validate_body(actual, expected, media_type)),
            _ => assert_eq!(actual.body().bytes(), expected.body().bytes()),
        };
        assert_eq!(actual.uri(), expected.uri());
+3 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ import software.amazon.smithy.rust.codegen.smithy.generators.LibRsSection
import software.amazon.smithy.rust.codegen.smithy.generators.ProtocolConfig
import software.amazon.smithy.rust.codegen.smithy.letIf

val TestedServices = setOf("kms")
val TestedServices = setOf("kms", "dynamodb")

class IntegrationTestDecorator : RustCodegenDecorator {
    override val name: String = "IntegrationTest"
@@ -41,5 +41,5 @@ class AwsHyperDevDep(private val runtimeConfig: RuntimeConfig) : LibRsCustomizat
    }
}

val Tokio = CargoDependency("tokio", CratesIo("1"), features = listOf("macros"), scope = DependencyScope.Dev)
fun RuntimeConfig.awsHyper() = CargoDependency("aws-hyper", Local(relativePath))
val Tokio = CargoDependency("tokio", CratesIo("1"), features = listOf("macros", "test-util"), scope = DependencyScope.Dev)
fun RuntimeConfig.awsHyper() = CargoDependency("aws-hyper", Local(relativePath), features = listOf("test-util"))
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ plugins {
val smithyVersion: String by project

val sdkOutputDir = buildDir.resolve("aws-sdk")
val runtimeModules = listOf("smithy-types", "smithy-http", "smithy-http-tower")
val runtimeModules = listOf("smithy-types", "smithy-http", "smithy-http-tower", "protocol-test-helpers")
val awsModules = listOf("aws-auth", "aws-endpoint", "aws-types", "aws-hyper", "aws-sig-auth", "aws-http")

buildscript {
Loading