Skip to content

Commit

Permalink
[DBClusterParameterGroup] Add binlog_replication_globaldb in the same…
Browse files Browse the repository at this point in the history
… request as binlog_backup and aurora_enhanced_binlog
  • Loading branch information
Javier Abella authored and zrfr committed Aug 26, 2024
1 parent 50f9cc7 commit 9ba2da0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public abstract class BaseHandlerStd extends BaseHandler<CallbackContext> {
ImmutableSet.of("password_encryption", "rds.accepted_password_auth_method"),
ImmutableSet.of("ssl_max_protocol_version", "ssl_min_protocol_version"),
ImmutableSet.of("rds.change_data_capture_streaming", "binlog_format"),
ImmutableSet.of("aurora_enhanced_binlog", "binlog_backup")
ImmutableSet.of("aurora_enhanced_binlog", "binlog_backup", "binlog_replication_globaldb")
);
protected static final BiFunction<ResourceModel, ProxyClient<RdsClient>, ResourceModel> EMPTY_CALL = (model, proxyClient) -> model;
protected static final String AVAILABLE = "available";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -93,18 +94,20 @@ public class CreateHandlerTest extends AbstractHandlerTest {
*/
private static class InsertionOrderedParamBuilder {
private final ImmutableMap.Builder<String, Object> parameters = new ImmutableMap.Builder<>();
private final AtomicInteger parameterIndex = new AtomicInteger(0);

public static InsertionOrderedParamBuilder builder() {
return new InsertionOrderedParamBuilder();
}

public InsertionOrderedParamBuilder addParameter(String parameterName, String parameterValue) {
parameters.put(parameterName, parameterValue);
parameterIndex.incrementAndGet();
return this;
}

public InsertionOrderedParamBuilder addRandomParameters(int numberOfRandomParameters) {
IntStream.range(0, numberOfRandomParameters).forEach(i -> parameters.put("param" + i, "value"));
IntStream.range(0, numberOfRandomParameters).forEach(i -> parameters.put("param" + parameterIndex.incrementAndGet(), "value"));
return this;
}

Expand Down Expand Up @@ -451,8 +454,8 @@ public void handleRequest_SuccessWithParameters() {
* We need to ensure that all related parameters are sent in the same request as defined
* in BaseHandlerStd.PARAMETER_DEPENDENCIES
*
* This test ensure that "aurora_enhanced_binlog" and "binlog_backup" get bundled in the same request after
* the split logic that happens in BaseHandlerStd.modifyParameters
* This test ensure that "aurora_enhanced_binlog", "binlog_backup" and "binlog_replication_globaldb" get bundled in
* the same request after the split logic that happens in BaseHandlerStd.modifyParameters
*/
@Test
public void handleRequest_SuccessSplitParameters() {
Expand Down Expand Up @@ -489,6 +492,8 @@ public void handleRequest_SuccessSplitParameters() {
.addParameter("aurora_enhanced_binlog", "1")
.addRandomParameters(BaseHandlerStd.MAX_PARAMETERS_PER_REQUEST)
.addParameter("binlog_backup", "0")
.addRandomParameters(BaseHandlerStd.MAX_PARAMETERS_PER_REQUEST)
.addParameter("binlog_replication_globaldb", "0")
.build())
.build();
mockDescribeDbClusterParametersResponse(resourceModel.getParameters(), true, "static");
Expand All @@ -503,12 +508,13 @@ public void handleRequest_SuccessSplitParameters() {
ArgumentCaptor<ModifyDbClusterParameterGroupRequest> captor = ArgumentCaptor.forClass(ModifyDbClusterParameterGroupRequest.class);

verify(rdsProxy.client(), times(1)).createDBClusterParameterGroup(any(CreateDbClusterParameterGroupRequest.class));
verify(rdsProxy.client(), times(2)).modifyDBClusterParameterGroup(captor.capture());
verify(rdsProxy.client(), times(3)).modifyDBClusterParameterGroup(captor.capture());
verify(rdsProxy.client(), times(1)).describeDBClusters(any(DescribeDbClustersRequest.class));

ModifyDbClusterParameterGroupRequest firstRequest = captor.getAllValues().get(0);
assertThat(verifyParameterExistsInRequest("aurora_enhanced_binlog", firstRequest)).isEqualTo(true);
assertThat(verifyParameterExistsInRequest("binlog_backup", firstRequest)).isEqualTo(true);
assertThat(verifyParameterExistsInRequest("binlog_replication_globaldb", firstRequest)).isEqualTo(true);
}

@Test
Expand Down

0 comments on commit 9ba2da0

Please sign in to comment.