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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
11 deletions
-
application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java
-
application/src/test/java/org/thingsboard/server/controller/TenantProfileControllerTest.java
|
|
|
@ -430,6 +430,7 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest { |
|
|
|
tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID); |
|
|
|
|
|
|
|
jdbcTemplate.execute("TRUNCATE TABLE notification"); |
|
|
|
jdbcTemplate.execute("TRUNCATE TABLE audit_log"); |
|
|
|
|
|
|
|
log.debug("Executed web test teardown"); |
|
|
|
} |
|
|
|
|
|
|
|
@ -407,20 +407,15 @@ public class TenantProfileControllerTest extends AbstractControllerTest { |
|
|
|
testBroadcastEntityStateChangeEventNeverTenantProfile(); |
|
|
|
} |
|
|
|
|
|
|
|
private void awaitAuditLog(String awaitMessage, TenantProfileId tenantProfileId, ActionType expectedAction) throws Exception { |
|
|
|
private void awaitAuditLog(String awaitMessage, TenantProfileId tenantProfileId, ActionType expectedAction) { |
|
|
|
Awaitility.await(awaitMessage) |
|
|
|
.atMost(TIMEOUT, TimeUnit.SECONDS) |
|
|
|
.until(() -> |
|
|
|
doGetTypedWithTimePageLink( |
|
|
|
"/api/audit/logs/entity/TENANT_PROFILE/" + tenantProfileId.getId() + "?", |
|
|
|
new TypeReference<PageData<AuditLog>>() { |
|
|
|
}, |
|
|
|
new TimePageLink(5)) |
|
|
|
.getData() |
|
|
|
.stream() |
|
|
|
.anyMatch(log -> log.getActionType() == expectedAction) |
|
|
|
.until(() -> doGetTypedWithTimePageLink( |
|
|
|
"/api/audit/logs?", |
|
|
|
new TypeReference<PageData<AuditLog>>() {}, |
|
|
|
new TimePageLink(100)).getData().stream() |
|
|
|
.anyMatch(log -> log.getEntityId().equals(tenantProfileId) && log.getActionType() == expectedAction) |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private TenantProfile createTenantProfile(String name) { |
|
|
|
|