Skip to content

Commit

Permalink
Issue #5684 Reduce intensity and rename SameNodeLoadTest (#6143)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Apr 13, 2021
1 parent 23c45c0 commit 57d0bae
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -42,14 +42,14 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* SameNodeLoadTest
* ConcurrencyTest
*
* This test performs multiple concurrent requests for the same session on the same node.
* This test performs multiple concurrent requests from different clients
* for the same session on the same node.
*/
public class SameNodeLoadTest
public class ConcurrencyTest
{
@Test
@DisabledIfSystemProperty(named = "env", matches = "ci") // TODO: SLOW, needs review
public void testLoad() throws Exception
{
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
Expand All @@ -73,17 +73,18 @@ public void testLoad() throws Exception
{
String url = "http://localhost:" + port1 + contextPath + servletMapping;

//create session via first server
//create session upfront so the session id is established and
//can be shared to all clients
ContentResponse response1 = client.GET(url + "?action=init");
assertEquals(HttpServletResponse.SC_OK, response1.getStatus());
String sessionCookie = response1.getHeaders().get("Set-Cookie");
assertTrue(sessionCookie != null);

//simulate 10 clients making 100 requests each
//simulate 10 clients making 10 requests each for the same session
ExecutorService executor = Executors.newCachedThreadPool();
int clientsCount = 10;
CyclicBarrier barrier = new CyclicBarrier(clientsCount + 1);
int requestsCount = 100;
int requestsCount = 10;
Worker[] workers = new Worker[clientsCount];
for (int i = 0; i < clientsCount; ++i)
{
Expand All @@ -101,7 +102,9 @@ public void testLoad() throws Exception
System.err.println("Elapsed ms:" + elapsed);
executor.shutdownNow();

// Perform one request to get the result
// Perform one request to get the result - the session
// should have counted all the requests by incrementing
// a counter in an attribute.
Request request = client.newRequest(url + "?action=result");
ContentResponse response2 = request.send();
assertEquals(HttpServletResponse.SC_OK, response2.getStatus());
Expand Down

0 comments on commit 57d0bae

Please sign in to comment.