-
Notifications
You must be signed in to change notification settings - Fork 986
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Master/Slave topology refresh connections are closed after tim…
…eout #723 Lettuce now closes Master/Slave topology refresh connections if connections complete the connect progress after the actual refresh finishes. This could happen if a connection finished its connect (slow connect) after the synchronization timeout and after all topology views were obtained so the process already ran its cleanup.
- Loading branch information
Showing
2 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/test/java/io/lettuce/core/masterslave/ConnectionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2018 the original author or 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 io.lettuce.core.masterslave; | ||
|
||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyZeroInteractions; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.Collections; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import reactor.util.function.Tuples; | ||
import io.lettuce.core.RedisURI; | ||
import io.lettuce.core.api.StatefulRedisConnection; | ||
|
||
/** | ||
* @author Mark Paluch | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class ConnectionsTest { | ||
|
||
@Mock | ||
private StatefulRedisConnection<String, String> connection1; | ||
|
||
@Before | ||
public void before() { | ||
when(connection1.closeAsync()).thenReturn(CompletableFuture.completedFuture(null)); | ||
} | ||
|
||
@Test | ||
public void shouldCloseConnectionCompletingAfterCloseSignal() { | ||
|
||
Connections connections = new Connections(5, Collections.emptyList()); | ||
connections.closeAsync(); | ||
|
||
verifyZeroInteractions(connection1); | ||
|
||
connections.onAccept(Tuples.of(RedisURI.create("localhost", 6379), connection1)); | ||
|
||
verify(connection1).closeAsync(); | ||
} | ||
} |