Skip to content

Commit

Permalink
Add OOM testing of parsing replicas
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Svensson <[email protected]>
  • Loading branch information
bjosv committed Oct 11, 2024
1 parent 12920a0 commit 8acf6aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ static dict *parse_cluster_nodes(valkeyClusterContext *cc, valkeyReply *reply) {
ret = cluster_master_slave_mapping_with_name(
cc, &nodes_name, master, master->name);
if (ret != VALKEY_OK) {
freeValkeyClusterNode(master);
goto error;
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/ct_out_of_memory_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void test_alloc_failure_handling(void) {
cc = valkeyClusterContextInit();
assert(cc);
}
cc->flags |= VALKEYCLUSTER_FLAG_ADD_SLAVE;

// Add nodes
{
Expand Down Expand Up @@ -170,14 +171,14 @@ void test_alloc_failure_handling(void) {

// Connect
{
for (int i = 0; i < 128; ++i) {
for (int i = 0; i < 148; ++i) {
prepare_allocation_test(cc, i);
result = valkeyClusterConnect2(cc);
assert(result == VALKEY_ERR);
ASSERT_STR_EQ(cc->errstr, "Out of memory");
}

prepare_allocation_test(cc, 128);
prepare_allocation_test(cc, 148);
result = valkeyClusterConnect2(cc);
assert(result == VALKEY_OK);
}
Expand Down

0 comments on commit 8acf6aa

Please sign in to comment.