Improved tests.
This commit is contained in:
parent
ae0a155a39
commit
7d7e524385
|
@ -61,7 +61,7 @@ public class ClientUsageTest
|
|||
// Then issue another similar request
|
||||
stream.getSession().syn(new SynInfo(true), this);
|
||||
}
|
||||
}).get();
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
// Send-and-forget the data
|
||||
stream.data(new StringDataInfo("data", true));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.eclipse.jetty.spdy.http;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -85,7 +86,7 @@ public abstract class AbstractHTTPSPDYTest
|
|||
clientFactory = newSPDYClientFactory(threadPool);
|
||||
clientFactory.start();
|
||||
}
|
||||
return clientFactory.newSPDYClient(SPDY.V2).connect(socketAddress, listener).get();
|
||||
return clientFactory.newSPDYClient(SPDY.V2).connect(socketAddress, listener).get(5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
protected SPDYClient.Factory newSPDYClientFactory(Executor threadPool)
|
||||
|
|
|
@ -206,7 +206,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
|||
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
|
||||
replyLatch.countDown();
|
||||
}
|
||||
}).get();
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
stream.data(new StringDataInfo(data, true));
|
||||
|
||||
Assert.assertTrue(handlerLatch.await(5, TimeUnit.SECONDS));
|
||||
|
@ -251,7 +251,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
|||
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
|
||||
replyLatch.countDown();
|
||||
}
|
||||
}).get();
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
// Sleep between the data frames so that they will be read in 2 reads
|
||||
stream.data(new StringDataInfo(data1, false));
|
||||
Thread.sleep(1000);
|
||||
|
@ -299,7 +299,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest
|
|||
Assert.assertTrue(replyHeaders.get("status").value().contains("200"));
|
||||
replyLatch.countDown();
|
||||
}
|
||||
}).get();
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
// Send the data frames consecutively, so the server reads both frames in one read
|
||||
stream.data(new StringDataInfo(data1, false));
|
||||
stream.data(new StringDataInfo(data2, true));
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.eclipse.jetty.spdy;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
|
@ -74,7 +75,7 @@ public abstract class AbstractTest
|
|||
clientFactory = newSPDYClientFactory(threadPool);
|
||||
clientFactory.start();
|
||||
}
|
||||
return clientFactory.newSPDYClient(SPDY.V2).connect(socketAddress, listener).get();
|
||||
return clientFactory.newSPDYClient(SPDY.V2).connect(socketAddress, listener).get(5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
protected SPDYClient.Factory newSPDYClientFactory(Executor threadPool)
|
||||
|
|
|
@ -96,7 +96,7 @@ public class GoAwayTest extends AbstractTest
|
|||
};
|
||||
Session session = startClient(startServer(serverSessionFrameListener), clientSessionFrameListener);
|
||||
|
||||
Stream stream1 = session.syn(new SynInfo(true), null).get();
|
||||
Stream stream1 = session.syn(new SynInfo(true), null).get(5, TimeUnit.SECONDS);
|
||||
|
||||
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||
GoAwayInfo goAwayInfo = ref.get();
|
||||
|
@ -129,17 +129,15 @@ public class GoAwayTest extends AbstractTest
|
|||
return null;
|
||||
}
|
||||
};
|
||||
final AtomicReference<Session> ref = new AtomicReference<>();
|
||||
SessionFrameListener clientSessionFrameListener = new SessionFrameListener.Adapter()
|
||||
{
|
||||
@Override
|
||||
public void onGoAway(Session session, GoAwayInfo goAwayInfo)
|
||||
{
|
||||
ref.get().syn(new SynInfo(true), null);
|
||||
session.syn(new SynInfo(true), null);
|
||||
}
|
||||
};
|
||||
Session session = startClient(startServer(serverSessionFrameListener), clientSessionFrameListener);
|
||||
ref.set(session);
|
||||
|
||||
session.syn(new SynInfo(true), null);
|
||||
|
||||
|
@ -201,11 +199,11 @@ public class GoAwayTest extends AbstractTest
|
|||
{
|
||||
reply1Latch.countDown();
|
||||
}
|
||||
}).get();
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
Assert.assertTrue(reply1Latch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
// Second stream is closed in the middle
|
||||
Stream stream2 = session.syn(new SynInfo(false), null).get();
|
||||
Stream stream2 = session.syn(new SynInfo(false), null).get(5, TimeUnit.SECONDS);
|
||||
Assert.assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
// There is a race between the data we want to send, and the client
|
||||
|
|
|
@ -173,7 +173,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
SPDYClient client = clientFactory.newSPDYClient(SPDY.V2);
|
||||
long maxIdleTime = 1000;
|
||||
client.setMaxIdleTime(maxIdleTime);
|
||||
Session session = client.connect(address, null).get();
|
||||
Session session = client.connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
|
||||
session.syn(new SynInfo(true), null);
|
||||
|
||||
|
@ -200,7 +200,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
SPDYClient client = clientFactory.newSPDYClient(SPDY.V2);
|
||||
long maxIdleTime = 1000;
|
||||
client.setMaxIdleTime(maxIdleTime);
|
||||
Session session = client.connect(address, null).get();
|
||||
Session session = client.connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
|
||||
session.syn(new SynInfo(true), null);
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
clientFactory.start();
|
||||
SPDYClient client = clientFactory.newSPDYClient(SPDY.V2);
|
||||
client.setMaxIdleTime(maxIdleTime);
|
||||
Session session = client.connect(address, null).get();
|
||||
Session session = client.connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
session.syn(new SynInfo(true), new StreamFrameListener.Adapter()
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PingTest extends AbstractTest
|
|||
}
|
||||
};
|
||||
Session session = startClient(startServer(null), clientSessionFrameListener);
|
||||
PingInfo pingInfo = session.ping().get();
|
||||
PingInfo pingInfo = session.ping().get(5, TimeUnit.SECONDS);
|
||||
Assert.assertEquals(1, pingInfo.getPingId() % 2);
|
||||
|
||||
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
|
||||
|
|
|
@ -100,7 +100,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest
|
|||
ExecutorService threadPool = Executors.newFixedThreadPool(count);
|
||||
List<Future<Object>> futures = threadPool.invokeAll(tasks);
|
||||
for (Future<Object> future : futures)
|
||||
future.get();
|
||||
future.get(5, TimeUnit.SECONDS);
|
||||
Assert.assertTrue(latch.await(count * iterations * 100, TimeUnit.MILLISECONDS));
|
||||
threadPool.shutdown();
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class SynDataReplyDataLoadTest extends AbstractTest
|
|||
Assert.assertEquals(0, dataInfo.available());
|
||||
latch.countDown();
|
||||
}
|
||||
}).get();
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
stream.data(new StringDataInfo("data_" + stream.getId(), true));
|
||||
Assert.assertTrue("process() failed for stream=" + stream.getId(), latch.await(5, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue