Skip to content

Commit

Permalink
TEIID-5054 fixing failing ping test
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 6, 2017
1 parent aacbfb8 commit 92d1483
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Expand Up @@ -217,7 +217,11 @@ public static void updateConnectionProperties(Properties connectionProperties, I
String address = addr.getHostAddress();
Object old = connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, address);
if (old == null || !address.equals(old)) {
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName());
if (addr.isLoopbackAddress()) {
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName());
} else {
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, "localhost"); //$NON-NLS-1$
}
if (setMac) {
try {
NetworkInterface ni = NetworkInterface.getByInetAddress(addr);
Expand Down
30 changes: 23 additions & 7 deletions runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Expand Up @@ -30,6 +30,10 @@
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.net.ssl.SSLContext;

Expand Down Expand Up @@ -359,20 +363,32 @@ private void helpTestNewInstance(Properties p)
helpEstablishConnection(true, config, p);
}

@Test(timeout=19000) public void testAutoFailoverPing() throws Exception {
@Test public void testAutoFailoverPing() throws Exception {
Properties p = new Properties();
p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, "true");
p.setProperty("org.teiid.sockets.synchronousttl", "20000");
SocketServerConnection conn = helpEstablishConnection(false, new SSLConfiguration(), p);
final FakeService fs = conn.getService(FakeService.class);
ResultsFuture<Integer> future = fs.delayedAsynchResult();
future.addCompletionListener(new CompletionListener<Integer>() {
ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
Future<?> future = exec.submit(new Runnable() {
@Override
public void onCompletion(ResultsFuture<Integer> future) {
fs.asynchResult(); //potentially recurrent;
public void run() {
final FakeService fs = conn.getService(FakeService.class);
ResultsFuture<Integer> f = fs.delayedAsynchResult();
f.addCompletionListener(new CompletionListener<Integer>() {
@Override
public void onCompletion(ResultsFuture<Integer> future) {
fs.asynchResult(); //potentially recurrent;
}
});
try {
f.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
future.get();
future.get(19, TimeUnit.SECONDS);
}

}

0 comments on commit 92d1483

Please sign in to comment.