|
|
|
@ -420,11 +420,11 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest { |
|
|
|
notificationRulesCache.evict(TenantId.SYS_TENANT_ID); |
|
|
|
|
|
|
|
int n = 10; |
|
|
|
updateDefaultTenantProfile(profileConfiguration -> { |
|
|
|
profileConfiguration.getProfileConfiguration().get().setTenantEntityExportRateLimit(n + ":600"); |
|
|
|
profileConfiguration.getProfileConfiguration().get().setCustomerServerRestLimitsConfiguration(n + ":600"); |
|
|
|
profileConfiguration.getProfileConfiguration().get().setTenantNotificationRequestsPerRuleRateLimit(n + ":600"); |
|
|
|
profileConfiguration.getProfileConfiguration().get().setTransportDeviceTelemetryMsgRateLimit(n + ":600"); |
|
|
|
updateDefaultTenantProfileConfig(profileConfiguration -> { |
|
|
|
profileConfiguration.setTenantEntityExportRateLimit(n + ":600"); |
|
|
|
profileConfiguration.setCustomerServerRestLimitsConfiguration(n + ":600"); |
|
|
|
profileConfiguration.setTenantNotificationRequestsPerRuleRateLimit(n + ":600"); |
|
|
|
profileConfiguration.setTransportDeviceTelemetryMsgRateLimit(n + ":600"); |
|
|
|
}); |
|
|
|
loginTenantAdmin(); |
|
|
|
NotificationRule rule = createNotificationRule(AlarmCommentNotificationRuleTriggerConfig.builder() |
|
|
|
@ -434,11 +434,14 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest { |
|
|
|
rateLimitService.checkRateLimit(LimitedApi.ENTITY_EXPORT, tenantId); |
|
|
|
rateLimitService.checkRateLimit(LimitedApi.REST_REQUESTS_PER_CUSTOMER, tenantId, customerId); |
|
|
|
rateLimitService.checkRateLimit(LimitedApi.NOTIFICATION_REQUESTS_PER_RULE, tenantId, rule.getId()); |
|
|
|
Thread.sleep(100); |
|
|
|
} |
|
|
|
|
|
|
|
loginTenantAdmin(); |
|
|
|
List<Notification> notifications = await().atMost(30, TimeUnit.SECONDS) |
|
|
|
.until(() -> getMyNotifications(true, 10), list -> list.size() == 3); |
|
|
|
List<Notification> notifications = await().atMost(15, TimeUnit.SECONDS) |
|
|
|
.until(() -> getMyNotifications(true, 10).stream() |
|
|
|
.filter(notification -> notification.getType() == NotificationType.RATE_LIMITS) |
|
|
|
.collect(Collectors.toList()), list -> list.size() == 3); |
|
|
|
assertThat(notifications).allSatisfy(notification -> { |
|
|
|
assertThat(notification.getSubject()).isEqualTo("Rate limits exceeded"); |
|
|
|
}); |
|
|
|
@ -455,12 +458,14 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest { |
|
|
|
}); |
|
|
|
|
|
|
|
loginSysAdmin(); |
|
|
|
notifications = await().atMost(30, TimeUnit.SECONDS) |
|
|
|
.until(() -> getMyNotifications(true, 10), list -> list.size() == 1); |
|
|
|
assertThat(notifications).allSatisfy(notification -> { |
|
|
|
notifications = await().atMost(15, TimeUnit.SECONDS) |
|
|
|
.until(() -> getMyNotifications(true, 10).stream() |
|
|
|
.filter(notification -> notification.getType() == NotificationType.RATE_LIMITS) |
|
|
|
.collect(Collectors.toList()), list -> list.size() == 1); |
|
|
|
assertThat(notifications).singleElement().satisfies(notification -> { |
|
|
|
assertThat(notification.getSubject()).isEqualTo("Rate limits exceeded for tenant " + TEST_TENANT_NAME); |
|
|
|
assertThat(notification.getText()).isEqualTo("Rate limits for entity version creation exceeded"); |
|
|
|
}); |
|
|
|
assertThat(notifications.get(0).getText()).isEqualTo("Rate limits for entity version creation exceeded"); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
|