Browse Source

Fixed edge client tests by setting correctly max inbound message size

pull/8340/head
Volodymyr Babak 3 years ago
parent
commit
c95cff74f7
  1. 6
      application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
  2. 1
      application/src/main/resources/thingsboard.yml
  3. 11
      application/src/test/java/org/thingsboard/server/edge/imitator/EdgeImitator.java
  4. 6
      common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java
  5. 4
      common/edge-api/src/main/proto/edge.proto

6
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java

@ -134,8 +134,10 @@ public final class EdgeGrpcSession implements Closeable {
if (ConnectResponseCode.ACCEPTED != responseMsg.getResponseCode()) {
outputStream.onError(new RuntimeException(responseMsg.getErrorMsg()));
} else {
log.debug("[{}] Client max inbound message size: {}", sessionId, requestMsg.getConnectRequestMsg().getMaxInboundMessageSize());
clientMaxInboundMessageSize = requestMsg.getConnectRequestMsg().getMaxInboundMessageSize();
if (requestMsg.getConnectRequestMsg().hasMaxInboundMessageSize()) {
log.debug("[{}] Client max inbound message size: {}", sessionId, requestMsg.getConnectRequestMsg().getMaxInboundMessageSize());
clientMaxInboundMessageSize = requestMsg.getConnectRequestMsg().getMaxInboundMessageSize();
}
connected = true;
}
}

1
application/src/main/resources/thingsboard.yml

@ -960,7 +960,6 @@ edges:
scheduler_pool_size: "${EDGES_SCHEDULER_POOL_SIZE:1}"
send_scheduler_pool_size: "${EDGES_SEND_SCHEDULER_POOL_SIZE:1}"
grpc_callback_thread_pool_size: "${EDGES_GRPC_CALLBACK_POOL_SIZE:1}"
edge_events_ttl: "${EDGES_EDGE_EVENTS_TTL:0}"
state:
persistToTelemetry: "${EDGES_PERSIST_STATE_TO_TELEMETRY:false}"

11
application/src/test/java/org/thingsboard/server/edge/imitator/EdgeImitator.java

@ -104,13 +104,14 @@ public class EdgeImitator {
ignoredTypes = new ArrayList<>();
this.routingKey = routingKey;
this.routingSecret = routingSecret;
setEdgeCredentials("rpcHost", host);
setEdgeCredentials("rpcPort", port);
setEdgeCredentials("timeoutSecs", 3);
setEdgeCredentials("keepAliveTimeSec", 300);
updateEdgeClientFields("rpcHost", host);
updateEdgeClientFields("rpcPort", port);
updateEdgeClientFields("timeoutSecs", 3);
updateEdgeClientFields("keepAliveTimeSec", 300);
updateEdgeClientFields("maxInboundMessageSize", 4194304);
}
private void setEdgeCredentials(String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
private void updateEdgeClientFields(String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
Field fieldToSet = edgeRpcClient.getClass().getDeclaredField(fieldName);
fieldToSet.setAccessible(true);
fieldToSet.set(edgeRpcClient, value);

6
common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

@ -124,8 +124,10 @@ public class EdgeGrpcClient implements EdgeRpcClient {
if (responseMsg.hasConnectResponseMsg()) {
ConnectResponseMsg connectResponseMsg = responseMsg.getConnectResponseMsg();
if (connectResponseMsg.getResponseCode().equals(ConnectResponseCode.ACCEPTED)) {
log.debug("[{}] Server max inbound message size: {}", edgeKey, connectResponseMsg.getMaxInboundMessageSize());
serverMaxInboundMessageSize = connectResponseMsg.getMaxInboundMessageSize();
if (connectResponseMsg.hasMaxInboundMessageSize()) {
log.debug("[{}] Server max inbound message size: {}", edgeKey, connectResponseMsg.getMaxInboundMessageSize());
serverMaxInboundMessageSize = connectResponseMsg.getMaxInboundMessageSize();
}
log.info("[{}] Configuration received: {}", edgeKey, connectResponseMsg.getConfiguration());
onEdgeUpdate.accept(connectResponseMsg.getConfiguration());
} else {

4
common/edge-api/src/main/proto/edge.proto

@ -68,7 +68,7 @@ message ConnectRequestMsg {
string edgeRoutingKey = 1;
string edgeSecret = 2;
EdgeVersion edgeVersion = 3;
int32 maxInboundMessageSize = 4;
optional int32 maxInboundMessageSize = 4;
}
enum ConnectResponseCode {
@ -81,7 +81,7 @@ message ConnectResponseMsg {
ConnectResponseCode responseCode = 1;
string errorMsg = 2;
EdgeConfiguration configuration = 3;
int32 maxInboundMessageSize = 4;
optional int32 maxInboundMessageSize = 4;
}
message SyncRequestMsg {

Loading…
Cancel
Save