Browse Source

Merge branch 'fix/edge-event-check-lost-on-reconnect-lts-4.2' into fix/edge-event-check-lost-on-reconnect-lts-4.3

# Conflicts:
#	application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java
pull/16093/head
Nikita Mazurenko 1 month ago
parent
commit
653fb3ba7d
  1. 17
      application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceReconnectTest.java
  2. 15
      application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java

17
application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceReconnectTest.java

@ -1,18 +1,5 @@
/**
* Copyright © 2016-2026 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.
*/
// SPDX-FileCopyrightText: Copyright The Thingsboard Authors
// SPDX-License-Identifier: Apache-2.0
package org.thingsboard.server.service.edge.rpc;
import com.google.common.util.concurrent.Futures;

15
application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java

@ -199,17 +199,14 @@ public class EdgeGrpcServiceTest {
@Test
public void givenSessionReplacedDuringDisconnect_whenStaleCallbackRuns_thenLiveSessionKept() {
// Reproduces the get()/remove() interleaving on a single node: onEdgeConnect swaps in a new session
// right after the stale callback's id check passes. The stale callback must not evict or tear down
// the live session, nor clear the activity state.
// onEdgeConnect has already swapped in a new session on this node when the stale callback runs.
// The check-and-remove is a single atomic step against the same map that onEdgeConnect writes
// through, so the swap can only land before or after it. The stale callback must not evict or
// tear down the live session, nor clear the activity state.
UUID staleSessionId = UUID.randomUUID();
EdgeGrpcSession live = mock(EdgeGrpcSession.class);
EdgeGrpcSession stale = mock(EdgeGrpcSession.class);
when(stale.getSessionId()).thenAnswer(invocation -> {
sessions().put(edgeId, live);
return staleSessionId;
});
sessions().put(edgeId, stale);
when(live.getSessionId()).thenReturn(UUID.randomUUID());
sessions().put(edgeId, live);
onEdgeDisconnect(staleSessionId);

Loading…
Cancel
Save