Browse Source

Make tests more stable

pull/12616/head
Andrii Landiak 2 years ago
parent
commit
f7923bc009
  1. 10
      application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java
  2. 1
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/ResourcesShortageNotificationRuleTriggerConfig.java
  3. 2
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java

10
application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java

@ -791,10 +791,9 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
public void testNotificationRuleProcessing_resourcesShortage() throws Exception {
loginSysAdmin();
ResourcesShortageNotificationRuleTriggerConfig triggerConfig = ResourcesShortageNotificationRuleTriggerConfig.builder()
.resource(Resource.CPU.name())
.cpuThreshold(0.01f)
.ramThreshold(0.01f)
.storageThreshold(0.01f)
.ramThreshold(1f)
.storageThreshold(1f)
.build();
createNotificationRule(triggerConfig, "Test", "Test", createNotificationTarget(tenantAdminUserId).getId());
loginTenantAdmin();
@ -805,15 +804,16 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
TimeUnit.SECONDS.sleep(5);
assertThat(getMyNotifications(false, 100)).size().isEqualTo(3);
assertThat(getMyNotifications(false, 100)).size().isOne();
}
@Test
public void testNotificationsDeduplication_resourcesShortage() throws Exception {
loginSysAdmin();
ResourcesShortageNotificationRuleTriggerConfig triggerConfig = ResourcesShortageNotificationRuleTriggerConfig.builder()
.resource(Resource.CPU.name())
.cpuThreshold(0.1f)
.ramThreshold(1f)
.storageThreshold(1f)
.build();
createNotificationRule(triggerConfig, "Test", "Test", createNotificationTarget(tenantAdminUserId).getId());
loginTenantAdmin();

1
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/ResourcesShortageNotificationRuleTriggerConfig.java

@ -32,7 +32,6 @@ public class ResourcesShortageNotificationRuleTriggerConfig implements Notificat
@Serial
private static final long serialVersionUID = 339395299693241424L;
private String resource;
@Max(1)
private float cpuThreshold; // in percents
@Max(1)

2
dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java

@ -382,7 +382,7 @@ public class DefaultNotifications {
.icon("warning")
.rule(DefaultRule.builder()
.name("Resources shortage")
.triggerConfig(ResourcesShortageNotificationRuleTriggerConfig.builder().resource(Resource.CPU.name()).cpuThreshold(0.8f).storageThreshold(0.8f).ramThreshold(0.8f).build())
.triggerConfig(ResourcesShortageNotificationRuleTriggerConfig.builder().cpuThreshold(0.8f).storageThreshold(0.8f).ramThreshold(0.8f).build())
.description("Send notification to system admins when resources shortage is running low")
.build())
.color(RED_COLOR)

Loading…
Cancel
Save