Tests: adjusted inactive interval in Java app for slow hosts.
This commit is contained in:
@@ -17,7 +17,13 @@ public class app extends HttpServlet
|
|||||||
HttpSession s = request.getSession();
|
HttpSession s = request.getSession();
|
||||||
|
|
||||||
if (s.isNew()) {
|
if (s.isNew()) {
|
||||||
s.setMaxInactiveInterval(2);
|
String interval = request.getHeader("X-Interval");
|
||||||
|
|
||||||
|
if (interval == null) {
|
||||||
|
s.setMaxInactiveInterval(0);
|
||||||
|
} else {
|
||||||
|
s.setMaxInactiveInterval(Integer.parseInt(interval));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response.addHeader("X-Session-Id", s.getId());
|
response.addHeader("X-Session-Id", s.getId());
|
||||||
|
|||||||
@@ -99,12 +99,16 @@ class TestJavaApplication(TestApplicationJava):
|
|||||||
def test_java_application_session_active(self):
|
def test_java_application_session_active(self):
|
||||||
self.load('session_inactive')
|
self.load('session_inactive')
|
||||||
|
|
||||||
resp = self.get()
|
resp = self.get(headers={
|
||||||
|
'X-Interval': '4',
|
||||||
|
'Host': 'localhost',
|
||||||
|
'Connection': 'close',
|
||||||
|
})
|
||||||
session_id = resp['headers']['X-Session-Id']
|
session_id = resp['headers']['X-Session-Id']
|
||||||
|
|
||||||
self.assertEqual(resp['status'], 200, 'session init')
|
self.assertEqual(resp['status'], 200, 'session init')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
resp['headers']['X-Session-Interval'], '2', 'session interval'
|
resp['headers']['X-Session-Interval'], '4', 'session interval'
|
||||||
)
|
)
|
||||||
self.assertLess(
|
self.assertLess(
|
||||||
abs(
|
abs(
|
||||||
@@ -147,7 +151,7 @@ class TestJavaApplication(TestApplicationJava):
|
|||||||
resp['headers']['X-Session-Id'], session_id, 'session active 2'
|
resp['headers']['X-Session-Id'], session_id, 'session active 2'
|
||||||
)
|
)
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(2)
|
||||||
|
|
||||||
resp = self.get(
|
resp = self.get(
|
||||||
headers={
|
headers={
|
||||||
@@ -164,7 +168,11 @@ class TestJavaApplication(TestApplicationJava):
|
|||||||
def test_java_application_session_inactive(self):
|
def test_java_application_session_inactive(self):
|
||||||
self.load('session_inactive')
|
self.load('session_inactive')
|
||||||
|
|
||||||
resp = self.get()
|
resp = self.get(headers={
|
||||||
|
'X-Interval': '1',
|
||||||
|
'Host': 'localhost',
|
||||||
|
'Connection': 'close',
|
||||||
|
})
|
||||||
session_id = resp['headers']['X-Session-Id']
|
session_id = resp['headers']['X-Session-Id']
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|||||||
Reference in New Issue
Block a user