Resolve Redis Client Connection Issue in Integration Test

- Resolves a race condition where a client instance is closed
  before it can be used by another test
This commit is contained in:
Tapan Avasthi 2020-02-12 23:28:12 +05:30
parent 125c07509d
commit 61787725fa
3 changed files with 11 additions and 4 deletions

View File

@ -146,4 +146,9 @@ public class RedisClient {
} }
} }
public void destroyInstance() {
jedisPool = null;
instance = null;
}
} }

View File

@ -25,13 +25,14 @@ public class NaiveApproachIntegrationTest {
s.close(); s.close();
redisServer = new RedisServer(port); redisServer = new RedisServer(port);
redisServer.start();
} }
@AfterClass @AfterClass
public static void destroy() { public static void destroy() {
if (redisServer.isActive()) if (redisServer.isActive()) {
redisServer.stop(); redisServer.stop();
redisClient.destroyInstance();
}
} }
@Before @Before

View File

@ -32,13 +32,14 @@ public class ScanStrategyIntegrationTest {
s.close(); s.close();
redisServer = new RedisServer(port); redisServer = new RedisServer(port);
redisServer.start();
} }
@AfterClass @AfterClass
public static void destroy() { public static void destroy() {
if (redisServer.isActive()) if (redisServer.isActive()) {
redisServer.stop(); redisServer.stop();
redisClient.destroyInstance();
}
} }
@Before @Before