Fix testNotificationRuleProcessing_exceededRateLimits
This commit is contained in:
parent
be7854fb5b
commit
23cd7f0865
@ -420,11 +420,11 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
|
|||||||
notificationRulesCache.evict(TenantId.SYS_TENANT_ID);
|
notificationRulesCache.evict(TenantId.SYS_TENANT_ID);
|
||||||
|
|
||||||
int n = 10;
|
int n = 10;
|
||||||
updateDefaultTenantProfile(profileConfiguration -> {
|
updateDefaultTenantProfileConfig(profileConfiguration -> {
|
||||||
profileConfiguration.getProfileConfiguration().get().setTenantEntityExportRateLimit(n + ":600");
|
profileConfiguration.setTenantEntityExportRateLimit(n + ":600");
|
||||||
profileConfiguration.getProfileConfiguration().get().setCustomerServerRestLimitsConfiguration(n + ":600");
|
profileConfiguration.setCustomerServerRestLimitsConfiguration(n + ":600");
|
||||||
profileConfiguration.getProfileConfiguration().get().setTenantNotificationRequestsPerRuleRateLimit(n + ":600");
|
profileConfiguration.setTenantNotificationRequestsPerRuleRateLimit(n + ":600");
|
||||||
profileConfiguration.getProfileConfiguration().get().setTransportDeviceTelemetryMsgRateLimit(n + ":600");
|
profileConfiguration.setTransportDeviceTelemetryMsgRateLimit(n + ":600");
|
||||||
});
|
});
|
||||||
loginTenantAdmin();
|
loginTenantAdmin();
|
||||||
NotificationRule rule = createNotificationRule(AlarmCommentNotificationRuleTriggerConfig.builder()
|
NotificationRule rule = createNotificationRule(AlarmCommentNotificationRuleTriggerConfig.builder()
|
||||||
@ -434,11 +434,14 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
|
|||||||
rateLimitService.checkRateLimit(LimitedApi.ENTITY_EXPORT, tenantId);
|
rateLimitService.checkRateLimit(LimitedApi.ENTITY_EXPORT, tenantId);
|
||||||
rateLimitService.checkRateLimit(LimitedApi.REST_REQUESTS_PER_CUSTOMER, tenantId, customerId);
|
rateLimitService.checkRateLimit(LimitedApi.REST_REQUESTS_PER_CUSTOMER, tenantId, customerId);
|
||||||
rateLimitService.checkRateLimit(LimitedApi.NOTIFICATION_REQUESTS_PER_RULE, tenantId, rule.getId());
|
rateLimitService.checkRateLimit(LimitedApi.NOTIFICATION_REQUESTS_PER_RULE, tenantId, rule.getId());
|
||||||
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
loginTenantAdmin();
|
loginTenantAdmin();
|
||||||
List<Notification> notifications = await().atMost(30, TimeUnit.SECONDS)
|
List<Notification> notifications = await().atMost(15, TimeUnit.SECONDS)
|
||||||
.until(() -> getMyNotifications(true, 10), list -> list.size() == 3);
|
.until(() -> getMyNotifications(true, 10).stream()
|
||||||
|
.filter(notification -> notification.getType() == NotificationType.RATE_LIMITS)
|
||||||
|
.collect(Collectors.toList()), list -> list.size() == 3);
|
||||||
assertThat(notifications).allSatisfy(notification -> {
|
assertThat(notifications).allSatisfy(notification -> {
|
||||||
assertThat(notification.getSubject()).isEqualTo("Rate limits exceeded");
|
assertThat(notification.getSubject()).isEqualTo("Rate limits exceeded");
|
||||||
});
|
});
|
||||||
@ -455,12 +458,14 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
loginSysAdmin();
|
loginSysAdmin();
|
||||||
notifications = await().atMost(30, TimeUnit.SECONDS)
|
notifications = await().atMost(15, TimeUnit.SECONDS)
|
||||||
.until(() -> getMyNotifications(true, 10), list -> list.size() == 1);
|
.until(() -> getMyNotifications(true, 10).stream()
|
||||||
assertThat(notifications).allSatisfy(notification -> {
|
.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.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
|
@Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user