Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump gravitee-entrypoint-webhook #10204

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@
*/
package io.gravitee.apim.integration.tests.messages.webhook;

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.graviteesource.entrypoint.webhook.auth.OAuth2AuthenticationProvider.*;
import static com.github.tomakehurst.wiremock.client.WireMock.badRequest;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToIgnoreCase;
import static com.github.tomakehurst.wiremock.client.WireMock.moreThanOrExactly;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.serverError;
import static com.github.tomakehurst.wiremock.client.WireMock.unauthorized;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.graviteesource.entrypoint.webhook.auth.OAuth2AuthenticationProvider.ACCESS_TOKEN_KEY;
import static com.graviteesource.entrypoint.webhook.auth.OAuth2AuthenticationProvider.EXPIRES_IN_KEY;
import static com.graviteesource.entrypoint.webhook.auth.OAuth2AuthenticationProvider.TOKEN_TYPE_KEY;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;

Expand Down Expand Up @@ -50,7 +60,6 @@
import io.gravitee.plugin.entrypoint.EntrypointConnectorPlugin;
import io.gravitee.plugin.policy.PolicyPlugin;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
import io.reactivex.rxjava3.schedulers.TestScheduler;
import java.util.ArrayList;
Expand Down Expand Up @@ -155,33 +164,34 @@ void should_retry_on_5xx_and_interrupt_when_max_retries_is_reached(
configureMockEndpoint(api, 0, 1);
deploy(api);

final int messageCount = 6;
// 1 first attempt + 3 retries then 5 dispatcher retries * ( 1 regular attempt + 3 retries)
final int messageCount = (1 + 3) + (5 * (1 + 3));
final String callbackPath = WEBHOOK_URL_PATH + "/test";
final ArrayList<Completable> readyObs = new ArrayList<>();
final Subscription subscription = webhookActions.createSubscription(API_ID, callbackPath, readyObs);
final Subscription subscription = webhookActions.createSubscription(API_ID, callbackPath);

TestScheduler testScheduler = new TestScheduler();
RxJavaPlugins.setComputationSchedulerHandler(s -> testScheduler);

wiremock.resetAll();
wiremock.stubFor(post(callbackPath).willReturn(serverError()));

final TestObserver<Void> obs = webhookActions
webhookActions
.dispatchSubscription(subscription)
.mergeWith(Completable.merge(readyObs).andThen(Completable.fromRunnable(testScheduler::triggerActions)))
.mergeWith(Completable.fromRunnable(testScheduler::triggerActions))
.takeUntil(
webhookActions.waitForRequestsOnCallback(
messageCount,
callbackPath,
() -> {
// 1000 for the webhook
testScheduler.advanceTimeBy(3000, MILLISECONDS);
testScheduler.triggerActions();
}
)
)
.test();

obs.awaitDone(10, SECONDS).assertError(InterruptionFailureException.class);
.test()
.awaitDone(10, SECONDS)
.assertError(InterruptionFailureException.class);

// Mock endpoint produces only 1 message. 1 attempt + 5 retries. We should expect no more than 6 calls
webhookActions.verifyMessages(messageCount, callbackPath, "message");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder;
import com.graviteesource.entrypoint.webhook.configuration.HttpHeader;
import com.graviteesource.entrypoint.webhook.configuration.RetryStrategy;
import com.graviteesource.entrypoint.webhook.configuration.SecurityType;
import com.graviteesource.entrypoint.webhook.configuration.WebhookEntrypointConnectorSubscriptionConfiguration;
import com.graviteesource.entrypoint.webhook.configuration.WebhookSubscriptionAuthConfiguration;
Expand Down Expand Up @@ -173,6 +174,10 @@ public Subscription configureSubscriptionAndCallback(String apiId, String callba
WebhookEntrypointConnectorSubscriptionConfiguration configuration = new WebhookEntrypointConnectorSubscriptionConfiguration();
configuration.setCallbackUrl(String.format("http://localhost:%s%s", wiremock.port(), callbackPath));
configuration.setHeaders(headers);
configuration.getRetry().setRetryStrategy(RetryStrategy.EXPONENTIAL);
configuration.getRetry().setRetryOnFail(true);
configuration.getRetry().setInitialDelaySeconds(3L);
configuration.getRetry().setMaxDelaySeconds(3L);
wiremock.stubFor(post(callbackPath).willReturn(ok("callback body")));

return buildTestSubscription(apiId, configuration);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
<gravitee-entrypoint-http-get.version>2.0.0-alpha.2</gravitee-entrypoint-http-get.version>
<gravitee-entrypoint-http-post.version>2.0.0-alpha.2</gravitee-entrypoint-http-post.version>
<gravitee-entrypoint-sse.version>5.0.0-alpha.2</gravitee-entrypoint-sse.version>
<gravitee-entrypoint-webhook.version>4.0.0-alpha.2</gravitee-entrypoint-webhook.version>
<gravitee-entrypoint-webhook.version>4.0.0-alpha.5</gravitee-entrypoint-webhook.version>
<gravitee-entrypoint-websocket.version>2.0.0-alpha.2</gravitee-entrypoint-websocket.version>
<gravitee-endpoint-kafka.version>3.0.0-alpha.3</gravitee-endpoint-kafka.version>
<gravitee-endpoint-mqtt5.version>3.0.0-alpha.3</gravitee-endpoint-mqtt5.version>
Expand Down