killbill-aplcache
Merge remote-tracking branch 'origin/test-fixes' into test-fixes-doc Signed-off-by: …
5/3/2018 8:39:17 AM
Changes
Details
diff --git a/beatrix/src/main/java/org/killbill/billing/beatrix/extbus/BeatrixListener.java b/beatrix/src/main/java/org/killbill/billing/beatrix/extbus/BeatrixListener.java
index 0c86b09..e8ba29b 100644
--- a/beatrix/src/main/java/org/killbill/billing/beatrix/extbus/BeatrixListener.java
+++ b/beatrix/src/main/java/org/killbill/billing/beatrix/extbus/BeatrixListener.java
@@ -106,6 +106,7 @@ public class BeatrixListener {
try {
final BusEvent externalEvent = computeExtBusEventEntryFromBusInternalEvent(event, internalContext);
if (externalEvent != null) {
+ log.info("Sending extBusEvent='{}' from busEvent='{}'", externalEvent, event);
externalBus.post(externalEvent);
}
} catch (final EventBusException e) {
diff --git a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
index 5a2a463..2b41c96 100644
--- a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
@@ -66,6 +66,10 @@ public class TestPaymentApiNoDB extends PaymentTestSuiteNoDB {
@BeforeClass(groups = "fast")
public void beforeClass() throws Exception {
+ if (hasFailed()) {
+ return;
+ }
+
super.beforeClass();
account = testHelper.createTestAccount("yoyo.yahoo.com", false);
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java b/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java
index 0a67f29..74f67f9 100644
--- a/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java
+++ b/payment/src/test/java/org/killbill/billing/payment/core/sm/TestRetryablePayment.java
@@ -129,6 +129,10 @@ public class TestRetryablePayment extends PaymentTestSuiteNoDB {
@BeforeClass(groups = "fast")
public void beforeClass() throws Exception {
+ if (hasFailed()) {
+ return;
+ }
+
super.beforeClass();
account = testHelper.createTestAccount("lolo@gmail.com", false);
Mockito.when(accountInternalApi.getAccountById(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(account);
diff --git a/profiles/killbill/src/main/java/org/killbill/billing/server/notifications/PushNotificationListener.java b/profiles/killbill/src/main/java/org/killbill/billing/server/notifications/PushNotificationListener.java
index abb1544..4ec1caf 100644
--- a/profiles/killbill/src/main/java/org/killbill/billing/server/notifications/PushNotificationListener.java
+++ b/profiles/killbill/src/main/java/org/killbill/billing/server/notifications/PushNotificationListener.java
@@ -127,6 +127,7 @@ public class PushNotificationListener {
private boolean doPost(final UUID tenantId, final String url, final String body, final NotificationJson notification,
final int timeoutSec, final int attemptRetryNumber) {
+ log.info("Sending push notification url='{}', body='{}', attemptRetryNumber='{}'", url, body, attemptRetryNumber);
final BoundRequestBuilder builder = httpClient.preparePost(url);
builder.setBody(body == null ? "{}" : body);
builder.addHeader(HTTP_HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON);
@@ -142,7 +143,7 @@ public class PushNotificationListener {
});
response = futureStatus.get(timeoutSec, TimeUnit.SECONDS);
} catch (final TimeoutException toe) {
- saveRetryPushNotificationInQueue(tenantId, url, notification, attemptRetryNumber);
+ saveRetryPushNotificationInQueue(tenantId, url, notification, attemptRetryNumber, "Timeout");
return false;
} catch (final Exception e) {
log.warn("Failed to push notification url='{}', tenantId='{}'", url, tenantId, e);
@@ -152,7 +153,7 @@ public class PushNotificationListener {
if (response.getStatusCode() >= 200 && response.getStatusCode() < 300) {
return true;
} else {
- saveRetryPushNotificationInQueue(tenantId, url, notification, attemptRetryNumber);
+ saveRetryPushNotificationInQueue(tenantId, url, notification, attemptRetryNumber, "statusCode=" + response.getStatusCode());
return false;
}
}
@@ -168,7 +169,7 @@ public class PushNotificationListener {
doPost(key.getTenantId(), key.getUrl(), body, notification, TIMEOUT_NOTIFICATION, key.getAttemptNumber());
}
- private void saveRetryPushNotificationInQueue(final UUID tenantId, final String url, final NotificationJson notificationJson, final int attemptRetryNumber) {
+ private void saveRetryPushNotificationInQueue(final UUID tenantId, final String url, final NotificationJson notificationJson, final int attemptRetryNumber, final String reason) {
final PushNotificationKey key = new PushNotificationKey(tenantId,
notificationJson.getAccountId(),
notificationJson.getEventType(),
@@ -185,16 +186,16 @@ public class PushNotificationListener {
log.warn("Max attempt number reached for push notification url='{}', tenantId='{}'", key.getUrl(), key.getTenantId());
return;
}
- log.debug("Push notification is scheduled to send at {} for url='{}', tenantId='{}'", nextNotificationTime, key.getUrl(), key.getTenantId());
+ log.warn("Push notification {} is re-scheduled to be sent at {}, url='{}', reason='{}'", key, nextNotificationTime, key.getUrl(), reason);
final Long accountRecordId = internalCallContextFactory.getRecordIdFromObject(key.getAccountId(), ObjectType.ACCOUNT, tenantContext);
final Long tenantRecordId = internalCallContextFactory.getRecordIdFromObject(key.getTenantId(), ObjectType.TENANT, tenantContext);
try {
final NotificationQueue notificationQueue = notificationQueueService.getNotificationQueue(DefaultServerService.SERVER_SERVICE, PushNotificationRetryService.QUEUE_NAME);
notificationQueue.recordFutureNotification(nextNotificationTime, key, null, MoreObjects.firstNonNull(accountRecordId, new Long(0)), tenantRecordId);
- } catch (NoSuchNotificationQueue noSuchNotificationQueue) {
+ } catch (final NoSuchNotificationQueue noSuchNotificationQueue) {
log.error("Failed to push notification url='{}', tenantId='{}'", key.getUrl(), key.getTenantId(), noSuchNotificationQueue);
- } catch (IOException e) {
+ } catch (final IOException e) {
log.error("Failed to push notification url='{}', tenantId='{}'", key.getUrl(), key.getTenantId(), e);
}
}
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestEntitlement.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestEntitlement.java
index 70e36d8..8db8c4c 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestEntitlement.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestEntitlement.java
@@ -90,6 +90,10 @@ public class TestEntitlement extends TestJaxrsBase {
entitlementJson.setPriceOverrides(null);
Assert.assertTrue(objFromJson.equals(entitlementJson));
+ // Change the clock otherwise the CREATE event might be replaced (instead of having a CHANGE event)
+ clock.addDays(1);
+ callbackServlet.assertListenerStatus();
+
// Change plan IMM
final String newProductName = "Assault-Rifle";
@@ -110,7 +114,7 @@ public class TestEntitlement extends TestJaxrsBase {
ExtBusEventType.INVOICE_CREATION,
ExtBusEventType.INVOICE_PAYMENT_SUCCESS,
ExtBusEventType.PAYMENT_SUCCESS);
- clock.addDays(31);
+ clock.addDays(30);
callbackServlet.assertListenerStatus();
// Cancel IMM (Billing EOT)
@@ -267,7 +271,9 @@ public class TestEntitlement extends TestJaxrsBase {
ExtBusEventType.ENTITLEMENT_CREATION,
ExtBusEventType.SUBSCRIPTION_CREATION,
ExtBusEventType.SUBSCRIPTION_CREATION,
- ExtBusEventType.INVOICE_CREATION);
+ ExtBusEventType.INVOICE_CREATION,
+ ExtBusEventType.INVOICE_PAYMENT_SUCCESS,
+ ExtBusEventType.PAYMENT_SUCCESS);
final Subscription subscription = subscriptionApi.createSubscription(input, null, null, null, null, null, true, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, NULL_PLUGIN_PROPERTIES, requestOptions);
callbackServlet.assertListenerStatus();
Assert.assertEquals(subscription.getPriceOverrides().size(), 2);