mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(neptune): throw a mappable capacity fault when the proxy-port range is exhausted (#1879)
allocateProxyPort threw AwsException("InsufficientNeptuneCapacity"), a code
that does not exist in Neptune's API, so the SDK could not map it and callers
got a generic NeptuneException. Use the wire code InsufficientStorageClusterCapacity
(the InsufficientStorageClusterCapacityFault that CreateDBCluster declares), 400,
so the SDK deserializes it to a typed exception.
This commit is contained in:
1 parent
83fcd12f1c
commit
fe531e2be8
2 files changed
+22
-3
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.neptune;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
@@ -32,6 +33,7 @@ class NeptuneServiceTest {
|
||||
private NeptuneService service;
|
||||
private NeptuneContainerManager containerManager;
|
||||
private NeptuneProxyManager proxyManager;
|
||||
private EmulatorConfig.NeptuneServiceConfig neptuneConfig;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
@@ -42,7 +44,7 @@ class NeptuneServiceTest {
|
||||
RegionResolver regionResolver = mock(RegionResolver.class);
|
||||
|
||||
EmulatorConfig.ServicesConfig servicesConfig = mock(EmulatorConfig.ServicesConfig.class);
|
||||
EmulatorConfig.NeptuneServiceConfig neptuneConfig = mock(EmulatorConfig.NeptuneServiceConfig.class);
|
||||
neptuneConfig = mock(EmulatorConfig.NeptuneServiceConfig.class);
|
||||
when(config.services()).thenReturn(servicesConfig);
|
||||
when(servicesConfig.neptune()).thenReturn(neptuneConfig);
|
||||
when(neptuneConfig.proxyBasePort()).thenReturn(18182);
|
||||
@@ -140,4 +142,18 @@ class NeptuneServiceTest {
|
||||
assertEquals(18182, recovered.getProxyPort(),
|
||||
"Port from the failed create must be released so the next cluster reuses it");
|
||||
}
|
||||
|
||||
@Test
|
||||
void exhaustedProxyPortRangeThrowsMappableCapacityFault() {
|
||||
// Shrink the range to one port so the second create exhausts it.
|
||||
when(neptuneConfig.proxyMaxPort()).thenReturn(18182);
|
||||
service.createDbCluster("c1", "1.3.2.1", false);
|
||||
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.createDbCluster("c2", "1.3.2.1", false));
|
||||
// Real Neptune wire code (maps to InsufficientStorageClusterCapacityFault), not the
|
||||
// fabricated "InsufficientNeptuneCapacity" the SDK couldn't map to a typed exception.
|
||||
assertEquals("InsufficientStorageClusterCapacity", e.getErrorCode());
|
||||
assertEquals(400, e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user