diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/CallbackServlet.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/CallbackServlet.java
index bf0535d..263a501 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/CallbackServlet.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/CallbackServlet.java
@@ -98,6 +98,28 @@ public class CallbackServlet extends HttpServlet {
}
}
+ public void flakyAssertListenerStatus() {
+ // Bail early
+ if (isListenerFailed) {
+ log.error(listenerFailedMsg);
+ Assert.fail(listenerFailedMsg);
+ }
+
+ try {
+ isCompleted(DELAY);
+ } catch (final Exception e) {
+ log.warn("flakyAssertListenerStatus didn't complete", e);
+ }
+
+ // Ignore missed events
+ reset();
+
+ if (isListenerFailed) {
+ log.error(listenerFailedMsg);
+ Assert.fail(listenerFailedMsg);
+ }
+ }
+
public synchronized void reset() {
receivedCalls.set(0);
forceToFail.set(false);
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java
index 763036a..07448a0 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestJaxrsBase.java
@@ -322,7 +322,11 @@ public class TestJaxrsBase extends KillbillClient {
// Register tenant for callback
final String callback = callbackServer.getServletEndpoint();
tenantApi.registerPushNotificationCallback(callback, requestOptions);
- callbackServlet.assertListenerStatus();
+
+ // Use the flaky version... In the non-happy path, the catalog event sent during tenant creation is received
+ // before we had the chance to register our servlet. In this case, instead of 2 events, we will only see one
+ // and the flakyAssertListenerStatus will timeout but not fail the test
+ callbackServlet.flakyAssertListenerStatus();
createdTenant.setApiSecret(apiSecret);