From bda1e7c4bfd049eea55ec37cd4c831fe0b6e655d Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Mon, 25 May 2020 18:25:36 +0300 Subject: [PATCH 1/3] Removed deprecated tests --- .../rules/RuleEngineNoSqlTestSuite.java | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 application/src/test/java/org/thingsboard/server/rules/RuleEngineNoSqlTestSuite.java diff --git a/application/src/test/java/org/thingsboard/server/rules/RuleEngineNoSqlTestSuite.java b/application/src/test/java/org/thingsboard/server/rules/RuleEngineNoSqlTestSuite.java deleted file mode 100644 index e4f4898eb7..0000000000 --- a/application/src/test/java/org/thingsboard/server/rules/RuleEngineNoSqlTestSuite.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright © 2016-2020 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.thingsboard.server.rules; - -import org.cassandraunit.dataset.cql.ClassPathCQLDataSet; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.extensions.cpsuite.ClasspathSuite; -import org.junit.runner.RunWith; -import org.thingsboard.server.dao.CustomCassandraCQLUnit; -import org.thingsboard.server.dao.CustomSqlUnit; -import org.thingsboard.server.queue.memory.InMemoryStorage; - -import java.util.Arrays; - -@RunWith(ClasspathSuite.class) -@ClasspathSuite.ClassnameFilters({ - "org.thingsboard.server.rules.flow.nosql.*Test", -// "org.thingsboard.server.rules.lifecycle.nosql.*Test" -}) -public class RuleEngineNoSqlTestSuite { - - @ClassRule - public static CustomCassandraCQLUnit cassandraUnit = - new CustomCassandraCQLUnit( - Arrays.asList( - new ClassPathCQLDataSet("cassandra/schema-ts.cql", false, false), - new ClassPathCQLDataSet("cassandra/schema-entities.cql", false, false), - new ClassPathCQLDataSet("cassandra/system-data.cql", false, false)), - "cassandra-test.yaml", 30000l); - - @BeforeClass - public static void cleanupInMemStorage(){ - InMemoryStorage.getInstance().cleanup(); - } - -} From 28f1993a7c8a7e4d914457e8606139b93461d459 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Mon, 25 May 2020 19:21:46 +0300 Subject: [PATCH 2/3] Fix black-box tests --- .../java/org/thingsboard/server/msa/ContainerTestSuite.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java index 17d942a835..647c8878b7 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java @@ -46,7 +46,8 @@ public class ContainerTestSuite { testContainer = new DockerComposeContainer( new File("./../../docker/docker-compose.yml"), new File("./../../docker/docker-compose.postgres.yml"), - new File("./../../docker/docker-compose.postgres.volumes.yml")) + new File("./../../docker/docker-compose.postgres.volumes.yml"), + new File("./../../docker/docker-compose.kafka.yml")) .withPull(false) .withLocalCompose(true) .withTailChildContainers(!skipTailChildContainers) From e823dfb85d5d13cc47b8fb09ac33a69eff5f2d3b Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Tue, 26 May 2020 12:24:03 +0300 Subject: [PATCH 3/3] Min RPC timeout --- .../server/controller/RpcController.java | 13 ++++++++++--- application/src/main/resources/thingsboard.yml | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/RpcController.java b/application/src/main/java/org/thingsboard/server/controller/RpcController.java index b88c3f3695..7cba22b836 100644 --- a/application/src/main/java/org/thingsboard/server/controller/RpcController.java +++ b/application/src/main/java/org/thingsboard/server/controller/RpcController.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.util.concurrent.FutureCallback; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -65,7 +66,6 @@ import java.util.UUID; @Slf4j public class RpcController extends BaseController { - public static final int DEFAULT_TIMEOUT = 10000; protected final ObjectMapper jsonMapper = new ObjectMapper(); @Autowired @@ -74,6 +74,12 @@ public class RpcController extends BaseController { @Autowired private AccessValidator accessValidator; + @Value("${server.rest.server_side_rpc.min_timeout:5000}") + private long minTimeout; + + @Value("${server.rest.server_side_rpc.default_timeout:10000}") + private long defaultTimeout; + @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") @RequestMapping(value = "/oneway/{deviceId}", method = RequestMethod.POST) @ResponseBody @@ -100,7 +106,8 @@ public class RpcController extends BaseController { SecurityUser currentUser = getCurrentUser(); TenantId tenantId = currentUser.getTenantId(); final DeferredResult response = new DeferredResult<>(); - long timeout = System.currentTimeMillis() + (cmd.getTimeout() != null ? cmd.getTimeout() : DEFAULT_TIMEOUT); + long timeout = cmd.getTimeout() != null ? cmd.getTimeout() : defaultTimeout; + long expTime = System.currentTimeMillis() + Math.max(minTimeout, timeout); ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(cmd.getMethodName(), cmd.getRequestData()); accessValidator.validate(currentUser, Operation.RPC_CALL, deviceId, new HttpValidationCallback(response, new FutureCallback>() { @Override @@ -109,7 +116,7 @@ public class RpcController extends BaseController { tenantId, deviceId, oneWay, - timeout, + expTime, body ); deviceRpcService.processRestApiRpcRequest(rpcRequest, fromDeviceRpcResponse -> reply(new LocalRequestMetaData(rpcRequest, currentUser, result), fromDeviceRpcResponse)); diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index fa0b3e3102..608ecdefc9 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -54,6 +54,13 @@ server: customer: enabled: "${TB_SERVER_REST_LIMITS_CUSTOMER_ENABLED:false}" configuration: "${TB_SERVER_REST_LIMITS_CUSTOMER_CONFIGURATION:50:1,1000:60}" + server_side_rpc: + # Minimum value of the server side RPC timeout. May override value provided in the REST API call. + # Since 2.5 migration to queues, the RPC delay depends on the size of the pending messages in the queue, + # so default UI parameter of 500ms may not be sufficient for loaded environments. + min_timeout: "${MIN_SERVER_SIDE_RPC_TIMEOUT:5000}" + # Default value of the server side RPC timeout. + default_timeout: "${DEFAULT_SERVER_SIDE_RPC_TIMEOUT:10000}" # Zookeeper connection parameters. Used for service discovery. zk: