Skip to content

Commit ac2a761

Browse files
committed
Fix cluster tests
1 parent f7f20ce commit ac2a761

File tree

1 file changed

+12
-38
lines changed

1 file changed

+12
-38
lines changed

src/test/java/redis/clients/jedis/builders/RedisClusterClientMigrationIntegrationTest.java

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,12 @@ public void testConstructorWithNodesAndPoolConfig() {
157157
GenericObjectPoolConfig<Connection> poolConfig = new ConnectionPoolConfig();
158158
poolConfig.setMaxTotal(8);
159159
poolConfig.setMaxIdle(8);
160+
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().password(PASSWORD).build();
160161

161162
// Legacy constructor
162-
legacyCluster = new JedisCluster(CLUSTER_NODES, poolConfig);
163+
legacyCluster = new JedisCluster(CLUSTER_NODES, clientConfig, poolConfig);
163164

164165
// New Builder pattern - need to add password via clientConfig
165-
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().password(PASSWORD).build();
166-
167166
newCluster = RedisClusterClient.builder().nodes(CLUSTER_NODES).clientConfig(clientConfig)
168167
.poolConfig(poolConfig).build();
169168

@@ -197,33 +196,6 @@ public void testConstructorWithTimeoutsPasswordAndPoolConfig() {
197196
verifyBothClients(legacyCluster, newCluster);
198197
}
199198

200-
/**
201-
* Test migration from constructor with connection timeout, socket timeout, maxAttempts, and
202-
* poolConfig (no password). Tests constructor: JedisCluster(Set&lt;HostAndPort&gt;, int, int,
203-
* int, GenericObjectPoolConfig&lt;Connection&gt;)
204-
*/
205-
@Test
206-
public void testConstructorWithTimeoutsAndPoolConfigNoPassword() {
207-
int connectionTimeout = 2000;
208-
int socketTimeout = 2000;
209-
210-
GenericObjectPoolConfig<Connection> poolConfig = new ConnectionPoolConfig();
211-
212-
// Legacy constructor without password
213-
legacyCluster = new JedisCluster(CLUSTER_NODES, connectionTimeout, socketTimeout, MAX_ATTEMPTS,
214-
poolConfig);
215-
216-
// New Builder pattern - need to add password for our test cluster
217-
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()
218-
.connectionTimeoutMillis(connectionTimeout).socketTimeoutMillis(socketTimeout)
219-
.password(PASSWORD).build();
220-
221-
newCluster = RedisClusterClient.builder().nodes(CLUSTER_NODES).clientConfig(clientConfig)
222-
.maxAttempts(MAX_ATTEMPTS).poolConfig(poolConfig).build();
223-
224-
verifyBothClients(legacyCluster, newCluster);
225-
}
226-
227199
/**
228200
* Test migration from constructor with timeout, maxAttempts, and poolConfig. Tests constructor:
229201
* JedisCluster(Set&lt;HostAndPort&gt;, int, int, GenericObjectPoolConfig&lt;Connection&gt;)
@@ -233,14 +205,14 @@ public void testConstructorWithTimeoutMaxAttemptsAndPoolConfig() {
233205
int timeout = 2000;
234206

235207
GenericObjectPoolConfig<Connection> poolConfig = new ConnectionPoolConfig();
208+
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().timeoutMillis(timeout)
209+
.password(PASSWORD).build();
236210

237211
// Legacy constructor - uses same timeout for connection and socket
238-
legacyCluster = new JedisCluster(CLUSTER_NODES, timeout, MAX_ATTEMPTS, poolConfig);
212+
legacyCluster = new JedisCluster(CLUSTER_NODES, timeout, timeout, MAX_ATTEMPTS, PASSWORD,
213+
poolConfig);
239214

240215
// New Builder pattern
241-
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().timeoutMillis(timeout)
242-
.password(PASSWORD).build();
243-
244216
newCluster = RedisClusterClient.builder().nodes(CLUSTER_NODES).clientConfig(clientConfig)
245217
.maxAttempts(MAX_ATTEMPTS).poolConfig(poolConfig).build();
246218

@@ -253,15 +225,16 @@ public void testConstructorWithTimeoutMaxAttemptsAndPoolConfig() {
253225
*/
254226
@Test
255227
public void testConstructorWithSingleNodeAndPoolConfig() {
228+
int timeout = 2000;
256229
HostAndPort singleNode = HostAndPorts.getStableClusterServers().get(0);
257230
GenericObjectPoolConfig<Connection> poolConfig = new ConnectionPoolConfig();
231+
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().password(PASSWORD).build();
258232

259233
// Legacy constructor with single node
260-
legacyCluster = new JedisCluster(singleNode, poolConfig);
234+
legacyCluster = new JedisCluster(singleNode, timeout, timeout, MAX_ATTEMPTS, PASSWORD,
235+
poolConfig);
261236

262237
// New Builder pattern - need to add password and wrap single node in a Set
263-
JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().password(PASSWORD).build();
264-
265238
Set<HostAndPort> singleNodeSet = new HashSet<>();
266239
singleNodeSet.add(singleNode);
267240

@@ -292,7 +265,8 @@ protected void verifyBothClients(JedisCluster legacyCluster, RedisClusterClient
292265
assertEquals("1", legacyCluster.get(key2));
293266

294267
// Clean up
295-
newCluster.del(key1, key2);
268+
newCluster.del(key1);
269+
newCluster.del(key2);
296270
}
297271

298272
/**

0 commit comments

Comments
 (0)