|
|
|
@ -24,11 +24,16 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.thingsboard.server.common.data.EntityInfo; |
|
|
|
import org.thingsboard.server.common.data.Tenant; |
|
|
|
import org.thingsboard.server.common.data.TenantProfile; |
|
|
|
import org.thingsboard.server.common.data.queue.ProcessingStrategy; |
|
|
|
import org.thingsboard.server.common.data.queue.ProcessingStrategyType; |
|
|
|
import org.thingsboard.server.common.data.queue.SubmitStrategy; |
|
|
|
import org.thingsboard.server.common.data.queue.SubmitStrategyType; |
|
|
|
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; |
|
|
|
import org.thingsboard.server.common.data.tenant.profile.TenantProfileData; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.common.data.page.PageData; |
|
|
|
import org.thingsboard.server.common.data.page.PageLink; |
|
|
|
import org.thingsboard.server.common.data.tenant.profile.TenantProfileQueueConfiguration; |
|
|
|
import org.thingsboard.server.dao.tenant.TenantProfileService; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
@ -44,9 +49,6 @@ public abstract class BaseTenantProfileControllerTest extends AbstractController |
|
|
|
private IdComparator<TenantProfile> idComparator = new IdComparator<>(); |
|
|
|
private IdComparator<EntityInfo> tenantProfileInfoIdComparator = new IdComparator<>(); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TenantProfileService tenantProfileService; |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSaveTenantProfile() throws Exception { |
|
|
|
loginSysAdmin(); |
|
|
|
@ -141,6 +143,7 @@ public abstract class BaseTenantProfileControllerTest extends AbstractController |
|
|
|
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); |
|
|
|
TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class); |
|
|
|
savedTenantProfile.setIsolatedTbRuleEngine(true); |
|
|
|
addMainQueueConfig(savedTenantProfile); |
|
|
|
doPost("/api/tenantProfile", savedTenantProfile).andExpect(status().isBadRequest()) |
|
|
|
.andExpect(statusReason(containsString("Can't update isolatedTbRuleEngine property"))); |
|
|
|
} |
|
|
|
@ -295,4 +298,28 @@ public abstract class BaseTenantProfileControllerTest extends AbstractController |
|
|
|
tenantProfile.setIsolatedTbRuleEngine(false); |
|
|
|
return tenantProfile; |
|
|
|
} |
|
|
|
|
|
|
|
private void addMainQueueConfig(TenantProfile tenantProfile) { |
|
|
|
TenantProfileQueueConfiguration mainQueueConfiguration = new TenantProfileQueueConfiguration(); |
|
|
|
mainQueueConfiguration.setName("Main"); |
|
|
|
mainQueueConfiguration.setTopic("tb_rule_engine.main"); |
|
|
|
mainQueueConfiguration.setPollInterval(25); |
|
|
|
mainQueueConfiguration.setPartitions(10); |
|
|
|
mainQueueConfiguration.setConsumerPerPartition(true); |
|
|
|
mainQueueConfiguration.setPackProcessingTimeout(2000); |
|
|
|
SubmitStrategy mainQueueSubmitStrategy = new SubmitStrategy(); |
|
|
|
mainQueueSubmitStrategy.setType(SubmitStrategyType.BURST); |
|
|
|
mainQueueSubmitStrategy.setBatchSize(1000); |
|
|
|
mainQueueConfiguration.setSubmitStrategy(mainQueueSubmitStrategy); |
|
|
|
ProcessingStrategy mainQueueProcessingStrategy = new ProcessingStrategy(); |
|
|
|
mainQueueProcessingStrategy.setType(ProcessingStrategyType.SKIP_ALL_FAILURES); |
|
|
|
mainQueueProcessingStrategy.setRetries(3); |
|
|
|
mainQueueProcessingStrategy.setFailurePercentage(0); |
|
|
|
mainQueueProcessingStrategy.setPauseBetweenRetries(3); |
|
|
|
mainQueueProcessingStrategy.setMaxPauseBetweenRetries(3); |
|
|
|
mainQueueConfiguration.setProcessingStrategy(mainQueueProcessingStrategy); |
|
|
|
TenantProfileData profileData = tenantProfile.getProfileData(); |
|
|
|
profileData.setQueueConfiguration(Collections.singletonList(mainQueueConfiguration)); |
|
|
|
tenantProfile.setProfileData(profileData); |
|
|
|
} |
|
|
|
} |
|
|
|
|