mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(ec2): implement DescribeSpotPriceHistory (#3359)
* feat(ec2): implement DescribeSpotPriceHistory * test(ec2): verify DescribeSpotPriceHistory with SDK * fix(ec2): honor spot price history dry run
This commit is contained in:
1 parent
7c08b35f1d
commit
ee23e26bc3
3 files changed
+66
-1
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
package com.floci.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.services.ec2.Ec2Client;
|
||||
import software.amazon.awssdk.services.ec2.model.Ec2Exception;
|
||||
import software.amazon.awssdk.services.ec2.model.DescribeSpotPriceHistoryRequest;
|
||||
import software.amazon.awssdk.services.ec2.model.InstanceType;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class Ec2DescribeSpotPriceHistoryTest {
|
||||
|
||||
@Test
|
||||
void describeSpotPriceHistoryReturnsEmptyHistoryWhenNoSnapshotIsConfigured() {
|
||||
try (Ec2Client ec2 = TestFixtures.ec2Client()) {
|
||||
var response = ec2.describeSpotPriceHistory(DescribeSpotPriceHistoryRequest.builder()
|
||||
.instanceTypes(InstanceType.M5_LARGE, InstanceType.fromValue("t4g.medium"))
|
||||
.productDescriptions("Linux/UNIX")
|
||||
.availabilityZone("us-east-1a")
|
||||
.startTime(Instant.parse("2026-01-01T00:00:00Z"))
|
||||
.endTime(Instant.parse("2026-01-02T00:00:00Z"))
|
||||
.maxResults(100)
|
||||
.build());
|
||||
|
||||
assertThat(response.spotPriceHistory()).isEmpty();
|
||||
assertThat(response.nextToken()).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeSpotPriceHistoryHonorsDryRun() {
|
||||
try (Ec2Client ec2 = TestFixtures.ec2Client()) {
|
||||
Ec2Exception exception = assertThrows(Ec2Exception.class,
|
||||
() -> ec2.describeSpotPriceHistory(DescribeSpotPriceHistoryRequest.builder()
|
||||
.dryRun(true)
|
||||
.build()));
|
||||
|
||||
assertThat(exception.statusCode()).isEqualTo(412);
|
||||
assertThat(exception.awsErrorDetails().errorCode()).isEqualTo("DryRunOperation");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user