Skip to content

Commit

Permalink
fix test broken by merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Velfi committed Oct 6, 2023
1 parent 10aca1b commit 32ee53f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.config

import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext
import software.amazon.smithy.rust.codegen.client.smithy.ClientRustModule
Expand Down Expand Up @@ -82,9 +80,8 @@ internal class ServiceConfigGeneratorTest {
model.lookup<ServiceShape>("com.example#ResourceService").needsIdempotencyToken(model) shouldBe true
}

@ParameterizedTest
@ValueSource(strings = ["middleware", "orchestrator"])
fun `generate customizations as specified`(smithyRuntimeModeStr: String) {
@Test
fun `generate customizations as specified`() {
class ServiceCustomizer(private val codegenContext: ClientCodegenContext) :
NamedCustomization<ServiceConfig>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub trait ClassifyRetry: Send + Sync + fmt::Debug {
fn classify_retry(
&self,
ctx: &InterceptorContext,
result_of_preceding_classifier: Option<RetryAction>,
previous_action: Option<RetryAction>,
) -> Option<RetryAction>;

/// The name of this retry classifier.
Expand Down Expand Up @@ -128,9 +128,9 @@ impl ClassifyRetry for SharedRetryClassifier {
fn classify_retry(
&self,
ctx: &InterceptorContext,
result_of_preceding_classifier: Option<RetryAction>,
previous_action: Option<RetryAction>,
) -> Option<RetryAction> {
self.0.classify_retry(ctx, result_of_preceding_classifier)
self.0.classify_retry(ctx, previous_action)
}

fn name(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
feature = "connector-hyper-0-14-x",
))]

use ::aws_smithy_runtime::client::retries::classifier::{
HttpStatusCodeClassifier, SmithyErrorClassifier,
use ::aws_smithy_runtime::client::retries::classifiers::{
HttpStatusCodeClassifier, TransientErrorClassifier,
};
use ::aws_smithy_runtime_api::client::retries::RetryClassifiers;
use aws_smithy_async::rt::sleep::TokioSleep;
use aws_smithy_http::body::{BoxBody, SdkBody};
use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
Expand All @@ -24,7 +23,7 @@ use aws_smithy_runtime::test_util::capture_test_logs::capture_test_logs;
use aws_smithy_runtime::{ev, match_events};
use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
use aws_smithy_runtime_api::client::retries::{ClassifyRetry, RetryReason};
use aws_smithy_runtime_api::client::retries::classifiers::{ClassifyRetry, RetryAction};
use aws_smithy_types::retry::{ErrorKind, ProvideErrorKind, ReconnectMode, RetryConfig};
use aws_smithy_types::timeout::TimeoutConfig;
use hyper::client::Builder as HyperBuilder;
Expand Down Expand Up @@ -58,18 +57,26 @@ impl std::error::Error for OperationError {}
struct TestRetryClassifier;

impl ClassifyRetry for TestRetryClassifier {
fn classify_retry(&self, ctx: &InterceptorContext) -> Option<RetryReason> {
fn classify_retry(
&self,
ctx: &InterceptorContext,
previous_action: Option<RetryAction>,
) -> Option<RetryAction> {
if previous_action.is_some() {
// Never second-guess the action of a higher-priority classifier
return previous_action;
}
tracing::info!("classifying retry for {ctx:?}");
let classification = ctx.output_or_error().unwrap().err().and_then(|err| {
if let Some(err) = err.as_operation_error() {
tracing::info!("its an operation error: {err:?}");
let err = err.downcast_ref::<OperationError>().unwrap();
Some(RetryReason::Error(err.0))
Some(RetryAction::Retry(err.0))
} else {
tracing::info!("its something else... using other classifiers");
SmithyErrorClassifier::<OperationError>::new()
.classify_retry(ctx)
.or_else(|| HttpStatusCodeClassifier::default().classify_retry(ctx))
TransientErrorClassifier::<OperationError>::new()
.classify_retry(ctx, None)
.or_else(|| HttpStatusCodeClassifier::default().classify_retry(ctx, None))
}
});
tracing::info!("classified as {classification:?}");
Expand Down Expand Up @@ -132,7 +139,7 @@ async fn wire_level_test(
.build(),
)
.standard_retry(&RetryConfig::standard().with_reconnect_mode(reconnect_mode))
.retry_classifiers(RetryClassifiers::new().with_classifier(TestRetryClassifier))
.retry_classifier(TestRetryClassifier)
.sleep_impl(TokioSleep::new())
.with_connection_poisoning()
.serializer({
Expand Down

0 comments on commit 32ee53f

Please sign in to comment.