forked from infinispan/infinispan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-16670 Retry server failed on client after timeout
- Loading branch information
Showing
19 changed files
with
214 additions
and
18 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
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
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
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
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
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
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
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
92 changes: 92 additions & 0 deletions
92
...hotrod-client/src/test/java/org/infinispan/client/hotrod/BasicClientIntelligenceTest.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,92 @@ | ||
package org.infinispan.client.hotrod; | ||
|
||
import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.withRemoteCacheManager; | ||
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration; | ||
import static org.testng.AssertJUnit.assertFalse; | ||
|
||
import org.infinispan.client.hotrod.configuration.ClientIntelligence; | ||
import org.infinispan.client.hotrod.exceptions.TransportException; | ||
import org.infinispan.client.hotrod.impl.transport.netty.ChannelFactory; | ||
import org.infinispan.client.hotrod.test.HotRodClientTestingUtil; | ||
import org.infinispan.client.hotrod.test.InternalRemoteCacheManager; | ||
import org.infinispan.client.hotrod.test.MultiHotRodServersTest; | ||
import org.infinispan.client.hotrod.test.RemoteCacheManagerCallable; | ||
import org.infinispan.commons.test.Exceptions; | ||
import org.infinispan.configuration.cache.CacheMode; | ||
import org.infinispan.configuration.cache.ConfigurationBuilder; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "functional", testName = "client.hotrod.BasicClientIntelligenceTest") | ||
public class BasicClientIntelligenceTest extends MultiHotRodServersTest { | ||
private final ConfigurationBuilder builder = hotRodCacheConfiguration( | ||
getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false)); | ||
@Override | ||
protected void createCacheManagers() throws Throwable { | ||
createHotRodServersWithoutClients(2, builder); | ||
} | ||
|
||
public void testOneServerDiedAndComesBack() { | ||
int initialPort = server(1).getPort(); | ||
|
||
org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = | ||
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); | ||
// Retry after every half second to make test faster | ||
clientBuilder.serverFailureTimeout(500); | ||
clientBuilder.addServers(HotRodClientTestingUtil.getServersString(server(0), server(1))); | ||
clientBuilder.clientIntelligence(ClientIntelligence.BASIC); | ||
|
||
withRemoteCacheManager(new RemoteCacheManagerCallable( | ||
new InternalRemoteCacheManager(clientBuilder.build())) { | ||
@Override | ||
public void call() { | ||
RemoteCache<Object, Object> cache = rcm.getCache(); | ||
ChannelFactory cf = rcm.getChannelFactory(); | ||
assertFalse(cache.containsKey("k")); | ||
killServer(1); | ||
eventuallyEquals(1, () -> { | ||
assertFalse(cache.containsKey("k")); | ||
return cf.getFailedServers().size(); | ||
}); | ||
|
||
addHotRodServer(builder, initialPort); | ||
|
||
eventuallyEquals(0, () -> { | ||
assertFalse(cache.containsKey("k")); | ||
return cf.getFailedServers().size(); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
public void testBasicHasSingleServerThatDied() { | ||
int initialPort = server(1).getPort(); | ||
|
||
org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = | ||
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); | ||
clientBuilder.serverFailureTimeout(500); | ||
clientBuilder.addServers(HotRodClientTestingUtil.getServersString(server(1))); | ||
clientBuilder.clientIntelligence(ClientIntelligence.BASIC); | ||
|
||
withRemoteCacheManager(new RemoteCacheManagerCallable( | ||
new InternalRemoteCacheManager(clientBuilder.build())) { | ||
@Override | ||
public void call() { | ||
RemoteCache<Object, Object> cache = rcm.getCache(); | ||
ChannelFactory cf = rcm.getChannelFactory(); | ||
assertFalse(cache.containsKey("k")); | ||
killServer(1); | ||
for (int i = 0; i < 10; i++) { | ||
Exceptions.expectException(TransportException.class, () -> cache.containsKey("k")); | ||
} | ||
eventuallyEquals(1, () -> cf.getFailedServers().size()); | ||
|
||
addHotRodServer(builder, initialPort); | ||
|
||
eventuallyEquals(0, () -> { | ||
assertFalse(cache.containsKey("k")); | ||
return cf.getFailedServers().size(); | ||
}); | ||
} | ||
}); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.