Issue #11463 Fix flaky session tests
This commit is contained in:
parent
4155e7bc25
commit
313def717c
|
@ -190,7 +190,7 @@ public class DuplicateCookieTest
|
|||
assertEquals("1122", response.getContentAsString());
|
||||
|
||||
//check valid session is drained of requests
|
||||
assertEquals(0, s1122.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1122::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ public class DuplicateCookieTest
|
|||
assertEquals("1122", response.getContentAsString());
|
||||
|
||||
//check valid session drained of requests
|
||||
assertEquals(0, s1122.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1122::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -311,7 +311,7 @@ public class DuplicateCookieTest
|
|||
assertEquals("1122", response.getContentAsString());
|
||||
|
||||
//check valid session drained of requests
|
||||
assertEquals(0, s1122.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1122::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -368,9 +368,9 @@ public class DuplicateCookieTest
|
|||
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
|
||||
|
||||
//check that all sessions have their request counts decremented correctly after the request, back to 0
|
||||
assertEquals(0, s1234.getRequests());
|
||||
assertEquals(0, s5678.getRequests());
|
||||
assertEquals(0, s9111.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1234::getRequests, Matchers.is(0L));
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s5678::getRequests, Matchers.is(0L));
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s9111::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -419,7 +419,7 @@ public class DuplicateCookieTest
|
|||
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
|
||||
|
||||
//check that all valid sessions have their request counts decremented correctly after the request, back to 0
|
||||
assertEquals(0, s1234.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1234::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -42,8 +42,10 @@ import org.eclipse.jetty.session.SessionDataStoreFactory;
|
|||
import org.eclipse.jetty.session.SessionManager;
|
||||
import org.eclipse.jetty.session.test.TestSessionDataStore;
|
||||
import org.eclipse.jetty.session.test.TestSessionDataStoreFactory;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
@ -190,10 +192,10 @@ public class SessionRenewTest
|
|||
ManagedSession sessiona = ((TestSessionCache)contextA.getSessionHandler().getSessionCache()).getWithoutReferenceCount(updatedId);
|
||||
ManagedSession sessionb = ((TestSessionCache)contextB.getSessionHandler().getSessionCache()).getWithoutReferenceCount(updatedId);
|
||||
|
||||
//sessions should nor have any usecounts
|
||||
assertEquals(0, sessiona.getRequests());
|
||||
assertEquals(0, sessionb.getRequests());
|
||||
|
||||
//sessions should nor have any usecounts
|
||||
await().atMost(5, TimeUnit.SECONDS).until(sessiona::getRequests, Matchers.is(0L));
|
||||
await().atMost(5, TimeUnit.SECONDS).until(sessionb::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -52,7 +52,6 @@ public class DuplicateCookieTest
|
|||
{
|
||||
public class TestSession extends ManagedSession
|
||||
{
|
||||
|
||||
public TestSession(SessionManager manager, SessionData data)
|
||||
{
|
||||
super(manager, data);
|
||||
|
@ -66,7 +65,6 @@ public class DuplicateCookieTest
|
|||
|
||||
public class TestSessionCache extends DefaultSessionCache
|
||||
{
|
||||
|
||||
public TestSessionCache(SessionManager manager)
|
||||
{
|
||||
super(manager);
|
||||
|
@ -81,7 +79,6 @@ public class DuplicateCookieTest
|
|||
|
||||
public class TestSessionCacheFactory extends DefaultSessionCacheFactory
|
||||
{
|
||||
|
||||
@Override
|
||||
public SessionCache newSessionCache(SessionManager manager)
|
||||
{
|
||||
|
@ -190,7 +187,7 @@ public class DuplicateCookieTest
|
|||
assertEquals("1122", response.getContentAsString());
|
||||
|
||||
//check valid session is drained of requests
|
||||
assertEquals(0, s1122.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1122::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -251,7 +248,7 @@ public class DuplicateCookieTest
|
|||
assertEquals("1122", response.getContentAsString());
|
||||
|
||||
//check valid session drained of requests
|
||||
assertEquals(0, s1122.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1122::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -311,7 +308,7 @@ public class DuplicateCookieTest
|
|||
assertEquals("1122", response.getContentAsString());
|
||||
|
||||
//check valid session drained of requests
|
||||
assertEquals(0, s1122.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1122::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -368,9 +365,9 @@ public class DuplicateCookieTest
|
|||
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
|
||||
|
||||
//check that all sessions have their request counts decremented correctly after the request, back to 0
|
||||
assertEquals(0, s1234.getRequests());
|
||||
assertEquals(0, s5678.getRequests());
|
||||
assertEquals(0, s9111.getRequests());
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s1234::getRequests, Matchers.is(0L));
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s5678::getRequests, Matchers.is(0L));
|
||||
await().atMost(5, TimeUnit.SECONDS).until(s9111::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -42,8 +42,10 @@ import org.eclipse.jetty.session.SessionDataStoreFactory;
|
|||
import org.eclipse.jetty.session.SessionManager;
|
||||
import org.eclipse.jetty.session.test.TestSessionDataStore;
|
||||
import org.eclipse.jetty.session.test.TestSessionDataStoreFactory;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
@ -192,9 +194,8 @@ public class SessionRenewTest
|
|||
ManagedSession sessionb = ((TestSessionCache)contextB.getSessionHandler().getSessionManager().getSessionCache()).getWithoutReferenceCount(updatedId);
|
||||
|
||||
//sessions should nor have any usecounts
|
||||
assertEquals(0, sessiona.getRequests());
|
||||
assertEquals(0, sessionb.getRequests());
|
||||
|
||||
await().atMost(5, TimeUnit.SECONDS).until(sessiona::getRequests, Matchers.is(0L));
|
||||
await().atMost(5, TimeUnit.SECONDS).until(sessionb::getRequests, Matchers.is(0L));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue