nonprod
nonprod

Reputation: 1

Test GCP publisher retry settings in Spring application

I've a spring integration application - which listens for messages from a Kafka topic and publishes them to Google Cloud Topic.

The GCP Publisher is created using DefaultPublisherFactory and has the below retry configuration

RetrySettings retrySettings = RetrySettings.newBuilder()
        .setInitialRetryDelay(Duration.ofSeconds(1))
        .setRetryDelayMultiplier(600)
        .setMaxRetryDelay(Duration.ofSeconds(2))
        .setTotalTimeout(Duration.ofSeconds(10))
        .setInitialRpcTimeout(Duration.ofSeconds(10))
        .setMaxRpcTimeout(Duration.ofSeconds(10))
        .build()

The application is up and everything runs as expected.

But I'm unable to figure out how to test the above retry settings.

Since the application isn't failing - the retry scenario is not tested.

I'm fairly new to integration testing - I googled a lot - but could not figure out way - to produce or mock the retry scenario.

Any guidance in figuring this out would be very helpful.

Thanks.

Upvotes: 0

Views: 443

Answers (1)

Hyperion
Hyperion

Reputation: 168

Google Cloud Support here!

As DCTID said, your code is not easily testable, because it will only be run when your application fails. For this reason, I would encourage you to simply wait until that happens - if it ever happens.

Upvotes: 1

Related Questions