Light, fluffy, and always free - The AWS Local Emulator alternative
fix(ec2): include supported usage classes in DescribeInstanceTypes (#3347)
luiseterc19f410d6b025
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.javaindex eb3e7fd62c..14a19c755a 100644--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java@@ -278,6 +278,22 @@ class Ec2Tests {.containsExactly("arm64");}+ /** Regression coverage for the Karpenter instance-type compatibility contract. */+ @Test+ @Order(7)+ @DisplayName("DescribeInstanceTypes - supported usage classes")+ void describeInstanceTypeSupportedUsageClasses() {+ DescribeInstanceTypesResponse resp = ec2.describeInstanceTypes(DescribeInstanceTypesRequest.builder()+ .instanceTypes(InstanceType.M5_LARGE, InstanceType.fromValue("t4g.medium"),+ InstanceType.fromValue("m6gd.large"))+ .build());++ assertThat(resp.instanceTypes()).hasSize(3);+ assertThat(resp.instanceTypes()).allSatisfy(instanceType ->+ assertThat(instanceType.supportedUsageClassesAsStrings())+ .containsExactlyInAnyOrder("on-demand", "spot"));+ }+@Test@Order(7)@DisplayName("CreateFleet - dry-run and instant on-demand launch")diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2InstanceTypeCatalog.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2InstanceTypeCatalog.javaindex eaffb4c492..b281e0f28c 100644--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2InstanceTypeCatalog.java+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2InstanceTypeCatalog.java@@ -95,6 +95,9 @@ public class Ec2InstanceTypeCatalog {if (instanceType.supportedArchitectures == null || instanceType.supportedArchitectures.isEmpty()) {throw new IllegalStateException("EC2 instance type catalog entry is missing supportedArchitectures: " + name);}+ if (instanceType.supportedUsageClasses == null || instanceType.supportedUsageClasses.isEmpty()) {+ throw new IllegalStateException("EC2 instance type catalog entry is missing supportedUsageClasses: " + name);+ }if (instanceType.encryptionInTransitSupported == null) {throw new IllegalStateException("EC2 instance type catalog entry is missing encryptionInTransitSupported: " + name);@@ -156,6 +159,7 @@ public class Ec2InstanceTypeCatalog {public int memoryMib;public int localStorageGiB;public List<String> supportedArchitectures = List.of();+ public List<String> supportedUsageClasses = List.of("on-demand", "spot");public Boolean currentGeneration;public Boolean encryptionInTransitSupported;public Integer defaultNetworkCardIndex;@@ -170,6 +174,7 @@ public class Ec2InstanceTypeCatalog {type.put("instanceStorageSupported", localStorageGiB > 0);type.put("localStorageGiB", localStorageGiB);type.put("supportedArchitectures", List.copyOf(supportedArchitectures));+ type.put("supportedUsageClasses", List.copyOf(supportedUsageClasses));type.put("currentGeneration", currentGeneration == null || currentGeneration);Map<String, Object> networkInfo = new LinkedHashMap<>();networkInfo.put("encryptionInTransitSupported", encryptionInTransitSupported);diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.javaindex 793a3de2d7..bb55b895d4 100644--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java@@ -3849,7 +3849,12 @@ public class Ec2QueryHandler {for (String arch : (List<String>) t.get("supportedArchitectures")) {xml.elem("item", arch);}- xml.end("supportedArchitectures").end("processorInfo");+ xml.end("supportedArchitectures").end("processorInfo")+ .start("supportedUsageClasses");+ for (String usageClass : (List<String>) t.get("supportedUsageClasses")) {+ xml.elem("item", usageClass);+ }+ xml.end("supportedUsageClasses");Map<String, Object> networkInfo = (Map<String, Object>) t.get("networkInfo");xml.start("networkInfo").elem("encryptionInTransitSupported",diff --git a/src/test/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutorFailStateErrorCauseTest.java b/src/test/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutorFailStateErrorCauseTest.javaindex 00743015ee..aedb5ae7d8 100644--- a/src/test/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutorFailStateErrorCauseTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/stepfunctions/AslExecutorFailStateErrorCauseTest.java@@ -31,6 +31,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;* <p>Both fields are resolved through the same reference-path resolver a {@code ".$"} payload* template field uses, so an unresolvable path fails with {@code States.Runtime}, matching the* precedent set for issue #2521 in {@link AslExecutorUnresolvableJsonPathTest}.+ *+ * <p>The fixture supplies all service handlers required by the production executor, including+ * the SNS handler introduced by the Step Functions SNS integration.*/@QuarkusTestclass AslExecutorFailStateErrorCauseTest {