Pause before checking session eviction (#9893)
* Pause before checking session eviction * Change after review
This commit is contained in:
parent
69964468bb
commit
9e4dc46a3e
|
@ -135,8 +135,11 @@ public class AsyncTest
|
|||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
|
||||
//session should now be evicted from the cache after request exited
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionCache().getSessionDataStore().exists(id));
|
||||
Awaitility.await().atMost(30, TimeUnit.SECONDS)
|
||||
.until(() -> !contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -185,6 +188,8 @@ public class AsyncTest
|
|||
|
||||
//session should now be evicted from the cache after request exited
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
Awaitility.await().atMost(30, TimeUnit.SECONDS)
|
||||
.until(() -> !contextB.getSessionHandler().getSessionCache().contains(id));
|
||||
assertFalse(contextB.getSessionHandler().getSessionCache().contains(id));
|
||||
assertTrue(contextB.getSessionHandler().getSessionCache().getSessionDataStore().exists(id));
|
||||
}
|
||||
|
@ -231,6 +236,8 @@ public class AsyncTest
|
|||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
|
||||
//session should now be evicted from the cache after request exited
|
||||
Awaitility.await().atMost(30, TimeUnit.SECONDS)
|
||||
.until(() -> !contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionCache().getSessionDataStore().exists(id));
|
||||
}
|
||||
|
@ -283,7 +290,8 @@ public class AsyncTest
|
|||
|
||||
//session should now be evicted from the cache A after request exited
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
assertFalse(contextA.getSessionHandler().getSessionCache().contains(id));
|
||||
Awaitility.await().atMost(30, TimeUnit.SECONDS)
|
||||
.until(() -> !contextA.getSessionHandler().getSessionCache().contains(id));
|
||||
assertTrue(contextA.getSessionHandler().getSessionCache().getSessionDataStore().exists(id));
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.ee10.session;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
@ -24,6 +25,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpSessionEvent;
|
||||
import jakarta.servlet.http.HttpSessionListener;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.eclipse.jetty.client.ContentResponse;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.Request;
|
||||
|
@ -146,8 +148,8 @@ public class CreationTest
|
|||
|
||||
//session should now be evicted from the cache
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionCache().getSessionDataStore().exists(id));
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
|
||||
//make another request for the same session
|
||||
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping + "?action=test");
|
||||
|
@ -155,7 +157,7 @@ public class CreationTest
|
|||
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
|
||||
|
||||
//session should now be evicted from the cache again
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionCache().contains(SessionTestSupport.extractSessionId(sessionCookie)));
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionCache().contains(id));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -75,8 +75,9 @@ public class SameContextForwardedSessionTest
|
|||
assertNotNull(sessionCookie);
|
||||
|
||||
//test that the session was created, and that it contains the attributes from servlet3 and servlet1
|
||||
testServletContextHandler.getSessionHandler().getSessionCache().contains(SessionTestSupport.extractSessionId(sessionCookie));
|
||||
testServletContextHandler.getSessionHandler().getSessionCache().getSessionDataStore().exists(SessionTestSupport.extractSessionId(sessionCookie));
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
testServletContextHandler.getSessionHandler().getSessionCache().contains(id);
|
||||
testServletContextHandler.getSessionHandler().getSessionCache().getSessionDataStore().exists(id);
|
||||
|
||||
//Make a fresh request
|
||||
Request request = client.newRequest("http://localhost:" + serverPort + "/context/four");
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.ee9.session;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
@ -24,6 +25,7 @@ import jakarta.servlet.http.HttpServlet;
|
|||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.eclipse.jetty.client.ContentResponse;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
|
||||
|
@ -87,8 +89,8 @@ public class AsyncTest
|
|||
|
||||
//session should now be evicted from the cache after request exited
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id));
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -132,8 +134,9 @@ public class AsyncTest
|
|||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
|
||||
//session should now be evicted from the cache after request exited
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id));
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -182,6 +185,7 @@ public class AsyncTest
|
|||
|
||||
//session should now be evicted from the cache after request exited
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextB.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertFalse(contextB.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertTrue(contextB.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id));
|
||||
}
|
||||
|
@ -228,6 +232,7 @@ public class AsyncTest
|
|||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
|
||||
//session should now be evicted from the cache after request exited
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id));
|
||||
}
|
||||
|
@ -280,6 +285,7 @@ public class AsyncTest
|
|||
|
||||
//session should now be evicted from the cache A after request exited
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextA.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertFalse(contextA.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertTrue(contextA.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id));
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.ee9.session;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
@ -24,6 +25,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpSessionEvent;
|
||||
import jakarta.servlet.http.HttpSessionListener;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.eclipse.jetty.client.ContentResponse;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.client.Request;
|
||||
|
@ -144,8 +146,8 @@ public class CreationTest
|
|||
|
||||
//session should now be evicted from the cache
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
assertTrue(contextHandler.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id));
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
|
||||
//make another request for the same session
|
||||
Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping + "?action=test");
|
||||
|
@ -153,7 +155,7 @@ public class CreationTest
|
|||
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
|
||||
|
||||
//session should now be evicted from the cache again
|
||||
assertFalse(contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(SessionTestSupport.extractSessionId(sessionCookie)));
|
||||
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(() -> !contextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -76,8 +76,9 @@ public class SameContextForwardedSessionTest
|
|||
assertNotNull(sessionCookie);
|
||||
|
||||
//test that the session was created, and that it contains the attributes from servlet3 and servlet1
|
||||
testServletContextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(SessionTestSupport.extractSessionId(sessionCookie));
|
||||
testServletContextHandler.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(SessionTestSupport.extractSessionId(sessionCookie));
|
||||
String id = SessionTestSupport.extractSessionId(sessionCookie);
|
||||
testServletContextHandler.getSessionHandler().getSessionManager().getSessionCache().contains(id);
|
||||
testServletContextHandler.getSessionHandler().getSessionManager().getSessionCache().getSessionDataStore().exists(id);
|
||||
|
||||
//Make a fresh request
|
||||
Request request = client.newRequest("http://localhost:" + serverPort + "/context/four");
|
||||
|
|
Loading…
Reference in New Issue