mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix: send ElastiCache, Memcached, DocDB and Amazon MQ container logs to the resource's region (#5098)
* fix: send ElastiCache, Memcached, DocDB and Amazon MQ container logs to the resource's region The container managers attached the CloudWatch Logs stream, and labelled the container, with the default region, so a cluster or broker created in another region logged to the default one. The ElastiCache, Memcached and DocDB managers now take the resource's region: the request's on create, the one in the resource's ARN on a startup restore. Amazon MQ reads its broker's ARN. A Memcached cluster records no ARN or region, so a restored one still logs to the default region. * fix(elasticache): keep a Memcached cluster's log region across a restart A Memcached cluster records no ARN, so a restore had no region to give its container and logged to the default region, although the cluster logged to its own region until the restart. The cluster record now keeps the region it was created in (persisted only, not in any response), and the restore uses it; a record from before this has none and keeps the default. The handler test now checks the request region is passed on.
This commit is contained in:
1 parent
0e89ab962a
commit
539bf15fdd
16 files changed
+174
-133
No files matched your search
+8
-2
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.amazonmq.container;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerBuilder;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
|
||||
@@ -101,7 +102,7 @@ public class RabbitMqManager {
|
||||
.withLogRotation()
|
||||
.withLabels(ContainerStorageHelper.resourceIdentityLabels(
|
||||
"amazonmq", broker.getBrokerId(), regionResolver.getAccountId(),
|
||||
regionResolver.getDefaultRegion()));
|
||||
brokerRegion(broker)));
|
||||
|
||||
// Seed the broker's admin user. RabbitMQ's built-in `guest` user is
|
||||
// loopback-only, so it cannot authenticate over the mapped host port; a user
|
||||
@@ -177,7 +178,7 @@ public class RabbitMqManager {
|
||||
: info.containerId();
|
||||
String logGroup = "/aws/amazonmq/broker/" + broker.getBrokerId();
|
||||
String logStream = logStreamer.generateLogStreamName(shortId);
|
||||
String region = regionResolver.getDefaultRegion();
|
||||
String region = brokerRegion(broker);
|
||||
Closeable logHandle = logStreamer.attach(
|
||||
info.containerId(), logGroup, logStream, region, "amazonmq:" + broker.getBrokerId());
|
||||
if (logHandle != null) {
|
||||
@@ -185,6 +186,11 @@ public class RabbitMqManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** The region in the broker's ARN; a broker recorded without one counts as the default region's. */
|
||||
private String brokerRegion(Broker broker) {
|
||||
return AwsArnUtils.regionOrDefault(broker.getBrokerArn(), regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ready once the RabbitMQ management UI answers on its port. The management
|
||||
* plugin starts after the broker core, so a 200 here implies AMQP is also up.
|
||||
|
||||
@@ -240,7 +240,8 @@ public class DocDbService {
|
||||
// A cluster record is metadata: its identifier, ARN and tags need no Docker, so the
|
||||
// cluster is created and reaches 'available' even when no daemon is reachable. Only
|
||||
// connecting to the database needs the container.
|
||||
DocDbContainerHandle handle = containerManager.tryStart(id, image, masterUsername, masterPassword);
|
||||
DocDbContainerHandle handle = containerManager.tryStart(id, image, masterUsername, masterPassword,
|
||||
region);
|
||||
if (handle != null) {
|
||||
cluster.setEndpoint(handle.getHost());
|
||||
cluster.setReaderEndpoint(handle.getHost());
|
||||
|
||||
+6
-5
@@ -66,9 +66,10 @@ public class DocDbContainerManager {
|
||||
*
|
||||
* @return the container handle, or {@code null} when no Docker daemon is reachable
|
||||
*/
|
||||
public DocDbContainerHandle tryStart(String clusterId, String image, String masterUsername, String masterPassword) {
|
||||
public DocDbContainerHandle tryStart(String clusterId, String image, String masterUsername, String masterPassword,
|
||||
String region) {
|
||||
try {
|
||||
DocDbContainerHandle handle = start(clusterId, image, masterUsername, masterPassword);
|
||||
DocDbContainerHandle handle = start(clusterId, image, masterUsername, masterPassword, region);
|
||||
dockerUnavailableLogged = false;
|
||||
return handle;
|
||||
} catch (RuntimeException e) {
|
||||
@@ -100,7 +101,8 @@ public class DocDbContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
public DocDbContainerHandle start(String clusterId, String image, String masterUsername, String masterPassword) {
|
||||
public DocDbContainerHandle start(String clusterId, String image, String masterUsername, String masterPassword,
|
||||
String region) {
|
||||
LOG.infov("Starting DocumentDB container for cluster: {0}", clusterId);
|
||||
|
||||
String containerName = ContainerStorageHelper.resourceName(config, "docdb", null, clusterId);
|
||||
@@ -117,7 +119,7 @@ public class DocDbContainerManager {
|
||||
.withLogRotation()
|
||||
.withEnv(envVars)
|
||||
.withLabels(ContainerStorageHelper.resourceIdentityLabels(
|
||||
"docdb", clusterId, regionResolver.getAccountId(), regionResolver.getDefaultRegion()));
|
||||
"docdb", clusterId, regionResolver.getAccountId(), region));
|
||||
|
||||
if (!containerDetector.isRunningInContainer()) {
|
||||
specBuilder.withDynamicPort(MONGO_PORT);
|
||||
@@ -141,7 +143,6 @@ public class DocDbContainerManager {
|
||||
: info.containerId();
|
||||
String logGroup = "/aws/docdb/cluster/" + clusterId + "/audit";
|
||||
String logStream = logStreamer.generateLogStreamName(shortId);
|
||||
String region = regionResolver.getDefaultRegion();
|
||||
|
||||
Closeable logHandle = logStreamer.attach(
|
||||
info.containerId(), logGroup, logStream, region, "docdb:" + clusterId);
|
||||
|
||||
+8
-5
@@ -63,7 +63,7 @@ public class ElastiCacheMemcachedService {
|
||||
new TypeReference<Map<String, ReplicationGroup>>() {});
|
||||
}
|
||||
|
||||
public CacheCluster createCacheCluster(String clusterId) {
|
||||
public CacheCluster createCacheCluster(String clusterId, String region) {
|
||||
// Claimed before the store checks rather than after, because no create here or in
|
||||
// ElastiCacheService persists its record until its container has started: a store check
|
||||
// that passes is no promise the id is still free by the time this one writes. The claim
|
||||
@@ -74,13 +74,13 @@ public class ElastiCacheMemcachedService {
|
||||
"Cache cluster " + clusterId + " is already being created.", 400);
|
||||
}
|
||||
try {
|
||||
return provisionCacheCluster(clusterId);
|
||||
return provisionCacheCluster(clusterId, region);
|
||||
} finally {
|
||||
provisioningIds.release(clusterId);
|
||||
}
|
||||
}
|
||||
|
||||
private CacheCluster provisionCacheCluster(String clusterId) {
|
||||
private CacheCluster provisionCacheCluster(String clusterId, String region) {
|
||||
// Every store that answers DescribeCacheClusters, not just this one: two records sharing
|
||||
// an id would have one describe report it twice, each with a different engine.
|
||||
if (clusters.get(clusterId).isPresent()
|
||||
@@ -96,7 +96,7 @@ public class ElastiCacheMemcachedService {
|
||||
// A cache cluster record is metadata: its id and endpoint are derived from configuration,
|
||||
// so the cluster is created and reaches 'available' even when no Docker daemon is
|
||||
// reachable. Only connecting to the cache needs the container.
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(clusterId, image);
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(clusterId, image, region);
|
||||
|
||||
String endpointHost = resolveEndpointHost(handle);
|
||||
int endpointPort = handle != null ? handle.getPort() : BACKEND_PORT;
|
||||
@@ -114,6 +114,7 @@ public class ElastiCacheMemcachedService {
|
||||
+ "is reachable. Metadata operations work; connections to the cache do not "
|
||||
+ "until a daemon appears.", clusterId);
|
||||
}
|
||||
cluster.setRegion(region);
|
||||
|
||||
clusters.put(clusterId, cluster);
|
||||
LOG.infov("Memcached cluster {0} created, endpoint={1}:{2}", clusterId, endpointHost, endpointPort);
|
||||
@@ -165,7 +166,9 @@ public class ElastiCacheMemcachedService {
|
||||
String clusterId = cluster.getCacheClusterId();
|
||||
String image = config.services().elasticache().defaultMemcachedImage();
|
||||
try {
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(clusterId, image);
|
||||
// The region the cluster was created in; a record from before it was kept has none and logs
|
||||
// to the default region.
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(clusterId, image, cluster.getRegion());
|
||||
synchronized (lockFor(clusterId)) {
|
||||
if (restoreTargetLost(clusterId)) {
|
||||
abandonRestoredContainer(clusterId, handle);
|
||||
|
||||
+1
-1
@@ -337,7 +337,7 @@ public class ElastiCacheQueryHandler {
|
||||
|
||||
try {
|
||||
CacheCluster cluster = "memcached".equalsIgnoreCase(engine)
|
||||
? memcachedService.createCacheCluster(clusterId)
|
||||
? memcachedService.createCacheCluster(clusterId, region)
|
||||
: service.createCacheCluster(new ElastiCacheService.CreateCacheClusterRequest(
|
||||
clusterId,
|
||||
engine,
|
||||
|
||||
+11
-6
@@ -273,7 +273,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
// derived from configuration and need no Docker, so the group is created and reaches
|
||||
// 'available' even when no daemon is reachable. Only connecting to the cache needs
|
||||
// the container.
|
||||
handle = containerManager.tryStart(groupId, image);
|
||||
handle = containerManager.tryStart(groupId, image, request.region());
|
||||
|
||||
String endpointHost = resolveEndpointHost();
|
||||
Endpoint endpoint = new Endpoint(endpointHost, proxyPort);
|
||||
@@ -359,7 +359,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
inFlightMemberId = node.getMemberClusterId();
|
||||
ElastiCacheContainerHandle handle = containerManager.start(
|
||||
node.getMemberClusterId(), image,
|
||||
clusterNodeFlags(endpointHost, announceIp, node.getProxyPort()));
|
||||
clusterNodeFlags(endpointHost, announceIp, node.getProxyPort()), request.region());
|
||||
inFlightMemberId = null;
|
||||
handles.add(handle);
|
||||
node.setContainerId(handle.getContainerId());
|
||||
@@ -694,11 +694,16 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
* monitor and re-reads the record, because a delete taken while the container started has
|
||||
* already removed it.
|
||||
*/
|
||||
/** The region in a restored resource's ARN; one recorded without an ARN counts as the default region's. */
|
||||
private String regionOf(String arn) {
|
||||
return AwsArnUtils.regionOrDefault(arn, regionResolver.getDefaultRegion());
|
||||
}
|
||||
|
||||
private void restoreCacheCluster(CacheCluster cluster) {
|
||||
String clusterId = cluster.getCacheClusterId();
|
||||
String image = config.services().elasticache().defaultImage();
|
||||
try {
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(clusterId, image);
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(clusterId, image, regionOf(cluster.getArn()));
|
||||
synchronized (lockFor("cc:" + clusterId)) {
|
||||
if (cacheClusterRestoreTargetLost(clusterId)) {
|
||||
abandonRestoredCacheClusterContainer(clusterId, handle);
|
||||
@@ -827,7 +832,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
String groupId = group.getReplicationGroupId();
|
||||
String image = config.services().elasticache().defaultImage();
|
||||
try {
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(groupId, image);
|
||||
ElastiCacheContainerHandle handle = containerManager.tryStart(groupId, image, regionOf(group.getArn()));
|
||||
synchronized (lockFor("rg:" + groupId)) {
|
||||
if (restoreTargetLost(groupId)) {
|
||||
abandonRestoredContainer(groupId, handle);
|
||||
@@ -963,7 +968,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
inFlightMemberId = node.getMemberClusterId();
|
||||
ElastiCacheContainerHandle handle = containerManager.start(
|
||||
node.getMemberClusterId(), image,
|
||||
clusterNodeFlags(endpointHost, announceIp, node.getProxyPort()));
|
||||
clusterNodeFlags(endpointHost, announceIp, node.getProxyPort()), regionOf(group.getArn()));
|
||||
inFlightMemberId = null;
|
||||
handles.add(handle);
|
||||
node.setContainerId(handle.getContainerId());
|
||||
@@ -1249,7 +1254,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
// As for a replication group, the record is metadata: it reaches 'available' even
|
||||
// when no Docker daemon is reachable, and only connecting to the cache needs the
|
||||
// container.
|
||||
handle = containerManager.tryStart(clusterId, image);
|
||||
handle = containerManager.tryStart(clusterId, image, request.region());
|
||||
|
||||
CacheCluster cluster = new CacheCluster(clusterId, CacheClusterStatus.AVAILABLE, engine,
|
||||
request.engineVersion() != null && !request.engineVersion().isBlank()
|
||||
|
||||
+7
-7
@@ -79,9 +79,9 @@ public class ElastiCacheContainerManager {
|
||||
* @return the container handle, or {@code null} when no Docker daemon is reachable and no
|
||||
* container was created
|
||||
*/
|
||||
public ElastiCacheContainerHandle tryStart(String groupId, String image) {
|
||||
public ElastiCacheContainerHandle tryStart(String groupId, String image, String region) {
|
||||
try {
|
||||
ElastiCacheContainerHandle handle = start(groupId, image);
|
||||
ElastiCacheContainerHandle handle = start(groupId, image, region);
|
||||
dockerUnavailableLogged = false;
|
||||
return handle;
|
||||
} catch (RuntimeException e) {
|
||||
@@ -118,8 +118,8 @@ public class ElastiCacheContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
public ElastiCacheContainerHandle start(String groupId, String image) {
|
||||
return start(groupId, image, List.of());
|
||||
public ElastiCacheContainerHandle start(String groupId, String image, String region) {
|
||||
return start(groupId, image, List.of(), region);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,8 @@ public class ElastiCacheContainerManager {
|
||||
* to the Valkey server command line (via the image's {@code VALKEY_EXTRA_FLAGS} hook).
|
||||
* Cluster-mode nodes use this to pass {@code --cluster-enabled} and announce settings.
|
||||
*/
|
||||
public ElastiCacheContainerHandle start(String groupId, String image, List<String> extraServerFlags) {
|
||||
public ElastiCacheContainerHandle start(String groupId, String image, List<String> extraServerFlags,
|
||||
String region) {
|
||||
LOG.infov("Starting ElastiCache backend container for group: {0}", groupId);
|
||||
|
||||
String containerName = containerName(groupId);
|
||||
@@ -149,7 +150,7 @@ public class ElastiCacheContainerManager {
|
||||
.withDockerNetwork(config.services().elasticache().dockerNetwork())
|
||||
.withLogRotation()
|
||||
.withLabels(ContainerStorageHelper.resourceIdentityLabels(
|
||||
"elasticache", groupId, regionResolver.getAccountId(), regionResolver.getDefaultRegion()));
|
||||
"elasticache", groupId, regionResolver.getAccountId(), region));
|
||||
|
||||
if (!containerDetector.isRunningInContainer()) {
|
||||
specBuilder.withDynamicPort(BACKEND_PORT);
|
||||
@@ -182,7 +183,6 @@ public class ElastiCacheContainerManager {
|
||||
: info.containerId();
|
||||
String logGroup = "/aws/elasticache/cluster/" + groupId + "/engine-log";
|
||||
String logStream = logStreamer.generateLogStreamName(shortId);
|
||||
String region = regionResolver.getDefaultRegion();
|
||||
|
||||
Closeable logHandle = logStreamer.attach(
|
||||
info.containerId(), logGroup, logStream, region, "elasticache:" + groupId);
|
||||
|
||||
+7
-6
@@ -76,9 +76,9 @@ public class ElastiCacheMemcachedContainerManager {
|
||||
* @return the container handle, or {@code null} when no Docker daemon is reachable and no
|
||||
* container was created
|
||||
*/
|
||||
public ElastiCacheContainerHandle tryStart(String clusterId, String image) {
|
||||
public ElastiCacheContainerHandle tryStart(String clusterId, String image, String region) {
|
||||
try {
|
||||
ElastiCacheContainerHandle handle = start(clusterId, image);
|
||||
ElastiCacheContainerHandle handle = start(clusterId, image, region);
|
||||
dockerUnavailableLogged = false;
|
||||
return handle;
|
||||
} catch (RuntimeException e) {
|
||||
@@ -115,7 +115,9 @@ public class ElastiCacheMemcachedContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
public ElastiCacheContainerHandle start(String clusterId, String image) {
|
||||
/** {@code region} is null for a cluster recorded without one, which then counts as the default region's. */
|
||||
public ElastiCacheContainerHandle start(String clusterId, String image, String region) {
|
||||
String effectiveRegion = region != null ? region : regionResolver.getDefaultRegion();
|
||||
LOG.infov("Starting Memcached container for cluster: {0}", clusterId);
|
||||
|
||||
String containerName = ContainerStorageHelper.resourceName(config, "memcached", null, clusterId);
|
||||
@@ -126,7 +128,7 @@ public class ElastiCacheMemcachedContainerManager {
|
||||
.withDockerNetwork(config.services().elasticache().dockerNetwork())
|
||||
.withLogRotation()
|
||||
.withLabels(ContainerStorageHelper.resourceIdentityLabels(
|
||||
"elasticache", clusterId, regionResolver.getAccountId(), regionResolver.getDefaultRegion()));
|
||||
"elasticache", clusterId, regionResolver.getAccountId(), effectiveRegion));
|
||||
|
||||
if (!containerDetector.isRunningInContainer()) {
|
||||
specBuilder.withDynamicPort(BACKEND_PORT);
|
||||
@@ -149,10 +151,9 @@ public class ElastiCacheMemcachedContainerManager {
|
||||
: info.containerId();
|
||||
String logGroup = "/aws/elasticache/cluster/" + clusterId + "/engine-log";
|
||||
String logStream = logStreamer.generateLogStreamName(shortId);
|
||||
String region = regionResolver.getDefaultRegion();
|
||||
|
||||
Closeable logHandle = logStreamer.attach(
|
||||
info.containerId(), logGroup, logStream, region, "elasticache-memcached:" + clusterId);
|
||||
info.containerId(), logGroup, logStream, effectiveRegion, "elasticache-memcached:" + clusterId);
|
||||
handle.setLogStream(logHandle);
|
||||
|
||||
waitForBackendReady(clusterId, endpoint.host(), endpoint.port());
|
||||
|
||||
@@ -20,6 +20,8 @@ public class CacheCluster {
|
||||
private String cacheNodeType;
|
||||
private int numCacheNodes;
|
||||
private String arn;
|
||||
// Persisted only: a Memcached cluster carries no ARN, so its region is kept here for a restart.
|
||||
private String region;
|
||||
private String cacheParameterGroupName;
|
||||
private String cacheSubnetGroupName;
|
||||
private AuthMode authMode;
|
||||
@@ -79,6 +81,9 @@ public class CacheCluster {
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
|
||||
public String getCacheParameterGroupName() { return cacheParameterGroupName; }
|
||||
public void setCacheParameterGroupName(String cacheParameterGroupName) { this.cacheParameterGroupName = cacheParameterGroupName; }
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class DocDbServiceTest {
|
||||
assertEquals(27017, cluster.getPort());
|
||||
assertTrue(cluster.getDbClusterArn().contains("mock-cluster"));
|
||||
|
||||
verify(containerManager, never()).start(anyString(), anyString(), anyString(), anyString());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), anyString(), anyString(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,7 +166,7 @@ class DocDbServiceTest {
|
||||
when(config.hostname()).thenReturn(java.util.Optional.of("localhost"));
|
||||
|
||||
DocDbContainerManager noDaemonContainerManager = Mockito.mock(DocDbContainerManager.class);
|
||||
when(noDaemonContainerManager.tryStart(anyString(), anyString(), anyString(), anyString()))
|
||||
when(noDaemonContainerManager.tryStart(anyString(), anyString(), anyString(), anyString(), any()))
|
||||
.thenReturn(null);
|
||||
RegionResolver regionResolver = new RegionResolver("us-east-1", "000000000000");
|
||||
DocDbService noDaemonService = new DocDbService(config, regionResolver, noDaemonContainerManager, storageFactory,
|
||||
@@ -520,7 +520,7 @@ class DocDbServiceTest {
|
||||
e = refused(new DocDbClusterSettings(null, null, null, null, null, null, "02:00-02:30", "tue:02:15-tue:02:45", null));
|
||||
assertEquals("The backup window and maintenance window must not overlap.", e.getMessage());
|
||||
assertThrows(AwsException.class, () -> docDbService.getDbCluster("c1"));
|
||||
verify(containerManager, never()).tryStart(any(), any(), any(), any());
|
||||
verify(containerManager, never()).tryStart(any(), any(), any(), any(), any());
|
||||
|
||||
// a window given alone is paired with a default clear of it
|
||||
docDbService.createDbCluster("alone", "5.0.0", "u", "pw", false,
|
||||
|
||||
+5
-5
@@ -46,7 +46,7 @@ class DocDbContainerManagerTest {
|
||||
DocDbContainerManager manager = newManager(lifecycleManager);
|
||||
|
||||
for (int attempt = 0; attempt < 3; attempt++) {
|
||||
assertNull(manager.tryStart("cluster1", "mongo:7.0", "admin", "secret"),
|
||||
assertNull(manager.tryStart("cluster1", "mongo:7.0", "admin", "secret", "us-east-1"),
|
||||
"attempt " + attempt + " should report unavailable");
|
||||
}
|
||||
assertFalse(manager.isDockerReachable());
|
||||
@@ -65,7 +65,7 @@ class DocDbContainerManagerTest {
|
||||
DocDbContainerManager manager = newManager(lifecycleManager);
|
||||
|
||||
RuntimeException failure = assertThrows(RuntimeException.class,
|
||||
() -> manager.tryStart("cluster1", "mongo:7.0", "admin", "secret"));
|
||||
() -> manager.tryStart("cluster1", "mongo:7.0", "admin", "secret", "us-east-1"));
|
||||
assertEquals("no such image: mongo:7.0", failure.getMessage());
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class DocDbContainerManagerTest {
|
||||
|
||||
DocDbContainerManager manager = newManager(lifecycleManager);
|
||||
|
||||
DocDbContainerHandle handle = manager.tryStart("cluster1", "mongo:7.0", "admin", "secret");
|
||||
DocDbContainerHandle handle = manager.tryStart("cluster1", "mongo:7.0", "admin", "secret", "us-east-1");
|
||||
|
||||
assertEquals("container-id", handle.getContainerId());
|
||||
assertEquals(serverSocket.getLocalPort(), handle.getPort());
|
||||
@@ -138,14 +138,14 @@ class DocDbContainerManagerTest {
|
||||
logStreamer, mock(ContainerDetector.class), config,
|
||||
new RegionResolver("us-east-1", "000000000000"));
|
||||
|
||||
manager.start("cluster1", "mongo:7.0", "admin", "secret");
|
||||
manager.start("cluster1", "mongo:7.0", "admin", "secret", "eu-west-1");
|
||||
|
||||
verify(builder).withLabels(Map.of(
|
||||
"io.floci", "aws",
|
||||
"io.floci.service", "docdb",
|
||||
"io.floci.resource-id", "cluster1",
|
||||
"io.floci.account", "000000000000",
|
||||
"io.floci.region", "us-east-1"));
|
||||
"io.floci.region", "eu-west-1"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+42
-26
@@ -50,7 +50,7 @@ class ElastiCacheMemcachedServiceTest {
|
||||
when(config.hostname()).thenReturn(Optional.of("localhost"));
|
||||
|
||||
when(storageFactory.create(anyString(), anyString(), any())).thenAnswer(inv -> AccountAwareStorageBackend.inMemory("000000000000"));
|
||||
when(containerManager.tryStart(anyString(), anyString()))
|
||||
when(containerManager.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "cluster", "localhost", 11211));
|
||||
|
||||
service = new ElastiCacheMemcachedService(containerManager, storageFactory, config, provisioningIds);
|
||||
@@ -58,7 +58,7 @@ class ElastiCacheMemcachedServiceTest {
|
||||
|
||||
@Test
|
||||
void createClusterReturnsAvailableCluster() {
|
||||
CacheCluster cluster = service.createCacheCluster("my-cluster");
|
||||
CacheCluster cluster = service.createCacheCluster("my-cluster", "us-east-1");
|
||||
|
||||
assertEquals("my-cluster", cluster.getCacheClusterId());
|
||||
assertEquals(CacheClusterStatus.AVAILABLE, cluster.getCacheClusterStatus());
|
||||
@@ -68,9 +68,9 @@ class ElastiCacheMemcachedServiceTest {
|
||||
|
||||
@Test
|
||||
void createDuplicateClusterThrows() {
|
||||
service.createCacheCluster("my-cluster");
|
||||
service.createCacheCluster("my-cluster", "us-east-1");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () -> service.createCacheCluster("my-cluster"));
|
||||
AwsException ex = assertThrows(AwsException.class, () -> service.createCacheCluster("my-cluster", "us-east-1"));
|
||||
assertEquals("CacheClusterAlreadyExists", ex.getErrorCode());
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ class ElastiCacheMemcachedServiceTest {
|
||||
assertTrue(provisioningIds.claim("racing-cluster"));
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> service.createCacheCluster("racing-cluster"));
|
||||
() -> service.createCacheCluster("racing-cluster", "us-east-1"));
|
||||
assertEquals("CacheClusterAlreadyExists", ex.getErrorCode());
|
||||
verify(containerManager, never()).tryStart(eq("racing-cluster"), anyString());
|
||||
verify(containerManager, never()).tryStart(eq("racing-cluster"), anyString(), any());
|
||||
|
||||
// The refusal must not have released the claim the other create still holds.
|
||||
assertFalse(provisioningIds.claim("racing-cluster"));
|
||||
@@ -93,7 +93,7 @@ class ElastiCacheMemcachedServiceTest {
|
||||
// Once that create finishes and releases, the id is free again.
|
||||
provisioningIds.release("racing-cluster");
|
||||
assertEquals("racing-cluster",
|
||||
service.createCacheCluster("racing-cluster").getCacheClusterId());
|
||||
service.createCacheCluster("racing-cluster", "us-east-1").getCacheClusterId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,8 +104,8 @@ class ElastiCacheMemcachedServiceTest {
|
||||
|
||||
@Test
|
||||
void listClustersReturnsAll() {
|
||||
service.createCacheCluster("cluster-a");
|
||||
service.createCacheCluster("cluster-b");
|
||||
service.createCacheCluster("cluster-a", "us-east-1");
|
||||
service.createCacheCluster("cluster-b", "us-east-1");
|
||||
|
||||
Collection<CacheCluster> list = service.listCacheClusters(null);
|
||||
assertEquals(2, list.size());
|
||||
@@ -113,8 +113,8 @@ class ElastiCacheMemcachedServiceTest {
|
||||
|
||||
@Test
|
||||
void listClustersFiltersById() {
|
||||
service.createCacheCluster("cluster-a");
|
||||
service.createCacheCluster("cluster-b");
|
||||
service.createCacheCluster("cluster-a", "us-east-1");
|
||||
service.createCacheCluster("cluster-b", "us-east-1");
|
||||
|
||||
Collection<CacheCluster> list = service.listCacheClusters("cluster-a");
|
||||
assertEquals(1, list.size());
|
||||
@@ -123,7 +123,7 @@ class ElastiCacheMemcachedServiceTest {
|
||||
|
||||
@Test
|
||||
void deleteClusterRemovesIt() {
|
||||
service.createCacheCluster("my-cluster");
|
||||
service.createCacheCluster("my-cluster", "us-east-1");
|
||||
service.deleteCacheCluster("my-cluster");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () -> service.getCacheCluster("my-cluster"));
|
||||
@@ -144,14 +144,14 @@ class ElastiCacheMemcachedServiceTest {
|
||||
when(config.hostname()).thenReturn(Optional.empty());
|
||||
|
||||
when(storageFactory.create(anyString(), anyString(), any())).thenAnswer(inv -> AccountAwareStorageBackend.inMemory("000000000000"));
|
||||
when(containerManager.tryStart(anyString(), anyString()))
|
||||
when(containerManager.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "cluster", "172.20.0.10", 11211));
|
||||
|
||||
ElastiCacheMemcachedService containerModeService =
|
||||
new ElastiCacheMemcachedService(containerManager, storageFactory, config,
|
||||
new ElastiCacheProvisioningIds());
|
||||
|
||||
CacheCluster cluster = containerModeService.createCacheCluster("container-cluster");
|
||||
CacheCluster cluster = containerModeService.createCacheCluster("container-cluster", "us-east-1");
|
||||
|
||||
assertEquals("172.20.0.10", cluster.getConfigurationEndpoint().address());
|
||||
}
|
||||
@@ -161,9 +161,9 @@ class ElastiCacheMemcachedServiceTest {
|
||||
// tryStart() returns null when no Docker daemon is reachable. The cache cluster record is
|
||||
// metadata, so the create still succeeds and the cluster reaches 'available' on the first
|
||||
// describe (what SDK/Terraform waiters poll), on Memcached's well-known port.
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenReturn(null);
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenReturn(null);
|
||||
|
||||
CacheCluster cluster = service.createCacheCluster("no-docker-cluster");
|
||||
CacheCluster cluster = service.createCacheCluster("no-docker-cluster", "us-east-1");
|
||||
|
||||
assertEquals(CacheClusterStatus.AVAILABLE, cluster.getCacheClusterStatus());
|
||||
assertEquals("localhost", cluster.getConfigurationEndpoint().address());
|
||||
@@ -176,22 +176,38 @@ class ElastiCacheMemcachedServiceTest {
|
||||
verify(containerManager, never()).stop(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void restorePersistedRuntimeRestartsTheContainerInTheClustersRegion() {
|
||||
StorageFactory storageFactory = sharedStorageFactory();
|
||||
ElastiCacheMemcachedContainerManager beforeRestart = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(beforeRestart.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "eu-cluster", "localhost", 32770));
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("eu-cluster", "eu-west-1");
|
||||
|
||||
ElastiCacheMemcachedContainerManager restarted = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(restarted.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid2", "eu-cluster", "localhost", 32771));
|
||||
serviceWith(storageFactory, restarted).restorePersistedRuntime().join();
|
||||
|
||||
verify(restarted).tryStart(eq("eu-cluster"), anyString(), eq("eu-west-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void restorePersistedRuntimeRestartsTheContainerAndRepointsTheEndpoint() {
|
||||
StorageFactory storageFactory = sharedStorageFactory();
|
||||
ElastiCacheMemcachedContainerManager beforeRestart = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(beforeRestart.tryStart(anyString(), anyString()))
|
||||
when(beforeRestart.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "my-cluster", "localhost", 32770));
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("my-cluster");
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("my-cluster", "us-east-1");
|
||||
|
||||
ElastiCacheMemcachedContainerManager restarted = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(restarted.tryStart(anyString(), anyString()))
|
||||
when(restarted.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid2", "my-cluster", "localhost", 32771));
|
||||
ElastiCacheMemcachedService restartedService = serviceWith(storageFactory, restarted);
|
||||
|
||||
restartedService.restorePersistedRuntime().join();
|
||||
|
||||
verify(restarted).tryStart(eq("my-cluster"), anyString());
|
||||
verify(restarted).tryStart(eq("my-cluster"), anyString(), any());
|
||||
CacheCluster cluster = restartedService.getCacheCluster("my-cluster");
|
||||
assertEquals(CacheClusterStatus.AVAILABLE, cluster.getCacheClusterStatus());
|
||||
assertEquals(32771, cluster.getConfigurationEndpoint().port(),
|
||||
@@ -202,12 +218,12 @@ class ElastiCacheMemcachedServiceTest {
|
||||
void memcachedRestoreFailureReportsRestoreFailed() {
|
||||
StorageFactory storageFactory = sharedStorageFactory();
|
||||
ElastiCacheMemcachedContainerManager beforeRestart = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(beforeRestart.tryStart(anyString(), anyString()))
|
||||
when(beforeRestart.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "my-cluster", "localhost", 11211));
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("my-cluster");
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("my-cluster", "us-east-1");
|
||||
|
||||
ElastiCacheMemcachedContainerManager restarted = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(restarted.tryStart(anyString(), anyString()))
|
||||
when(restarted.tryStart(anyString(), anyString(), any()))
|
||||
.thenThrow(new RuntimeException("container failed"));
|
||||
ElastiCacheMemcachedService restartedService = serviceWith(storageFactory, restarted);
|
||||
|
||||
@@ -223,9 +239,9 @@ class ElastiCacheMemcachedServiceTest {
|
||||
void restoreDoesNotResurrectAClusterDeletedWhileItWasRestoring() {
|
||||
StorageFactory storageFactory = sharedStorageFactory();
|
||||
ElastiCacheMemcachedContainerManager beforeRestart = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(beforeRestart.tryStart(anyString(), anyString()))
|
||||
when(beforeRestart.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "my-cluster", "localhost", 32770));
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("my-cluster");
|
||||
serviceWith(storageFactory, beforeRestart).createCacheCluster("my-cluster", "us-east-1");
|
||||
|
||||
ElastiCacheMemcachedContainerManager restarted = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
ElastiCacheMemcachedService restartedService = serviceWith(storageFactory, restarted);
|
||||
@@ -233,7 +249,7 @@ class ElastiCacheMemcachedServiceTest {
|
||||
new ElastiCacheContainerHandle("cid2", "my-cluster", "localhost", 32771);
|
||||
// The delete lands in the window the cluster's monitor closes: the container is up, the
|
||||
// record has not been written back yet.
|
||||
when(restarted.tryStart(anyString(), anyString())).thenAnswer(inv -> {
|
||||
when(restarted.tryStart(anyString(), anyString(), any())).thenAnswer(inv -> {
|
||||
restartedService.deleteCacheCluster("my-cluster");
|
||||
return restoredHandle;
|
||||
});
|
||||
|
||||
+3
-3
@@ -465,7 +465,7 @@ class ElastiCacheQueryHandlerTest {
|
||||
assertEquals(1, captor.getValue().numCacheNodes());
|
||||
assertEquals(6379, captor.getValue().port());
|
||||
assertEquals("us-east-1", captor.getValue().region());
|
||||
verify(memcachedService, never()).createCacheCluster(anyString());
|
||||
verify(memcachedService, never()).createCacheCluster(anyString(), any());
|
||||
|
||||
String body = (String) response.getEntity();
|
||||
assertTrue(body.contains("<Engine>redis</Engine>"), body);
|
||||
@@ -523,7 +523,7 @@ class ElastiCacheQueryHandlerTest {
|
||||
|
||||
@Test
|
||||
void createCacheCluster_memcachedStillGoesToTheMemcachedService() {
|
||||
when(memcachedService.createCacheCluster("mc")).thenReturn(new CacheCluster(
|
||||
when(memcachedService.createCacheCluster(eq("mc"), any())).thenReturn(new CacheCluster(
|
||||
"mc", CacheClusterStatus.AVAILABLE, "memcached", "1.6.22",
|
||||
new Endpoint("localhost", 11211), Instant.now()));
|
||||
|
||||
@@ -533,7 +533,7 @@ class ElastiCacheQueryHandlerTest {
|
||||
|
||||
String body = (String) handler.handle("CreateCacheCluster", p, "us-east-1").getEntity();
|
||||
|
||||
verify(memcachedService).createCacheCluster("mc");
|
||||
verify(memcachedService).createCacheCluster(eq("mc"), eq("us-east-1"));
|
||||
verify(service, never()).createCacheCluster(any());
|
||||
assertTrue(body.contains(
|
||||
"<ConfigurationEndpoint><Address>localhost</Address><Port>11211</Port></ConfigurationEndpoint>"), body);
|
||||
|
||||
+56
-56
@@ -96,8 +96,8 @@ class ElastiCacheServiceTest {
|
||||
backendsByFile.computeIfAbsent(inv.getArgument(1),
|
||||
file -> AccountAwareStorageBackend.inMemory("000000000000")));
|
||||
memcachedContainerManager = mock(ElastiCacheMemcachedContainerManager.class);
|
||||
when(memcachedContainerManager.tryStart(anyString(), anyString())).thenReturn(null);
|
||||
when(containerManager.tryStart(anyString(), anyString()))
|
||||
when(memcachedContainerManager.tryStart(anyString(), anyString(), any())).thenReturn(null);
|
||||
when(containerManager.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379));
|
||||
doNothing().when(proxyManager).startProxy(anyString(), any(), anyInt(), anyString(), anyInt(), any());
|
||||
ec2Service = mock(Ec2Service.class);
|
||||
@@ -129,7 +129,7 @@ class ElastiCacheServiceTest {
|
||||
when(ec.defaultImage()).thenReturn("valkey/valkey:8");
|
||||
when(cfg.hostname()).thenReturn(Optional.of("localhost"));
|
||||
when(sf.create(anyString(), anyString(), any())).thenAnswer(inv -> AccountAwareStorageBackend.inMemory("000000000000"));
|
||||
when(cm.start(anyString(), anyString()))
|
||||
when(cm.start(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379));
|
||||
doNothing().when(pm).startProxy(anyString(), any(), anyInt(), anyString(), anyInt(), any());
|
||||
ElastiCacheService svc = new ElastiCacheService(cm, pm, mock(ValkeyClusterFormation.class),
|
||||
@@ -298,7 +298,7 @@ class ElastiCacheServiceTest {
|
||||
void failedProvisioningRollsBackContainerAndReleasesProxyPort() {
|
||||
ElastiCacheContainerHandle handle =
|
||||
new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379);
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenReturn(handle);
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenReturn(handle);
|
||||
|
||||
// Proxy startup blows up after the port is reserved and the container is started.
|
||||
doThrow(new RuntimeException("proxy boom"))
|
||||
@@ -327,7 +327,7 @@ class ElastiCacheServiceTest {
|
||||
void failedContainerStartupCleansUpContainerByIdAndReleasesPort() {
|
||||
// Models a readiness timeout: start() throws without ever returning a handle.
|
||||
doThrow(new RuntimeException("readiness boom"))
|
||||
.when(containerManager).tryStart(eq("grp"), anyString());
|
||||
.when(containerManager).tryStart(eq("grp"), anyString(), any());
|
||||
|
||||
assertThrows(RuntimeException.class,
|
||||
() -> service.createReplicationGroup("grp", "test", AuthMode.PASSWORD, null, "us-east-1"));
|
||||
@@ -336,7 +336,7 @@ class ElastiCacheServiceTest {
|
||||
verify(containerManager).stopByGroupId("grp");
|
||||
|
||||
// The reserved proxy port was still released: a subsequent successful create reuses the base port.
|
||||
when(containerManager.tryStart(anyString(), anyString()))
|
||||
when(containerManager.tryStart(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "grp2", "localhost", 6379));
|
||||
ReplicationGroup recovered =
|
||||
service.createReplicationGroup("grp2", "test", AuthMode.PASSWORD, null, "us-east-1");
|
||||
@@ -456,7 +456,7 @@ class ElastiCacheServiceTest {
|
||||
}
|
||||
|
||||
private void stubPerNodeContainers() {
|
||||
when(containerManager.start(anyString(), anyString(), any())).thenAnswer(inv ->
|
||||
when(containerManager.start(anyString(), anyString(), any(), any())).thenAnswer(inv ->
|
||||
new ElastiCacheContainerHandle("cid-" + inv.getArgument(0, String.class),
|
||||
inv.getArgument(0, String.class), "localhost", 6379));
|
||||
}
|
||||
@@ -486,7 +486,7 @@ class ElastiCacheServiceTest {
|
||||
assertEquals(16379, group.getConfigurationEndpoint().port());
|
||||
|
||||
verify(clusterFormation).form(eq("grp"), any(), eq(2));
|
||||
verify(containerManager, times(4)).start(anyString(), anyString(), any());
|
||||
verify(containerManager, times(4)).start(anyString(), anyString(), any(), any());
|
||||
verify(proxyManager, times(4)).startProxy(anyString(), any(), anyInt(), anyString(), anyInt(), any());
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
assertEquals("NodeGroupsPerReplicationGroupQuotaExceeded", ex.getErrorCode());
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -521,7 +521,7 @@ class ElastiCacheServiceTest {
|
||||
assertEquals(List.of("grp-001"),
|
||||
service.memberCacheClusters(group).stream()
|
||||
.map(ElastiCacheService.MemberCacheCluster::cacheClusterId).toList());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -567,7 +567,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> flags = ArgumentCaptor.forClass(List.class);
|
||||
verify(containerManager).start(eq("grp-0001-001"), anyString(), flags.capture());
|
||||
verify(containerManager).start(eq("grp-0001-001"), anyString(), flags.capture(), any());
|
||||
List<String> captured = flags.getValue();
|
||||
assertEquals("localhost", flagValue(captured, "--cluster-announce-hostname"));
|
||||
assertEquals("hostname", flagValue(captured, "--cluster-preferred-endpoint-type"));
|
||||
@@ -584,7 +584,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> flags = ArgumentCaptor.forClass(List.class);
|
||||
verify(containerManager).start(eq("grp-0001-001"), anyString(), flags.capture());
|
||||
verify(containerManager).start(eq("grp-0001-001"), anyString(), flags.capture(), any());
|
||||
assertEquals("localhost.floci.io", flagValue(flags.getValue(), "--cluster-announce-hostname"));
|
||||
assertEquals("localhost.floci.io", group.getConfigurationEndpoint().address());
|
||||
}
|
||||
@@ -623,15 +623,15 @@ class ElastiCacheServiceTest {
|
||||
}
|
||||
|
||||
private static void stubPerNodeContainers(ElastiCacheContainerManager containerManager) {
|
||||
when(containerManager.start(anyString(), anyString(), any())).thenAnswer(inv ->
|
||||
when(containerManager.start(anyString(), anyString(), any(), any())).thenAnswer(inv ->
|
||||
new ElastiCacheContainerHandle("cid-" + inv.getArgument(0, String.class),
|
||||
inv.getArgument(0, String.class), "localhost", 6379));
|
||||
when(containerManager.start(anyString(), anyString()))
|
||||
when(containerManager.start(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379));
|
||||
}
|
||||
|
||||
private static void stubSingleNodeContainer(ElastiCacheContainerManager containerManager) {
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenAnswer(inv ->
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenAnswer(inv ->
|
||||
new ElastiCacheContainerHandle("cid-" + inv.getArgument(0, String.class),
|
||||
inv.getArgument(0, String.class), "localhost", 6379));
|
||||
}
|
||||
@@ -658,7 +658,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
restarted.restorePersistedRuntime().join();
|
||||
|
||||
verify(restartedContainers).tryStart(eq("grp"), anyString());
|
||||
verify(restartedContainers).tryStart(eq("grp"), anyString(), any());
|
||||
verify(restartedProxies).startProxy(eq("grp"), eq(AuthMode.PASSWORD), eq(16379),
|
||||
eq("localhost"), eq(6379), any());
|
||||
ReplicationGroup restored = restarted.getReplicationGroup("grp");
|
||||
@@ -679,7 +679,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
ElastiCacheContainerManager restartedContainers = mock(ElastiCacheContainerManager.class);
|
||||
// Only the restore fails: the create that checks the port was freed must still get through.
|
||||
when(restartedContainers.tryStart(eq("grp"), anyString()))
|
||||
when(restartedContainers.tryStart(eq("grp"), anyString(), any()))
|
||||
.thenThrow(new RuntimeException("container failed"));
|
||||
ElastiCacheProxyManager restartedProxies = mock(ElastiCacheProxyManager.class);
|
||||
ElastiCacheService restarted = serviceWith(storageFactory, restartedContainers,
|
||||
@@ -704,7 +704,7 @@ class ElastiCacheServiceTest {
|
||||
StorageFactory storageFactory = storageWithSingleNodeGroup("grp");
|
||||
|
||||
ElastiCacheContainerManager restartedContainers = mock(ElastiCacheContainerManager.class);
|
||||
when(restartedContainers.tryStart(anyString(), anyString())).thenReturn(null);
|
||||
when(restartedContainers.tryStart(anyString(), anyString(), any())).thenReturn(null);
|
||||
ElastiCacheProxyManager restartedProxies = mock(ElastiCacheProxyManager.class);
|
||||
ElastiCacheService restarted = serviceWith(storageFactory, restartedContainers,
|
||||
restartedProxies, mock(ValkeyClusterFormation.class));
|
||||
@@ -730,7 +730,7 @@ class ElastiCacheServiceTest {
|
||||
new ElastiCacheContainerHandle("cid-grp-restored", "grp", "localhost", 6379);
|
||||
// The delete lands in the window the group's monitor closes: the container is up, the
|
||||
// record has not been written back yet.
|
||||
when(restartedContainers.tryStart(eq("grp"), anyString())).thenAnswer(inv -> {
|
||||
when(restartedContainers.tryStart(eq("grp"), anyString(), any())).thenAnswer(inv -> {
|
||||
restarted.deleteReplicationGroup("grp");
|
||||
// Takes the port that delete just freed, so a restore that released it a second
|
||||
// time would hand the same port out twice.
|
||||
@@ -768,7 +768,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
restarted.restorePersistedRuntime().join();
|
||||
|
||||
verify(restartedContainers, never()).tryStart(anyString(), anyString());
|
||||
verify(restartedContainers, never()).tryStart(anyString(), anyString(), any());
|
||||
assertEquals(ReplicationGroupStatus.DELETING, restarted.getReplicationGroup("grp").getStatus());
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
restarted.restorePersistedRuntime().join();
|
||||
|
||||
verify(restartedContainers, times(4)).start(anyString(), anyString(), any());
|
||||
verify(restartedContainers, times(4)).start(anyString(), anyString(), any(), any());
|
||||
verify(restartedFormation).form(eq("grp"), any(), eq(2));
|
||||
verify(restartedProxies, times(4)).startProxy(anyString(), any(), anyInt(), anyString(), anyInt(), any());
|
||||
ReplicationGroup restored = restarted.getReplicationGroup("grp");
|
||||
@@ -814,9 +814,9 @@ class ElastiCacheServiceTest {
|
||||
.createReplicationGroup(clusterRequest("grp", 2, 0));
|
||||
|
||||
ElastiCacheContainerManager restartedContainers = mock(ElastiCacheContainerManager.class);
|
||||
when(restartedContainers.start(anyString(), anyString(), any()))
|
||||
when(restartedContainers.start(anyString(), anyString(), any(), any()))
|
||||
.thenThrow(new RuntimeException("docker down"));
|
||||
when(restartedContainers.start(anyString(), anyString()))
|
||||
when(restartedContainers.start(anyString(), anyString(), any()))
|
||||
.thenReturn(new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379));
|
||||
ElastiCacheProxyManager restartedProxies = mock(ElastiCacheProxyManager.class);
|
||||
ElastiCacheService restarted = serviceWith(storageFactory, restartedContainers,
|
||||
@@ -848,7 +848,7 @@ class ElastiCacheServiceTest {
|
||||
ElastiCacheContainerManager restartedContainers = mock(ElastiCacheContainerManager.class);
|
||||
CountDownLatch restoreStarted = new CountDownLatch(1);
|
||||
CountDownLatch releaseRestore = new CountDownLatch(1);
|
||||
when(restartedContainers.start(anyString(), anyString(), any())).thenAnswer(inv -> {
|
||||
when(restartedContainers.start(anyString(), anyString(), any(), any())).thenAnswer(inv -> {
|
||||
restoreStarted.countDown();
|
||||
releaseRestore.await(5, TimeUnit.SECONDS);
|
||||
return new ElastiCacheContainerHandle("cid-" + inv.getArgument(0, String.class),
|
||||
@@ -872,7 +872,7 @@ class ElastiCacheServiceTest {
|
||||
void concurrentCreateForSameGroupIdIsRejectedWhileFirstIsProvisioning() throws InterruptedException {
|
||||
CountDownLatch startedLatch = new CountDownLatch(1);
|
||||
CountDownLatch releaseLatch = new CountDownLatch(1);
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenAnswer(inv -> {
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenAnswer(inv -> {
|
||||
startedLatch.countDown();
|
||||
assertTrue(releaseLatch.await(5, TimeUnit.SECONDS), "test timed out waiting for release");
|
||||
return new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379);
|
||||
@@ -944,7 +944,7 @@ class ElastiCacheServiceTest {
|
||||
assertEquals("InvalidParameterValue", missing.getErrorCode());
|
||||
assertEquals("KMS key does not exist with key id: alias/does-not-exist", missing.getMessage());
|
||||
assertThrows(AwsException.class, () -> service.getReplicationGroup("g1"));
|
||||
verify(containerManager, never()).start(anyString(), anyString());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any());
|
||||
|
||||
AwsException combination = assertThrows(AwsException.class, () -> service.createReplicationGroup(
|
||||
"g1", "d", AuthMode.NO_AUTH, null, "us-east-1",
|
||||
@@ -1065,8 +1065,8 @@ class ElastiCacheServiceTest {
|
||||
|
||||
assertEquals("CacheParameterGroupNotFound", ex.getErrorCode());
|
||||
assertEquals(404, ex.getHttpStatus());
|
||||
verify(containerManager, never()).start(anyString(), anyString());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any());
|
||||
verify(containerManager, never()).start(anyString(), anyString(), any(), any());
|
||||
assertThrows(AwsException.class, () -> service.getReplicationGroup("grp"));
|
||||
}
|
||||
|
||||
@@ -1092,7 +1092,7 @@ class ElastiCacheServiceTest {
|
||||
service.createCacheParameterGroup("custom-pg", "redis7", "in use", Map.of());
|
||||
CountDownLatch startedLatch = new CountDownLatch(1);
|
||||
CountDownLatch releaseLatch = new CountDownLatch(1);
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenAnswer(inv -> {
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenAnswer(inv -> {
|
||||
startedLatch.countDown();
|
||||
assertTrue(releaseLatch.await(5, TimeUnit.SECONDS), "test timed out waiting for release");
|
||||
return new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379);
|
||||
@@ -1142,7 +1142,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
CountDownLatch startedLatch = new CountDownLatch(1);
|
||||
CountDownLatch releaseLatch = new CountDownLatch(1);
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenAnswer(inv -> {
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenAnswer(inv -> {
|
||||
startedLatch.countDown();
|
||||
assertTrue(releaseLatch.await(5, TimeUnit.SECONDS), "test timed out waiting for release");
|
||||
return new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379);
|
||||
@@ -1177,7 +1177,7 @@ class ElastiCacheServiceTest {
|
||||
@Test
|
||||
void aFailedCreateReleasesItsClaimOnTheParameterGroup() {
|
||||
service.createCacheParameterGroup("custom-pg", "redis7", "in use", Map.of());
|
||||
when(containerManager.tryStart(anyString(), anyString()))
|
||||
when(containerManager.tryStart(anyString(), anyString(), any()))
|
||||
.thenThrow(new RuntimeException("docker is down"));
|
||||
|
||||
assertThrows(RuntimeException.class,
|
||||
@@ -1231,7 +1231,7 @@ class ElastiCacheServiceTest {
|
||||
assertEquals(16379, cluster.getConfigurationEndpoint().port());
|
||||
assertEquals("arn:aws:elasticache:us-east-1:000000000000:cluster:tf-redis", cluster.getArn());
|
||||
|
||||
verify(containerManager).tryStart(eq("tf-redis"), eq("valkey/valkey:8"));
|
||||
verify(containerManager).tryStart(eq("tf-redis"), eq("valkey/valkey:8"), any());
|
||||
verify(proxyManager).startProxy(eq("tf-redis"), eq(AuthMode.NO_AUTH), eq(16379),
|
||||
eq("localhost"), eq(6379), any());
|
||||
|
||||
@@ -1252,7 +1252,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
assertEquals("NumCacheNodes should be 1 if engine is redis", ex.getMessage());
|
||||
verify(containerManager, never()).tryStart(eq("too-big"), anyString());
|
||||
verify(containerManager, never()).tryStart(eq("too-big"), anyString(), any());
|
||||
assertTrue(service.findCacheClusters("too-big").isEmpty());
|
||||
}
|
||||
|
||||
@@ -1327,7 +1327,7 @@ class ElastiCacheServiceTest {
|
||||
assertEquals("CacheClusterAlreadyExists", ex.getErrorCode());
|
||||
// the live group kept its container and its proxy: nothing was started or removed for the
|
||||
// refused request
|
||||
verify(containerManager, times(1)).tryStart(eq("shared"), anyString());
|
||||
verify(containerManager, times(1)).tryStart(eq("shared"), anyString(), any());
|
||||
verify(containerManager, never()).stopByGroupId("shared");
|
||||
verify(proxyManager, times(1)).startProxy(eq("shared"), any(), anyInt(), anyString(), anyInt(), any());
|
||||
assertEquals("shared", service.getReplicationGroup("shared").getReplicationGroupId());
|
||||
@@ -1341,7 +1341,7 @@ class ElastiCacheServiceTest {
|
||||
() -> service.createReplicationGroup("shared", "d", AuthMode.NO_AUTH, null, "us-east-1"));
|
||||
|
||||
assertEquals("ReplicationGroupAlreadyExistsFault", ex.getErrorCode());
|
||||
verify(containerManager, times(1)).tryStart(eq("shared"), anyString());
|
||||
verify(containerManager, times(1)).tryStart(eq("shared"), anyString(), any());
|
||||
verify(containerManager, never()).stopByGroupId("shared");
|
||||
assertEquals("shared", service.findCacheClusters("shared").getFirst().getCacheClusterId());
|
||||
}
|
||||
@@ -1353,7 +1353,7 @@ class ElastiCacheServiceTest {
|
||||
// would stopByGroupId the winner's container out from under it.
|
||||
CountDownLatch startedLatch = new CountDownLatch(1);
|
||||
CountDownLatch releaseLatch = new CountDownLatch(1);
|
||||
when(containerManager.tryStart(eq("raced"), anyString())).thenAnswer(inv -> {
|
||||
when(containerManager.tryStart(eq("raced"), anyString(), any())).thenAnswer(inv -> {
|
||||
startedLatch.countDown();
|
||||
assertTrue(releaseLatch.await(5, TimeUnit.SECONDS), "test timed out waiting for release");
|
||||
return new ElastiCacheContainerHandle("cid", "raced", "localhost", 6379);
|
||||
@@ -1372,14 +1372,14 @@ class ElastiCacheServiceTest {
|
||||
releaseLatch.countDown();
|
||||
winner.join(5000);
|
||||
assertEquals("raced", service.findCacheClusters("raced").getFirst().getCacheClusterId());
|
||||
verify(containerManager, times(1)).tryStart(eq("raced"), anyString());
|
||||
verify(containerManager, times(1)).tryStart(eq("raced"), anyString(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aReplicationGroupCreateIsBlockedByAnInFlightCacheClusterCreateOfThatId() throws Exception {
|
||||
CountDownLatch startedLatch = new CountDownLatch(1);
|
||||
CountDownLatch releaseLatch = new CountDownLatch(1);
|
||||
when(containerManager.tryStart(eq("raced"), anyString())).thenAnswer(inv -> {
|
||||
when(containerManager.tryStart(eq("raced"), anyString(), any())).thenAnswer(inv -> {
|
||||
startedLatch.countDown();
|
||||
assertTrue(releaseLatch.await(5, TimeUnit.SECONDS), "test timed out waiting for release");
|
||||
return new ElastiCacheContainerHandle("cid", "raced", "localhost", 6379);
|
||||
@@ -1442,7 +1442,7 @@ class ElastiCacheServiceTest {
|
||||
"us-east-1", Map.of()))).getErrorCode());
|
||||
|
||||
// a refused request provisions nothing
|
||||
verify(containerManager, never()).tryStart(eq("bad-cc"), anyString());
|
||||
verify(containerManager, never()).tryStart(eq("bad-cc"), anyString(), any());
|
||||
assertTrue(service.findCacheClusters("bad-cc").isEmpty());
|
||||
}
|
||||
|
||||
@@ -1508,7 +1508,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
restarted.restorePersistedRuntime().join();
|
||||
|
||||
verify(restartedContainers).tryStart(eq("tf-redis"), anyString());
|
||||
verify(restartedContainers).tryStart(eq("tf-redis"), anyString(), any());
|
||||
verify(restartedProxies).startProxy(eq("tf-redis"), eq(AuthMode.PASSWORD), eq(16379),
|
||||
eq("localhost"), eq(6379), any());
|
||||
CacheCluster restored = restarted.findCacheClusters("tf-redis").getFirst();
|
||||
@@ -1524,7 +1524,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
ElastiCacheContainerManager restartedContainers = mock(ElastiCacheContainerManager.class);
|
||||
// Only the restore fails: the create that checks the port was freed must still get through.
|
||||
when(restartedContainers.tryStart(eq("tf-redis"), anyString()))
|
||||
when(restartedContainers.tryStart(eq("tf-redis"), anyString(), any()))
|
||||
.thenThrow(new RuntimeException("container failed"));
|
||||
ElastiCacheProxyManager restartedProxies = mock(ElastiCacheProxyManager.class);
|
||||
ElastiCacheService restarted = serviceWith(storageFactory, restartedContainers,
|
||||
@@ -1550,7 +1550,7 @@ class ElastiCacheServiceTest {
|
||||
StorageFactory storageFactory = storageWithStandaloneCluster("tf-redis");
|
||||
|
||||
ElastiCacheContainerManager restartedContainers = mock(ElastiCacheContainerManager.class);
|
||||
when(restartedContainers.tryStart(anyString(), anyString())).thenReturn(null);
|
||||
when(restartedContainers.tryStart(anyString(), anyString(), any())).thenReturn(null);
|
||||
ElastiCacheProxyManager restartedProxies = mock(ElastiCacheProxyManager.class);
|
||||
ElastiCacheService restarted = serviceWith(storageFactory, restartedContainers,
|
||||
restartedProxies, mock(ValkeyClusterFormation.class));
|
||||
@@ -1583,7 +1583,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
restarted.restorePersistedRuntime().join();
|
||||
|
||||
verify(restartedContainers, never()).tryStart(anyString(), anyString());
|
||||
verify(restartedContainers, never()).tryStart(anyString(), anyString(), any());
|
||||
assertEquals(CacheClusterStatus.DELETING,
|
||||
restarted.findCacheClusters("tf-redis").getFirst().getCacheClusterStatus());
|
||||
}
|
||||
@@ -1600,7 +1600,7 @@ class ElastiCacheServiceTest {
|
||||
new ElastiCacheContainerHandle("cid-restored", "tf-redis", "localhost", 6379);
|
||||
// The delete lands in the window the cluster's monitor closes: the container is up, the
|
||||
// record has not been written back yet.
|
||||
when(restartedContainers.tryStart(eq("tf-redis"), anyString())).thenAnswer(inv -> {
|
||||
when(restartedContainers.tryStart(eq("tf-redis"), anyString(), any())).thenAnswer(inv -> {
|
||||
restarted.deleteCacheCluster("tf-redis");
|
||||
// Takes the port that delete just freed, so a restore that released it a second
|
||||
// time would hand the same port out twice.
|
||||
@@ -1703,13 +1703,13 @@ class ElastiCacheServiceTest {
|
||||
void aReplicationGroupCannotTakeTheIdOfAMemcachedCluster() {
|
||||
// The third store counts too: CreateReplicationGroup would otherwise name a group after
|
||||
// a live memcached cluster and take over its container and proxy registration.
|
||||
memcachedService().createCacheCluster("shared-id");
|
||||
memcachedService().createCacheCluster("shared-id", "us-east-1");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () -> service.createReplicationGroup(
|
||||
"shared-id", "d", AuthMode.NO_AUTH, null, "us-east-1"));
|
||||
|
||||
assertEquals("ReplicationGroupAlreadyExistsFault", ex.getErrorCode());
|
||||
verify(containerManager, never()).tryStart(eq("shared-id"), anyString());
|
||||
verify(containerManager, never()).tryStart(eq("shared-id"), anyString(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1727,13 +1727,13 @@ class ElastiCacheServiceTest {
|
||||
void aCacheClusterCannotTakeTheIdOfAMemcachedCluster() {
|
||||
// One namespace: DescribeCacheClusters answers from every store, so two records sharing
|
||||
// an id would have it reported twice, each with a different engine.
|
||||
memcachedService().createCacheCluster("shared-id");
|
||||
memcachedService().createCacheCluster("shared-id", "us-east-1");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> service.createCacheCluster(cacheClusterRequest("shared-id", "redis", 1)));
|
||||
|
||||
assertEquals("CacheClusterAlreadyExists", ex.getErrorCode());
|
||||
verify(containerManager, never()).tryStart(eq("shared-id"), anyString());
|
||||
verify(containerManager, never()).tryStart(eq("shared-id"), anyString(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1743,13 +1743,13 @@ class ElastiCacheServiceTest {
|
||||
service.createReplicationGroup("group-id", "d", AuthMode.NO_AUTH, null, "us-east-1");
|
||||
|
||||
assertEquals("CacheClusterAlreadyExists",
|
||||
assertThrows(AwsException.class, () -> memcached.createCacheCluster("redis-id"))
|
||||
assertThrows(AwsException.class, () -> memcached.createCacheCluster("redis-id", "us-east-1"))
|
||||
.getErrorCode());
|
||||
assertEquals("CacheClusterAlreadyExists",
|
||||
assertThrows(AwsException.class, () -> memcached.createCacheCluster("group-id"))
|
||||
assertThrows(AwsException.class, () -> memcached.createCacheCluster("group-id", "us-east-1"))
|
||||
.getErrorCode());
|
||||
verify(memcachedContainerManager, never()).tryStart(eq("redis-id"), anyString());
|
||||
verify(memcachedContainerManager, never()).tryStart(eq("group-id"), anyString());
|
||||
verify(memcachedContainerManager, never()).tryStart(eq("redis-id"), anyString(), any());
|
||||
verify(memcachedContainerManager, never()).tryStart(eq("group-id"), anyString(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1762,7 +1762,7 @@ class ElastiCacheServiceTest {
|
||||
ElastiCacheMemcachedService memcached = memcachedService();
|
||||
CountDownLatch startedLatch = new CountDownLatch(1);
|
||||
CountDownLatch releaseLatch = new CountDownLatch(1);
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenAnswer(inv -> {
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenAnswer(inv -> {
|
||||
startedLatch.countDown();
|
||||
assertTrue(releaseLatch.await(5, TimeUnit.SECONDS), "test timed out waiting for release");
|
||||
return new ElastiCacheContainerHandle("cid", "grp", "localhost", 6379);
|
||||
@@ -1774,9 +1774,9 @@ class ElastiCacheServiceTest {
|
||||
assertTrue(startedLatch.await(5, TimeUnit.SECONDS), "create never reached container start");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> memcached.createCacheCluster("shared-id"));
|
||||
() -> memcached.createCacheCluster("shared-id", "us-east-1"));
|
||||
assertEquals("CacheClusterAlreadyExists", ex.getErrorCode());
|
||||
verify(memcachedContainerManager, never()).tryStart(eq("shared-id"), anyString());
|
||||
verify(memcachedContainerManager, never()).tryStart(eq("shared-id"), anyString(), any());
|
||||
|
||||
releaseLatch.countDown();
|
||||
groupCreate.join(5000);
|
||||
@@ -1797,7 +1797,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
assertEquals("CacheSubnetGroupNotFoundFault", ex.getErrorCode());
|
||||
// and nothing was provisioned against the name that does not resolve
|
||||
verify(containerManager, never()).tryStart(eq("sng-cc"), anyString());
|
||||
verify(containerManager, never()).tryStart(eq("sng-cc"), anyString(), any());
|
||||
assertTrue(service.findCacheClusters("sng-cc").isEmpty());
|
||||
}
|
||||
|
||||
@@ -1821,7 +1821,7 @@ class ElastiCacheServiceTest {
|
||||
|
||||
@Test
|
||||
void aCacheClusterCreatedWithoutDockerStillReachesAvailable() {
|
||||
when(containerManager.tryStart(anyString(), anyString())).thenReturn(null);
|
||||
when(containerManager.tryStart(anyString(), anyString(), any())).thenReturn(null);
|
||||
|
||||
CacheCluster cluster = service.createCacheCluster(cacheClusterRequest("no-docker", "redis", 1));
|
||||
|
||||
|
||||
+7
-4
@@ -81,17 +81,20 @@ class ElastiCacheContainerManagerTest {
|
||||
when(regionResolver.getAccountId()).thenReturn("000000000000");
|
||||
when(regionResolver.getDefaultRegion()).thenReturn("us-east-1");
|
||||
|
||||
ContainerLogStreamer logStreamer = mock(ContainerLogStreamer.class);
|
||||
ElastiCacheContainerManager manager = new ElastiCacheContainerManager(containerBuilder, lifecycleManager,
|
||||
mock(ContainerLogStreamer.class), mock(ContainerDetector.class), config, regionResolver);
|
||||
logStreamer, mock(ContainerDetector.class), config, regionResolver);
|
||||
|
||||
manager.start("my-group", "valkey/valkey:7.2");
|
||||
// The group's region, not the default, names the container and receives its logs.
|
||||
manager.start("my-group", "valkey/valkey:7.2", "eu-west-1");
|
||||
|
||||
verify(builder).withLabels(Map.of(
|
||||
"io.floci", "aws",
|
||||
"io.floci.service", "elasticache",
|
||||
"io.floci.resource-id", "my-group",
|
||||
"io.floci.account", "000000000000",
|
||||
"io.floci.region", "us-east-1"));
|
||||
"io.floci.region", "eu-west-1"));
|
||||
verify(logStreamer).attach(eq("container-id"), anyString(), any(), eq("eu-west-1"), anyString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +124,7 @@ class ElastiCacheContainerManagerTest {
|
||||
ElastiCacheContainerManager manager = new ElastiCacheContainerManager(containerBuilder, lifecycleManager,
|
||||
logStreamer, mock(ContainerDetector.class), config, mock(RegionResolver.class));
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> manager.tryStart("my-group", "valkey/valkey:7.2"));
|
||||
assertThrows(IllegalStateException.class, () -> manager.tryStart("my-group", "valkey/valkey:7.2", "us-east-1"));
|
||||
|
||||
verify(lifecycleManager).stopAndRemove(eq("container-id"), any());
|
||||
}
|
||||
|
||||
+3
-3
@@ -71,14 +71,14 @@ class ElastiCacheMemcachedContainerManagerTest {
|
||||
containerBuilder, lifecycleManager, mock(ContainerLogStreamer.class),
|
||||
mock(ContainerDetector.class), config, regionResolver);
|
||||
|
||||
manager.start("my-cluster", "memcached:1.6");
|
||||
manager.start("my-cluster", "memcached:1.6", "eu-west-1");
|
||||
|
||||
verify(builder).withLabels(Map.of(
|
||||
"io.floci", "aws",
|
||||
"io.floci.service", "elasticache",
|
||||
"io.floci.resource-id", "my-cluster",
|
||||
"io.floci.account", "000000000000",
|
||||
"io.floci.region", "us-east-1"));
|
||||
"io.floci.region", "eu-west-1"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class ElastiCacheMemcachedContainerManagerTest {
|
||||
containerBuilder, lifecycleManager, logStreamer, mock(ContainerDetector.class),
|
||||
config, mock(RegionResolver.class));
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> manager.tryStart("my-cluster", "memcached:1.6"));
|
||||
assertThrows(IllegalStateException.class, () -> manager.tryStart("my-cluster", "memcached:1.6", "us-east-1"));
|
||||
|
||||
verify(lifecycleManager).stopAndRemove(eq("container-id"), any());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user