mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(ec2): include network metadata in instance type responses (#2943)
This commit is contained in:
1 parent
30b8f88467
commit
c54b237cd8
6 files changed
+61
-1
No files matched your search
@@ -193,6 +193,23 @@ class Ec2Tests {
|
||||
assertThat(resp.instanceTypes()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
@DisplayName("DescribeInstanceTypes - network compatibility metadata")
|
||||
void describeInstanceTypeNetworkCompatibilityMetadata() {
|
||||
DescribeInstanceTypesResponse resp = ec2.describeInstanceTypes(DescribeInstanceTypesRequest.builder()
|
||||
.instanceTypes(InstanceType.M5_LARGE, InstanceType.fromValue("t4g.medium"))
|
||||
.build());
|
||||
|
||||
assertThat(resp.instanceTypes()).hasSize(2);
|
||||
assertThat(resp.instanceTypes()).allSatisfy(instanceType -> {
|
||||
assertThat(instanceType.networkInfo()).isNotNull();
|
||||
assertThat(instanceType.networkInfo().encryptionInTransitSupported()).isNotNull();
|
||||
});
|
||||
assertThat(resp.instanceTypes()).allMatch(instanceType ->
|
||||
!instanceType.networkInfo().encryptionInTransitSupported());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
@DisplayName("DescribeInstanceTypes - processor architectures")
|
||||
|
||||
@@ -93,6 +93,10 @@ public class Ec2InstanceTypeCatalog {
|
||||
if (instanceType.supportedArchitectures == null || instanceType.supportedArchitectures.isEmpty()) {
|
||||
throw new IllegalStateException("EC2 instance type catalog entry is missing supportedArchitectures: " + name);
|
||||
}
|
||||
if (instanceType.encryptionInTransitSupported == null) {
|
||||
throw new IllegalStateException(
|
||||
"EC2 instance type catalog entry is missing encryptionInTransitSupported: " + name);
|
||||
}
|
||||
CatalogInstanceType previous = index.putIfAbsent(name, instanceType);
|
||||
if (previous != null) {
|
||||
throw new IllegalStateException("Duplicate EC2 instance type catalog entry: " + name);
|
||||
@@ -123,6 +127,7 @@ public class Ec2InstanceTypeCatalog {
|
||||
public int localStorageGiB;
|
||||
public List<String> supportedArchitectures = List.of();
|
||||
public Boolean currentGeneration;
|
||||
public Boolean encryptionInTransitSupported;
|
||||
|
||||
public Map<String, Object> toResponseMap() {
|
||||
Map<String, Object> type = new LinkedHashMap<>();
|
||||
@@ -133,6 +138,9 @@ public class Ec2InstanceTypeCatalog {
|
||||
type.put("localStorageGiB", localStorageGiB);
|
||||
type.put("supportedArchitectures", List.copyOf(supportedArchitectures));
|
||||
type.put("currentGeneration", currentGeneration == null || currentGeneration);
|
||||
Map<String, Object> networkInfo = new LinkedHashMap<>();
|
||||
networkInfo.put("encryptionInTransitSupported", encryptionInTransitSupported);
|
||||
type.put("networkInfo", networkInfo);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3370,7 +3370,13 @@ public class Ec2QueryHandler {
|
||||
for (String arch : (List<String>) t.get("supportedArchitectures")) {
|
||||
xml.elem("item", arch);
|
||||
}
|
||||
xml.end("supportedArchitectures").end("processorInfo").end("item");
|
||||
xml.end("supportedArchitectures").end("processorInfo");
|
||||
Map<String, Object> networkInfo = (Map<String, Object>) t.get("networkInfo");
|
||||
xml.start("networkInfo")
|
||||
.elem("encryptionInTransitSupported",
|
||||
String.valueOf(networkInfo.get("encryptionInTransitSupported")))
|
||||
.end("networkInfo")
|
||||
.end("item");
|
||||
}
|
||||
xml.end("instanceTypeSet").end("DescribeInstanceTypesResponse");
|
||||
return xmlResponse(xml.build());
|
||||
|
||||
@@ -5,6 +5,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- x86_64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: t3.micro
|
||||
vcpu: 2
|
||||
@@ -12,6 +13,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- x86_64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: t3.small
|
||||
vcpu: 2
|
||||
@@ -19,6 +21,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- x86_64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: t3.medium
|
||||
vcpu: 2
|
||||
@@ -26,6 +29,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- x86_64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m5.large
|
||||
vcpu: 2
|
||||
@@ -33,6 +37,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- x86_64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: t4g.micro
|
||||
vcpu: 2
|
||||
@@ -40,6 +45,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: t4g.small
|
||||
vcpu: 2
|
||||
@@ -47,6 +53,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: t4g.medium
|
||||
vcpu: 2
|
||||
@@ -54,6 +61,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m6gd.large
|
||||
vcpu: 2
|
||||
@@ -62,6 +70,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m6gd.2xlarge
|
||||
vcpu: 8
|
||||
@@ -70,6 +79,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m7gd.large
|
||||
vcpu: 2
|
||||
@@ -78,6 +88,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m7gd.2xlarge
|
||||
vcpu: 8
|
||||
@@ -86,6 +97,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m8gd.medium
|
||||
vcpu: 1
|
||||
@@ -94,6 +106,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m8gd.large
|
||||
vcpu: 2
|
||||
@@ -102,6 +115,7 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
|
||||
- instanceType: m8gd.2xlarge
|
||||
vcpu: 8
|
||||
@@ -110,3 +124,4 @@ instanceTypes:
|
||||
supportedArchitectures:
|
||||
- arm64
|
||||
currentGeneration: true
|
||||
encryptionInTransitSupported: false
|
||||
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.ec2;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
@@ -54,6 +55,15 @@ class Ec2InstanceTypeCatalogTest {
|
||||
assertFalse(instanceTypeCatalog.find("m8gd.xlarge").isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void catalogEntriesIncludeNetworkCompatibilityMetadata() {
|
||||
instanceTypeCatalog.instanceTypes().forEach(instanceType ->
|
||||
assertNotNull(instanceType.encryptionInTransitSupported, instanceType.instanceType));
|
||||
|
||||
assertFalse(instanceTypeCatalog.find("m5.large").orElseThrow().encryptionInTransitSupported);
|
||||
assertFalse(instanceTypeCatalog.find("t4g.medium").orElseThrow().encryptionInTransitSupported);
|
||||
}
|
||||
|
||||
private void assertLargeGravitonType(String name) {
|
||||
Ec2InstanceTypeCatalog.CatalogInstanceType instanceType = instanceTypeCatalog.find(name).orElseThrow();
|
||||
|
||||
|
||||
@@ -792,6 +792,8 @@ class Ec2IntegrationTest {
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.instanceType", equalTo("m6gd.2xlarge"))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.instanceStorageSupported", equalTo("true"))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.instanceStorageInfo.totalSizeInGB", equalTo("474"))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.networkInfo.encryptionInTransitSupported",
|
||||
equalTo("false"))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.processorInfo.supportedArchitectures.item",
|
||||
equalTo("arm64"));
|
||||
}
|
||||
@@ -821,6 +823,8 @@ class Ec2IntegrationTest {
|
||||
everyItem(equalTo("true")))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.instanceStorageInfo.totalSizeInGB",
|
||||
everyItem(equalTo("118")))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.networkInfo.encryptionInTransitSupported",
|
||||
everyItem(equalTo("false")))
|
||||
.body("DescribeInstanceTypesResponse.instanceTypeSet.item.processorInfo.supportedArchitectures.item",
|
||||
everyItem(equalTo("arm64")));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user