jdeppe-pivotal commented on a change in pull request #5079: URL: https://github.com/apache/geode/pull/5079#discussion_r425433754
########## File path: geode-redis/src/distributedTest/java/org/apache/geode/redis/session/SessionDUnitTest.java ########## @@ -80,137 +84,62 @@ public static void setup() { cluster.startLocatorVM(LOCATOR); startRedisServer(SERVER1); startRedisServer(SERVER2); - startSpringApp(APP1, SERVER1, SERVER2); - startSpringApp(APP2, SERVER2, SERVER1); - jedis = new Jedis("localhost", ports.get(SERVER1), JEDIS_TIMEOUT); - } - - @After - public void cleanupAfterTest() { - jedis.flushAll(); + jedisConnetedToServer1 = new Jedis("localhost", ports.get(SERVER1), JEDIS_TIMEOUT); } @AfterClass public static void cleanupAfterClass() { - jedis.disconnect(); - } - - @Test - public void should_beAbleToCreateASession_storedInRedis() { - String sessionCookie = createNewSessionWithNote(APP1, "note1"); - String sessionId = getSessionId(sessionCookie); - - Map<String, String> sessionInfo = - jedis.hgetAll("spring:session:sessions:" + sessionId); - - assertThat(sessionInfo.get("sessionAttr:NOTES")).contains("note1"); - } - - @Test - public void should_storeSession() { - String sessionCookie = createNewSessionWithNote(APP1, "note1"); - - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("note1"); - } - - @Test - public void should_propagateSession_toOtherServers() { - String sessionCookie = createNewSessionWithNote(APP1, "noteFromClient1"); - - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient1"); - } - - @Test - public void should_getSessionFromServer1_whenServer2GoesDown() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); - cluster.crashVM(SERVER2); - try { - String[] sessionNotes = getSessionNotes(APP1, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2"); - } finally { - startRedisServer(SERVER2); - } - } - - @Test - public void should_getSessionFromServer_whenServerGoesDownAndIsRestarted() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); - cluster.crashVM(SERVER2); - addNoteToSession(APP1, sessionCookie); - startRedisServer(SERVER2); - - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2", "noteFromClient1"); - } - - @Test - public void should_getSession_whenServer2GoesDown_andAppFailsOverToServer1() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); - cluster.crashVM(SERVER2); - - try { - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2"); - } finally { - startRedisServer(SERVER2); - } - } - - @Test - public void should_getSessionCreatedByApp2_whenApp2GoesDown_andClientConnectsToApp1() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); + jedisConnetedToServer1.disconnect(); + stopSpringApp(APP1); stopSpringApp(APP2); + } - try { - String[] sessionNotes = getSessionNotes(APP1, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2"); - } finally { - startSpringApp(APP2, SERVER1, SERVER2); - } - + @After + public void cleanupAfterTest() { + jedisConnetedToServer1.flushAll(); } - private static void startRedisServer(int server1) { + protected static void startRedisServer(int server1) { cluster.startServerVM(server1, redisProperties(server1), cluster.getMember(LOCATOR).getPort()); + + cluster.getVM(server1).invoke("Set logging level to DEBUG", () -> { + Logger logger = LogManager.getLogger("org.apache.geode.redis.internal"); + Configurator.setAllLevels(logger.getName(), Level.getLevel("DEBUG")); + FastLogger.setDelegating(true); + }); } private static Properties redisProperties(int server2) { Review comment: Done. ########## File path: geode-redis/src/distributedTest/java/org/apache/geode/redis/session/SessionDUnitTest.java ########## @@ -80,137 +84,62 @@ public static void setup() { cluster.startLocatorVM(LOCATOR); startRedisServer(SERVER1); startRedisServer(SERVER2); - startSpringApp(APP1, SERVER1, SERVER2); - startSpringApp(APP2, SERVER2, SERVER1); - jedis = new Jedis("localhost", ports.get(SERVER1), JEDIS_TIMEOUT); - } - - @After - public void cleanupAfterTest() { - jedis.flushAll(); + jedisConnetedToServer1 = new Jedis("localhost", ports.get(SERVER1), JEDIS_TIMEOUT); } @AfterClass public static void cleanupAfterClass() { - jedis.disconnect(); - } - - @Test - public void should_beAbleToCreateASession_storedInRedis() { - String sessionCookie = createNewSessionWithNote(APP1, "note1"); - String sessionId = getSessionId(sessionCookie); - - Map<String, String> sessionInfo = - jedis.hgetAll("spring:session:sessions:" + sessionId); - - assertThat(sessionInfo.get("sessionAttr:NOTES")).contains("note1"); - } - - @Test - public void should_storeSession() { - String sessionCookie = createNewSessionWithNote(APP1, "note1"); - - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("note1"); - } - - @Test - public void should_propagateSession_toOtherServers() { - String sessionCookie = createNewSessionWithNote(APP1, "noteFromClient1"); - - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient1"); - } - - @Test - public void should_getSessionFromServer1_whenServer2GoesDown() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); - cluster.crashVM(SERVER2); - try { - String[] sessionNotes = getSessionNotes(APP1, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2"); - } finally { - startRedisServer(SERVER2); - } - } - - @Test - public void should_getSessionFromServer_whenServerGoesDownAndIsRestarted() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); - cluster.crashVM(SERVER2); - addNoteToSession(APP1, sessionCookie); - startRedisServer(SERVER2); - - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2", "noteFromClient1"); - } - - @Test - public void should_getSession_whenServer2GoesDown_andAppFailsOverToServer1() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); - cluster.crashVM(SERVER2); - - try { - String[] sessionNotes = getSessionNotes(APP2, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2"); - } finally { - startRedisServer(SERVER2); - } - } - - @Test - public void should_getSessionCreatedByApp2_whenApp2GoesDown_andClientConnectsToApp1() { - String sessionCookie = createNewSessionWithNote(APP2, "noteFromClient2"); + jedisConnetedToServer1.disconnect(); + stopSpringApp(APP1); stopSpringApp(APP2); + } - try { - String[] sessionNotes = getSessionNotes(APP1, sessionCookie); - - assertThat(sessionNotes).containsExactly("noteFromClient2"); - } finally { - startSpringApp(APP2, SERVER1, SERVER2); - } - + @After + public void cleanupAfterTest() { + jedisConnetedToServer1.flushAll(); } - private static void startRedisServer(int server1) { + protected static void startRedisServer(int server1) { Review comment: Done ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org