Browse Source

Merge pull request #15022 from thingsboard/fix/flaky-test

Fix flaky tests in TenantProfileControllerTest
pull/15044/head
Viacheslav Klimov 8 months ago
committed by GitHub
parent
commit
474b929954
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java
  2. 17
      application/src/test/java/org/thingsboard/server/controller/TenantProfileControllerTest.java

1
application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java

@ -430,6 +430,7 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID); tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID);
jdbcTemplate.execute("TRUNCATE TABLE notification"); jdbcTemplate.execute("TRUNCATE TABLE notification");
jdbcTemplate.execute("TRUNCATE TABLE audit_log");
log.debug("Executed web test teardown"); log.debug("Executed web test teardown");
} }

17
application/src/test/java/org/thingsboard/server/controller/TenantProfileControllerTest.java

@ -407,20 +407,15 @@ public class TenantProfileControllerTest extends AbstractControllerTest {
testBroadcastEntityStateChangeEventNeverTenantProfile(); testBroadcastEntityStateChangeEventNeverTenantProfile();
} }
private void awaitAuditLog(String awaitMessage, TenantProfileId tenantProfileId, ActionType expectedAction) throws Exception { private void awaitAuditLog(String awaitMessage, TenantProfileId tenantProfileId, ActionType expectedAction) {
Awaitility.await(awaitMessage) Awaitility.await(awaitMessage)
.atMost(TIMEOUT, TimeUnit.SECONDS) .atMost(TIMEOUT, TimeUnit.SECONDS)
.until(() -> .until(() -> doGetTypedWithTimePageLink(
doGetTypedWithTimePageLink( "/api/audit/logs?",
"/api/audit/logs/entity/TENANT_PROFILE/" + tenantProfileId.getId() + "?", new TypeReference<PageData<AuditLog>>() {},
new TypeReference<PageData<AuditLog>>() { new TimePageLink(100)).getData().stream()
}, .anyMatch(log -> log.getEntityId().equals(tenantProfileId) && log.getActionType() == expectedAction)
new TimePageLink(5))
.getData()
.stream()
.anyMatch(log -> log.getActionType() == expectedAction)
); );
} }
private TenantProfile createTenantProfile(String name) { private TenantProfile createTenantProfile(String name) {

Loading…
Cancel
Save