mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 08:55:17 -05:00
fix(elasticache): report a ConfigurationEndpoint only for cluster-mode-enabled replication groups (#4469)
A cluster-mode-disabled replication group reported a ConfigurationEndpoint alongside NodeGroups[0].PrimaryEndpoint. AWS only returns ConfigurationEndpoint for a cluster-mode-enabled group, and terraform-provider-aws branches on its presence: when it is set, primary_endpoint_address and reader_endpoint_address are left null.
This commit is contained in:
1 parent
2dafbb45b2
commit
5af1d4048e
4 files changed
+32
-15
No files matched your search
+1
-1
@@ -962,7 +962,7 @@ private Response handleCreateCacheParameterGroup(MultivaluedMap<String, String>
|
||||
appendSingleNodeGroup(xml, g, members, ep);
|
||||
}
|
||||
xml.end("NodeGroups");
|
||||
if (ep != null) {
|
||||
if (g.isClusterEnabled() && ep != null) {
|
||||
xml.start("ConfigurationEndpoint")
|
||||
.elem("Address", ep.address())
|
||||
.elem("Port", (long) ep.port())
|
||||
|
||||
+12
-8
@@ -19,6 +19,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
@@ -94,11 +95,11 @@ class ElastiCacheIntegrationTest {
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ReplicationGroupId", equalTo(GROUP_ID))
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.Status", equalTo("available"))
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.AuthTokenEnabled", equalTo("true"))
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ConfigurationEndpoint.Address", equalTo("localhost"))
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ConfigurationEndpoint.Port", notNullValue())
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Address", equalTo("localhost"))
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Port", notNullValue())
|
||||
.extract()
|
||||
.xmlPath()
|
||||
.getInt("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ConfigurationEndpoint.Port");
|
||||
.getInt("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Port");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,8 +115,11 @@ class ElastiCacheIntegrationTest {
|
||||
.statusCode(200)
|
||||
.body("DescribeReplicationGroupsResponse.DescribeReplicationGroupsResult.ReplicationGroups.ReplicationGroup.ReplicationGroupId",
|
||||
equalTo(GROUP_ID))
|
||||
.body("DescribeReplicationGroupsResponse.DescribeReplicationGroupsResult.ReplicationGroups.ReplicationGroup.ConfigurationEndpoint.Port",
|
||||
equalTo(String.valueOf(firstProxyPort)));
|
||||
.body("DescribeReplicationGroupsResponse.DescribeReplicationGroupsResult.ReplicationGroups.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Port",
|
||||
equalTo(String.valueOf(firstProxyPort)))
|
||||
.body("DescribeReplicationGroupsResponse.DescribeReplicationGroupsResult.ReplicationGroups.ReplicationGroup.ClusterEnabled",
|
||||
equalTo("false"))
|
||||
.body(not(containsString("<ConfigurationEndpoint>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -235,7 +239,7 @@ class ElastiCacheIntegrationTest {
|
||||
.statusCode(200)
|
||||
.extract()
|
||||
.xmlPath()
|
||||
.getInt("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ConfigurationEndpoint.Port");
|
||||
.getInt("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Port");
|
||||
|
||||
// User associated with GROUP_ID should be rejected on CROSS_GROUP_ID
|
||||
String reply = sendCommand(crossGroupPort, respArray("AUTH", USER_NAME, INITIAL_PASSWORD));
|
||||
@@ -345,10 +349,10 @@ class ElastiCacheIntegrationTest {
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ConfigurationEndpoint.Address", equalTo("localhost"))
|
||||
.body("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Address", equalTo("localhost"))
|
||||
.extract()
|
||||
.xmlPath()
|
||||
.getInt("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.ConfigurationEndpoint.Port");
|
||||
.getInt("CreateReplicationGroupResponse.CreateReplicationGroupResult.ReplicationGroup.NodeGroups.NodeGroup.PrimaryEndpoint.Port");
|
||||
|
||||
assertEquals(firstProxyPort, reusedPort);
|
||||
|
||||
|
||||
+4
@@ -104,6 +104,8 @@ class ElastiCacheQueryHandlerTest {
|
||||
assertTrue(body.contains("<CacheClusterId>grp-0002-001</CacheClusterId>"));
|
||||
assertFalse(body.contains("<PrimaryEndpoint>"),
|
||||
"Cluster-mode node groups carry Slots, not a PrimaryEndpoint");
|
||||
assertTrue(body.contains(
|
||||
"<ConfigurationEndpoint><Address>localhost</Address><Port>6379</Port></ConfigurationEndpoint>"), body);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,6 +127,8 @@ class ElastiCacheQueryHandlerTest {
|
||||
assertTrue(body.contains("<ClusterId>grp-001</ClusterId>"));
|
||||
assertTrue(body.contains("<PrimaryEndpoint><Address>localhost</Address><Port>6379</Port></PrimaryEndpoint>"));
|
||||
assertTrue(body.contains("<CurrentRole>primary</CurrentRole>"));
|
||||
assertFalse(body.contains("<ConfigurationEndpoint>"),
|
||||
"A cluster-mode-disabled group reports its endpoints under NodeGroups only");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user