Skip to content

Commit

Permalink
Troubleshoot failing CI test (passing locally)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggivo committed Dec 3, 2024
1 parent 51c95ed commit 210865d
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import io.lettuce.core.protocol.Command;
import io.lettuce.test.CanConnect;
import io.lettuce.test.CliParser;
import io.lettuce.test.WithPassword;
import io.lettuce.test.condition.RedisConditions;
import io.lettuce.test.resource.FastShutdown;
import io.lettuce.test.resource.TestClientResources;
import io.lettuce.test.settings.TestSettings;
Expand Down Expand Up @@ -142,25 +140,28 @@ void nodeSelectionApiShouldWork() {
@Test
void shouldPerformNodeConnectionReauth() {

try (StatefulRedisClusterConnection<String, String> connection = redisClient.connect()) {
connection.getPartitions()
.forEach(partition -> createTestUser(connection.getConnection(partition.getNodeId()).sync()));
StatefulRedisClusterConnection<String, String> connection = redisClient.connect();
connection.getPartitions()
.forEach(partition -> createTestUser(connection.getConnection(partition.getNodeId()).sync()));

credentialsProvider.emitCredentials(TestSettings.aclUsername(),
TestSettings.aclPassword().toString().toCharArray());
credentialsProvider.emitCredentials(TestSettings.aclUsername(),
TestSettings.aclPassword().toString().toCharArray());

Executions<String> pingResponses = connection.sync().all().commands().ping();
assertThat(pingResponses).hasSize(3).contains("PONG");
// Verify each node's authenticated username matches the updated credentials
connection.getPartitions().forEach(partition -> {
StatefulRedisConnection<String, String> userConn = connection.getConnection(partition.getNodeId());
assertThat(userConn.sync().aclWhoami()).isEqualTo(TestSettings.aclUsername());
});

// Verify each node's authenticated username matches the updated credentials
connection.getPartitions().forEach(partition -> {
String authenticatedUser = connection.getConnection(partition.getNodeId()).sync().aclWhoami();
assertThat(authenticatedUser).isEqualTo(TestSettings.aclUsername());
});
// re-auth with the default credentials
credentialsProvider.emitCredentials(TestSettings.username(),
TestSettings.password().toString().toCharArray());

connection.getPartitions()
.forEach(partition -> deleteTestUser(connection.getConnection(partition.getNodeId()).sync()));
}
connection.getPartitions().forEach(partition -> {
deleteTestUser(connection.getConnection(partition.getNodeId()).sync());
});

connection.close();
}

public static void createTestUser(RedisCommands<String, String> commands) {
Expand Down

0 comments on commit 210865d

Please sign in to comment.