mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ec2): expand Graviton instance type metadata (#7501)
Add the missing virtual sizes in C6g, C6gn, C7g, C8g, M6g, M7g and M8g using captured AWS type metadata. Verify metadata and offerings through the Java SDK. Closes floci-io/floci#7500
This commit is contained in:
1 parent
3fdc100947
commit
71e8725a45
5 files changed
+927
-2
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
package io.github.hectorvent.floci.services.ec2;
|
||||
|
||||
import io.github.hectorvent.floci.testing.AwsTestClients;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvFileSource;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.ec2.Ec2Client;
|
||||
import software.amazon.awssdk.services.ec2.model.InstanceTypeInfo;
|
||||
import software.amazon.awssdk.services.ec2.model.InstanceTypeOffering;
|
||||
import software.amazon.awssdk.services.ec2.model.LocationType;
|
||||
import software.amazon.awssdk.services.ec2.model.NetworkCardInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
@QuarkusTest
|
||||
class Ec2GravitonCatalogIntegrationTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvFileSource(resources = "/ec2/graviton-instance-types.csv", numLinesToSkip = 1)
|
||||
void gravitonMetadataAndOfferingsMatchAwsSnapshot(String name, int vcpus, long memoryMib,
|
||||
int maxInterfaces, int ipv4PerInterface, boolean encryptionInTransit, boolean currentGeneration) {
|
||||
try (Ec2Client ec2 = AwsTestClients.create(Ec2Client.builder(), "test", Region.US_EAST_1)) {
|
||||
List<InstanceTypeInfo> types = ec2.describeInstanceTypes(r -> r.instanceTypesWithStrings(name)).instanceTypes();
|
||||
assertThat(types, hasSize(1));
|
||||
InstanceTypeInfo type = types.getFirst();
|
||||
assertEquals(name, type.instanceTypeAsString());
|
||||
assertEquals(vcpus, type.vCpuInfo().defaultVCpus());
|
||||
assertEquals(memoryMib, type.memoryInfo().sizeInMiB());
|
||||
assertThat(type.processorInfo().supportedArchitecturesAsStrings(), contains("arm64"));
|
||||
assertEquals(currentGeneration, type.currentGeneration());
|
||||
assertFalse(type.instanceStorageSupported());
|
||||
assertFalse(type.burstablePerformanceSupported());
|
||||
assertThat(type.supportedUsageClassesAsStrings(), containsInAnyOrder("on-demand", "spot"));
|
||||
assertEquals(encryptionInTransit, type.networkInfo().encryptionInTransitSupported());
|
||||
assertEquals(0, type.networkInfo().defaultNetworkCardIndex());
|
||||
assertEquals(ipv4PerInterface, type.networkInfo().ipv4AddressesPerInterface());
|
||||
assertThat(type.networkInfo().networkCards(), hasSize(1));
|
||||
NetworkCardInfo card = type.networkInfo().networkCards().getFirst();
|
||||
assertEquals(0, card.networkCardIndex());
|
||||
assertEquals(maxInterfaces, card.maximumNetworkInterfaces());
|
||||
|
||||
String zone = ec2.describeAvailabilityZones().availabilityZones().getFirst().zoneName();
|
||||
List<InstanceTypeOffering> offerings = ec2.describeInstanceTypeOfferings(r -> r
|
||||
.locationType(LocationType.AVAILABILITY_ZONE)
|
||||
.filters(f -> f.name("instance-type").values(name), f -> f.name("location").values(zone)))
|
||||
.instanceTypeOfferings();
|
||||
assertThat(offerings, hasSize(1));
|
||||
assertEquals(name, offerings.getFirst().instanceTypeAsString());
|
||||
assertEquals(zone, offerings.getFirst().location());
|
||||
assertEquals(LocationType.AVAILABILITY_ZONE, offerings.getFirst().locationType());
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -4,6 +4,7 @@ import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -27,7 +28,7 @@ class Ec2InstanceTypeCatalogTest {
|
||||
.map(instanceType -> instanceType.instanceType)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertEquals(Set.of(
|
||||
Set<String> expected = new HashSet<>(Set.of(
|
||||
"t2.nano",
|
||||
"t2.micro",
|
||||
"t2.small",
|
||||
@@ -52,7 +53,14 @@ class Ec2InstanceTypeCatalogTest {
|
||||
"m7gd.2xlarge",
|
||||
"m8gd.medium",
|
||||
"m8gd.large",
|
||||
"m8gd.2xlarge"), instanceTypes);
|
||||
"m8gd.2xlarge"));
|
||||
for (String family : List.of("c6g", "c6gn", "c7g", "c8g", "m6g", "m7g", "m8g")) {
|
||||
for (String size : List.of("medium", "large", "xlarge", "2xlarge", "4xlarge", "8xlarge", "12xlarge", "16xlarge")) {
|
||||
expected.add(family + "." + size);
|
||||
}
|
||||
}
|
||||
expected.addAll(List.of("c8g.24xlarge", "c8g.48xlarge", "m8g.24xlarge", "m8g.48xlarge"));
|
||||
assertEquals(expected, instanceTypes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user