mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(emr-serverless): start, get, list and cancel job runs (#6202)
Adds StartJobRun, GetJobRun, ListJobRuns and CancelJobRun under
/applications/{applicationId}/jobruns. Job runs are metadata only, like
Glue's: a run is RUNNING from submission and settles when read. With the
new floci.services.emrserverless.job-run-duration-seconds at its default
of 0, a BATCH run is SUCCESS as soon as it starts; a positive duration
keeps it RUNNING that long, and a run that would outlast its
executionTimeoutMinutes (720 when not given) is CANCELLED at the
timeout. A STREAMING run stays RUNNING until it is cancelled.
A run on a CREATED or STOPPED application starts it, as auto-start
defaults to on; with auto-start off the run is refused. clientToken is
the idempotency token: a retry returns the original run, and the same
token with another request answers ConflictException "Request did not
match the original". CancelJobRun on a finished run answers
ValidationException "Job run is not in a cancellable state". ListJobRuns
returns the newest runs first, filtered by states, creation time and
mode, and its nextToken resumes only the listing it came from. A run
needs a jobDriver that sets exactly one of sparkSubmit and hive, as
GetJobRun's JobRun always carries one, and tags are checked before
auto-start, so a refused run leaves the application as it was.
createdBy is the caller's ARN.
Application createdAt and updatedAt now go out as epoch seconds, the
restJson1 default for the model's Date shape, as job runs do. They were
epoch milliseconds, which the Java SDK reads as the year 58774 and
botocore refuses as out of range. Auto-start rewrites updatedAt, so a
run's own submission reached the bug. Applications persisted with
millisecond timestamps read back at the same instant.
Part of #6046 (part 8).
This commit is contained in:
1 parent
9e66185c9d
commit
1f1e5db1bc
25 files changed
+1918
-37
No files matched your search
+58
-6
@@ -1,32 +1,46 @@
|
||||
package io.github.hectorvent.floci.services.emrserverless;
|
||||
|
||||
import io.github.hectorvent.floci.testing.EmrServerlessRequests;
|
||||
import io.github.hectorvent.floci.testing.MutableClock;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.config.JsonConfig;
|
||||
import io.restassured.config.RestAssuredConfig;
|
||||
import io.restassured.path.json.config.JsonPathConfig;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class EmrServerlessIntegrationTest {
|
||||
|
||||
private static final String JSON_CONTENT_TYPE = "application/json";
|
||||
private static final RestAssuredConfig DECIMAL_NUMBERS = RestAssuredConfig.config()
|
||||
.jsonConfig(JsonConfig.jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL));
|
||||
private static String applicationId;
|
||||
|
||||
@Inject
|
||||
MutableClock clock;
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
private io.restassured.specification.RequestSpecification givenReq() {
|
||||
return given()
|
||||
.header("Authorization", "AWS4-HMAC-SHA256 Credential=TEST/20260819/us-east-1/emr-serverless/aws4_request, SignedHeaders=host;x-amz-date, Signature=test")
|
||||
.contentType(JSON_CONTENT_TYPE);
|
||||
private RequestSpecification givenReq() {
|
||||
return EmrServerlessRequests.emrServerless("us-east-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -286,4 +300,42 @@ public class EmrServerlessIntegrationTest {
|
||||
.statusCode(200)
|
||||
.body("application.state", equalTo("TERMINATED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void applicationTimestampsAreEpochSecondsWithMilliseconds() {
|
||||
// A Region of its own, so ListApplications holds this application and no other test's.
|
||||
String region = "ap-southeast-4";
|
||||
clock.advance(Duration.ofMillis(250));
|
||||
BigDecimal before = BigDecimal.valueOf(clock.instant().toEpochMilli(), 3);
|
||||
String id = EmrServerlessRequests.emrServerless(region)
|
||||
.body("""
|
||||
{"name": "stamped-app", "releaseLabel": "emr-6.6.0", "type": "SPARK", "clientToken": "%s"}
|
||||
""".formatted(UUID.randomUUID()))
|
||||
.when()
|
||||
.post("/applications")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("applicationId");
|
||||
|
||||
BigDecimal createdAt = EmrServerlessRequests.emrServerless(region).config(DECIMAL_NUMBERS)
|
||||
.when()
|
||||
.get("/applications/" + id)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("application.createdAt");
|
||||
BigDecimal updatedAt = EmrServerlessRequests.emrServerless(region).config(DECIMAL_NUMBERS)
|
||||
.get("/applications/" + id)
|
||||
.then().statusCode(200).extract().path("application.updatedAt");
|
||||
BigDecimal listed = EmrServerlessRequests.emrServerless(region).config(DECIMAL_NUMBERS)
|
||||
.get("/applications")
|
||||
.then().statusCode(200).extract().path("applications[0].createdAt");
|
||||
|
||||
// The test clock moves a millisecond on every read, so the application was created a little later.
|
||||
assertTrue(createdAt.compareTo(before) > 0 && createdAt.compareTo(before.add(BigDecimal.ONE)) < 0,
|
||||
"createdAt " + createdAt + " is not just after " + before);
|
||||
assertTrue(createdAt.stripTrailingZeros().scale() <= 3, "createdAt " + createdAt + " is finer than milliseconds");
|
||||
assertEquals(0, createdAt.compareTo(updatedAt), "updatedAt " + updatedAt + " differs from createdAt " + createdAt);
|
||||
assertEquals(0, createdAt.compareTo(listed), "ListApplications reports createdAt " + listed);
|
||||
}
|
||||
}
|
||||
+485
@@ -0,0 +1,485 @@
|
||||
package io.github.hectorvent.floci.services.emrserverless;
|
||||
|
||||
import io.github.hectorvent.floci.testing.EmrServerlessRequests;
|
||||
import io.github.hectorvent.floci.testing.MutableClock;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.config.JsonConfig;
|
||||
import io.restassured.config.RestAssuredConfig;
|
||||
import io.restassured.path.json.config.JsonPathConfig;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
class EmrServerlessJobRunIntegrationTest {
|
||||
|
||||
private static final String ROLE = "arn:aws:iam::000000000000:role/emr-serverless-job";
|
||||
private static final RestAssuredConfig DECIMAL_NUMBERS = RestAssuredConfig.config()
|
||||
.jsonConfig(JsonConfig.jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.BIG_DECIMAL));
|
||||
|
||||
@Inject
|
||||
MutableClock clock;
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
private static RequestSpecification givenReq() {
|
||||
return EmrServerlessRequests.emrServerless("us-east-1");
|
||||
}
|
||||
|
||||
private static String createApplication(String extra) {
|
||||
return givenReq()
|
||||
.body("""
|
||||
{"name": "jobs-%s", "releaseLabel": "emr-7.5.0", "type": "SPARK", "clientToken": "%s"%s}
|
||||
""".formatted(UUID.randomUUID(), UUID.randomUUID(), extra))
|
||||
.when().post("/applications")
|
||||
.then().statusCode(200)
|
||||
.extract().path("applicationId");
|
||||
}
|
||||
|
||||
private static String sparkRun(String clientToken, String extra) {
|
||||
return """
|
||||
{"clientToken": "%s", "executionRoleArn": "%s",
|
||||
"jobDriver": {"sparkSubmit": {"entryPoint": "s3://bucket/jobs/app.jar",
|
||||
"entryPointArguments": ["s3://bucket/in"],
|
||||
"sparkSubmitParameters": "--class example.Main"}}%s}
|
||||
""".formatted(clientToken, ROLE, extra);
|
||||
}
|
||||
|
||||
private static Response startJobRun(String applicationId, String body) {
|
||||
return givenReq().body(body).when().post("/applications/" + applicationId + "/jobruns");
|
||||
}
|
||||
|
||||
private static String startedRunId(String applicationId, String body) {
|
||||
return startJobRun(applicationId, body).then().statusCode(200).extract().path("jobRunId");
|
||||
}
|
||||
|
||||
@Test
|
||||
void startJobRunAutoStartsTheApplicationAndSucceedsByDefault() {
|
||||
String applicationId = createApplication("");
|
||||
givenReq().when().get("/applications/" + applicationId)
|
||||
.then().statusCode(200).body("application.state", equalTo("CREATED"));
|
||||
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ", \"name\": \"nightly\""))
|
||||
.then().statusCode(200)
|
||||
.body("applicationId", equalTo(applicationId))
|
||||
.body("jobRunId", matchesPattern("[0-9a-z]{16}"))
|
||||
.body("arn", matchesPattern("arn:aws:emr-serverless:us-east-1:000000000000:/applications/"
|
||||
+ applicationId + "/jobruns/[0-9a-z]{16}"));
|
||||
|
||||
givenReq().when().get("/applications/" + applicationId)
|
||||
.then().statusCode(200).body("application.state", equalTo("STARTED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getJobRunReportsTheRunAsGetJobRunShapesIt() {
|
||||
String applicationId = createApplication("");
|
||||
String jobRunId = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(),
|
||||
", \"name\": \"nightly\", \"tags\": {\"team\": \"data\"}, \"mode\": \"BATCH\""));
|
||||
|
||||
givenReq().when().get("/applications/" + applicationId + "/jobruns/" + jobRunId)
|
||||
.then().statusCode(200)
|
||||
.body("jobRun.applicationId", equalTo(applicationId))
|
||||
.body("jobRun.jobRunId", equalTo(jobRunId))
|
||||
.body("jobRun.name", equalTo("nightly"))
|
||||
.body("jobRun.arn", endsWith("/applications/" + applicationId + "/jobruns/" + jobRunId))
|
||||
.body("jobRun.createdBy", equalTo("arn:aws:iam::000000000000:root"))
|
||||
.body("jobRun.createdAt", instanceOf(Number.class))
|
||||
.body("jobRun.updatedAt", instanceOf(Number.class))
|
||||
.body("jobRun.executionRole", equalTo(ROLE))
|
||||
.body("jobRun.state", equalTo("SUCCESS"))
|
||||
.body("jobRun.stateDetails", equalTo(""))
|
||||
.body("jobRun.releaseLabel", equalTo("emr-7.5.0"))
|
||||
.body("jobRun.jobDriver.sparkSubmit.entryPoint", equalTo("s3://bucket/jobs/app.jar"))
|
||||
.body("jobRun.jobDriver.sparkSubmit.entryPointArguments", contains("s3://bucket/in"))
|
||||
.body("jobRun.jobDriver.sparkSubmit.sparkSubmitParameters", equalTo("--class example.Main"))
|
||||
.body("jobRun.tags.team", equalTo("data"))
|
||||
.body("jobRun.mode", equalTo("BATCH"))
|
||||
.body("jobRun.executionTimeoutMinutes", equalTo(720))
|
||||
.body("jobRun.totalExecutionDurationSeconds", equalTo(0))
|
||||
.body("jobRun.startedAt", instanceOf(Number.class))
|
||||
.body("jobRun.endedAt", instanceOf(Number.class))
|
||||
.body("jobRun", not(hasKey("hive")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void timestampsAreEpochSecondsWithMilliseconds() {
|
||||
String applicationId = createApplication("");
|
||||
clock.advance(Duration.ofMillis(250));
|
||||
Instant submittedAt = clock.instant();
|
||||
String jobRunId = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
BigDecimal createdAt = givenReq().config(DECIMAL_NUMBERS)
|
||||
.when().get("/applications/" + applicationId + "/jobruns/" + jobRunId)
|
||||
.then().statusCode(200).extract().path("jobRun.createdAt");
|
||||
// The test clock moves a millisecond on every read, so the run was created a little later.
|
||||
BigDecimal submitted = BigDecimal.valueOf(submittedAt.toEpochMilli(), 3);
|
||||
assertTrue(createdAt.compareTo(submitted) >= 0 && createdAt.compareTo(submitted.add(BigDecimal.ONE)) < 0,
|
||||
"createdAt " + createdAt + " is not just after " + submitted);
|
||||
assertTrue(createdAt.stripTrailingZeros().scale() <= 3, "createdAt " + createdAt + " is finer than milliseconds");
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWithoutTagsReportsAnEmptyTagMap() {
|
||||
String applicationId = createApplication("");
|
||||
String jobRunId = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
givenReq().when().get("/applications/" + applicationId + "/jobruns/" + jobRunId)
|
||||
.then().statusCode(200)
|
||||
.body("jobRun.tags", anEmptyMap())
|
||||
.body("jobRun", not(hasKey("mode")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void repeatedClientTokenReturnsTheOriginalRun() {
|
||||
String applicationId = createApplication("");
|
||||
String body = sparkRun(UUID.randomUUID().toString(), ", \"tags\": {\"a\": \"1\", \"b\": \"2\"}");
|
||||
String first = startedRunId(applicationId, body);
|
||||
|
||||
assertEquals(first, startedRunId(applicationId, body));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reusedClientTokenWithAnotherRequestIsAConflict() {
|
||||
String applicationId = createApplication("");
|
||||
String token = UUID.randomUUID().toString();
|
||||
startedRunId(applicationId, sparkRun(token, ", \"name\": \"first\""));
|
||||
|
||||
startJobRun(applicationId, sparkRun(token, ", \"name\": \"second\""))
|
||||
.then().statusCode(409)
|
||||
.body("message", equalTo("Request did not match the original"))
|
||||
.body("__type", equalTo("ConflictException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void newClientTokenStartsAnotherRun() {
|
||||
String applicationId = createApplication("");
|
||||
String first = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
assertNotEquals(first, startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), "")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void missingRequiredMembersAreAValidationException() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
startJobRun(applicationId, "{\"jobDriver\": {\"sparkSubmit\": {}}}")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("3 validation errors detected: "
|
||||
+ "Value null at 'clientToken' failed to satisfy constraint: Member must not be null; "
|
||||
+ "Value null at 'executionRoleArn' failed to satisfy constraint: Member must not be null; "
|
||||
+ "Value null at 'jobDriver.sparkSubmit.entryPoint' failed to satisfy constraint: "
|
||||
+ "Member must not be null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void executionRoleOutsideTheRolePatternIsAValidationException() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
startJobRun(applicationId, """
|
||||
{"clientToken": "t-1", "executionRoleArn": "arn:aws:iam::000000000000:user/someone"}
|
||||
""")
|
||||
.then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value at 'executionRoleArn' failed to "
|
||||
+ "satisfy constraint: Member must satisfy regular expression pattern: "
|
||||
+ "arn:(aws[a-zA-Z0-9-]*):iam::([0-9]{12}):(role((" + backslashU("002F") + ")|("
|
||||
+ backslashU("002F") + "[" + backslashU("0021") + "-" + backslashU("007F") + "]+"
|
||||
+ backslashU("002F") + "))[" + (char) 92 + "w+=,.@-]+)"));
|
||||
}
|
||||
|
||||
// The pattern is quoted with its escapes as text, so the expected message spells them out.
|
||||
private static String backslashU(String hex) {
|
||||
return (char) 92 + "u" + hex;
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownModeIsAValidationException() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ", \"mode\": \"INTERACTIVE\""))
|
||||
.then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value 'INTERACTIVE' at 'mode' failed to "
|
||||
+ "satisfy constraint: Member must satisfy enum value set: [BATCH, STREAMING]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void executionTimeoutOutsideItsRangeIsAValidationException() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ", \"executionTimeoutMinutes\": -1"))
|
||||
.then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value '-1' at 'executionTimeoutMinutes' "
|
||||
+ "failed to satisfy constraint: Member must have value greater than or equal to 0"));
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ", \"executionTimeoutMinutes\": 1000001"))
|
||||
.then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value '1000001' at 'executionTimeoutMinutes' "
|
||||
+ "failed to satisfy constraint: Member must have value less than or equal to 1000000"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRunNeedsExactlyOneJobDriver() {
|
||||
String applicationId = createApplication("");
|
||||
String missing = """
|
||||
{"clientToken": "%s", "executionRoleArn": "%s"}
|
||||
""".formatted(UUID.randomUUID(), ROLE);
|
||||
String both = """
|
||||
{"clientToken": "%s", "executionRoleArn": "%s",
|
||||
"jobDriver": {"sparkSubmit": {"entryPoint": "s3://bucket/jobs/app.jar"}, "hive": {"query": "SELECT 1"}}}
|
||||
""".formatted(UUID.randomUUID(), ROLE);
|
||||
String neither = """
|
||||
{"clientToken": "%s", "executionRoleArn": "%s", "jobDriver": {}}
|
||||
""".formatted(UUID.randomUUID(), ROLE);
|
||||
|
||||
for (String body : List.of(missing, both, neither)) {
|
||||
startJobRun(applicationId, body)
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("jobDriver must contain exactly one union member"));
|
||||
}
|
||||
givenReq().when().get("/applications/" + applicationId)
|
||||
.then().body("application.state", equalTo("CREATED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void refusedTagsLeaveTheApplicationAsItWas() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ", \"tags\": {\"aws:team\": \"data\"}"))
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
givenReq().when().get("/applications/" + applicationId)
|
||||
.then().body("application.state", equalTo("CREATED"));
|
||||
givenReq().when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().body("jobRuns", empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void runOnAnUnknownApplicationIsResourceNotFound() {
|
||||
startJobRun("00missing0000000", sparkRun(UUID.randomUUID().toString(), ""))
|
||||
.then().statusCode(404)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownJobRunIsResourceNotFound() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
givenReq().when().get("/applications/" + applicationId + "/jobruns/00missing0000000")
|
||||
.then().statusCode(404)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
givenReq().when().delete("/applications/" + applicationId + "/jobruns/00missing0000000")
|
||||
.then().statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
void jobRunOfAnotherApplicationIsResourceNotFound() {
|
||||
String owner = createApplication("");
|
||||
String other = createApplication("");
|
||||
String jobRunId = startedRunId(owner, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
givenReq().when().get("/applications/" + other + "/jobruns/" + jobRunId)
|
||||
.then().statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
void disabledAutoStartRefusesARunUntilTheApplicationStarts() {
|
||||
String applicationId = createApplication(", \"autoStartConfiguration\": {\"enabled\": false}");
|
||||
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ""))
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
givenReq().when().get("/applications/" + applicationId)
|
||||
.then().body("application.state", equalTo("CREATED"));
|
||||
|
||||
givenReq().when().post("/applications/" + applicationId + "/start").then().statusCode(200);
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), "")).then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void runOnATerminatedApplicationIsRefused() {
|
||||
String applicationId = createApplication("");
|
||||
givenReq().when().delete("/applications/" + applicationId).then().statusCode(200);
|
||||
|
||||
startJobRun(applicationId, sparkRun(UUID.randomUUID().toString(), ""))
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cancellingAFinishedRunIsAValidationException() {
|
||||
String applicationId = createApplication("");
|
||||
String jobRunId = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
givenReq().when().delete("/applications/" + applicationId + "/jobruns/" + jobRunId)
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("Job run is not in a cancellable state"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamingRunKeepsRunningUntilCancelled() {
|
||||
String applicationId = createApplication("");
|
||||
String jobRunId = startedRunId(applicationId,
|
||||
sparkRun(UUID.randomUUID().toString(), ", \"mode\": \"STREAMING\""));
|
||||
String path = "/applications/" + applicationId + "/jobruns/" + jobRunId;
|
||||
|
||||
givenReq().when().get(path).then().statusCode(200)
|
||||
.body("jobRun.state", equalTo("RUNNING"))
|
||||
.body("jobRun", not(hasKey("endedAt")))
|
||||
.body("jobRun", not(hasKey("totalExecutionDurationSeconds")));
|
||||
|
||||
givenReq().when().delete(path).then().statusCode(200)
|
||||
.body("applicationId", equalTo(applicationId))
|
||||
.body("jobRunId", equalTo(jobRunId));
|
||||
|
||||
givenReq().when().get(path).then().statusCode(200)
|
||||
.body("jobRun.state", equalTo("CANCELLED"))
|
||||
.body("jobRun.endedAt", instanceOf(Number.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsReturnsTheNewestFirst() {
|
||||
String applicationId = createApplication("");
|
||||
String older = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
clock.advance(Duration.ofSeconds(5));
|
||||
String newer = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
givenReq().when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(200)
|
||||
.body("jobRuns.id", contains(newer, older))
|
||||
.body("jobRuns[0].applicationId", equalTo(applicationId))
|
||||
.body("jobRuns[0].state", equalTo("SUCCESS"))
|
||||
.body("jobRuns[0].type", equalTo("SPARK"))
|
||||
.body("jobRuns[0].releaseLabel", equalTo("emr-7.5.0"))
|
||||
.body("jobRuns[0].createdBy", equalTo("arn:aws:iam::000000000000:root"))
|
||||
.body("jobRuns[0]", not(hasKey("jobRunId")))
|
||||
.body("jobRuns[0]", not(hasKey("jobDriver")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsPagesWithNextToken() {
|
||||
String applicationId = createApplication("");
|
||||
String older = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
clock.advance(Duration.ofSeconds(5));
|
||||
String newer = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
String nextToken = givenReq().queryParam("maxResults", 1)
|
||||
.when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(200)
|
||||
.body("jobRuns.id", contains(newer))
|
||||
.body("nextToken", notNullValue())
|
||||
.extract().path("nextToken");
|
||||
|
||||
givenReq().queryParam("maxResults", 1).queryParam("nextToken", nextToken)
|
||||
.when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(200)
|
||||
.body("jobRuns.id", contains(older))
|
||||
.body("$", not(hasKey("nextToken")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsRefusesAPageLargerThanFifty() {
|
||||
String applicationId = createApplication("");
|
||||
|
||||
givenReq().queryParam("maxResults", 51)
|
||||
.when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("1 validation error detected: Value '51' at 'maxResults' failed to "
|
||||
+ "satisfy constraint: Member must have value less than or equal to 50"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsRefusesATokenFromAnotherListing() {
|
||||
String applicationId = createApplication("");
|
||||
String other = createApplication("");
|
||||
startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
clock.advance(Duration.ofSeconds(5));
|
||||
startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
String nextToken = givenReq().queryParam("maxResults", 1)
|
||||
.when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(200)
|
||||
.extract().path("nextToken");
|
||||
|
||||
givenReq().queryParam("nextToken", nextToken)
|
||||
.when().get("/applications/" + other + "/jobruns")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
givenReq().queryParam("nextToken", nextToken).queryParam("states", "SUCCESS")
|
||||
.when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsFiltersOnStateModeAndCreationTime() {
|
||||
String applicationId = createApplication("");
|
||||
String batch = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
clock.advance(Duration.ofSeconds(10));
|
||||
Instant between = clock.instant();
|
||||
clock.advance(Duration.ofSeconds(10));
|
||||
String streaming = startedRunId(applicationId,
|
||||
sparkRun(UUID.randomUUID().toString(), ", \"mode\": \"STREAMING\""));
|
||||
String base = "/applications/" + applicationId + "/jobruns";
|
||||
|
||||
givenReq().queryParam("states", "RUNNING").when().get(base)
|
||||
.then().statusCode(200).body("jobRuns.id", contains(streaming));
|
||||
givenReq().queryParam("mode", "STREAMING").when().get(base)
|
||||
.then().statusCode(200).body("jobRuns.id", contains(streaming));
|
||||
givenReq().queryParam("mode", "BATCH").when().get(base)
|
||||
.then().statusCode(200).body("jobRuns.id", contains(batch));
|
||||
givenReq().queryParam("createdAtBefore", between.toString()).when().get(base)
|
||||
.then().statusCode(200).body("jobRuns.id", contains(batch));
|
||||
givenReq().queryParam("createdAtAfter", between.toString()).when().get(base)
|
||||
.then().statusCode(200).body("jobRuns.id", contains(streaming));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsGroupsSeveralStatesInTheFilterOrder() {
|
||||
String applicationId = createApplication("");
|
||||
String streaming = startedRunId(applicationId,
|
||||
sparkRun(UUID.randomUUID().toString(), ", \"mode\": \"STREAMING\""));
|
||||
clock.advance(Duration.ofSeconds(5));
|
||||
String batch = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
givenReq().queryParam("states", List.of("RUNNING", "SUCCESS"))
|
||||
.when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(200)
|
||||
.body("jobRuns.id", contains(streaming, batch));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listJobRunsOfAnUnknownApplicationIsEmpty() {
|
||||
givenReq().when().get("/applications/00missing0000000/jobruns")
|
||||
.then().statusCode(200)
|
||||
.body("jobRuns", empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void jobRunsStayInTheirRegion() {
|
||||
String applicationId = createApplication("");
|
||||
String jobRunId = startedRunId(applicationId, sparkRun(UUID.randomUUID().toString(), ""));
|
||||
|
||||
EmrServerlessRequests.emrServerless("eu-west-1").when().get("/applications/" + applicationId + "/jobruns/" + jobRunId)
|
||||
.then().statusCode(404);
|
||||
EmrServerlessRequests.emrServerless("eu-west-1").when().get("/applications/" + applicationId + "/jobruns")
|
||||
.then().statusCode(200).body("jobRuns", empty());
|
||||
}
|
||||
}
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
package io.github.hectorvent.floci.services.emrserverless;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
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.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.CreateApplicationRequest;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.JobDriver;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.JobRun;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.JobRunRecord;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.StartJobRunRequest;
|
||||
import io.github.hectorvent.floci.services.iam.IamService;
|
||||
import io.github.hectorvent.floci.testing.InMemoryStorageFactory;
|
||||
import io.github.hectorvent.floci.testing.MutableClock;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class EmrServerlessJobRunServiceTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
private static final String ROLE = "arn:aws:iam::000000000000:role/emr-serverless-job";
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
|
||||
private EmrServerlessService applications;
|
||||
private IamService iamService;
|
||||
private AccountAwareStorageBackend<JobRunRecord> store;
|
||||
private MutableClock clock;
|
||||
private String applicationId;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
EmulatorConfig config = mock(EmulatorConfig.class);
|
||||
when(config.defaultAccountId()).thenReturn(ACCOUNT_ID);
|
||||
clock = new MutableClock();
|
||||
applications = new EmrServerlessService(config, new InMemoryStorageFactory(ACCOUNT_ID),
|
||||
new RegionResolver(REGION, ACCOUNT_ID), clock);
|
||||
iamService = mock(IamService.class);
|
||||
when(iamService.resolveCallerArn(any())).thenReturn(Optional.empty());
|
||||
store = AccountAwareStorageBackend.inMemory(ACCOUNT_ID);
|
||||
|
||||
CreateApplicationRequest create = new CreateApplicationRequest();
|
||||
create.setName("jobs");
|
||||
create.setReleaseLabel("emr-7.5.0");
|
||||
create.setType("SPARK");
|
||||
create.setClientToken(UUID.randomUUID().toString());
|
||||
applicationId = applications.createApplication(create).getApplicationId();
|
||||
}
|
||||
|
||||
private EmrServerlessJobRunService service(int runDurationSeconds) {
|
||||
return new EmrServerlessJobRunService(store, applications, iamService, new RegionResolver(REGION, ACCOUNT_ID),
|
||||
null, objectMapper, runDurationSeconds, clock);
|
||||
}
|
||||
|
||||
private static StartJobRunRequest request(String mode, Long executionTimeoutMinutes) {
|
||||
JobDriver.SparkSubmit sparkSubmit = new JobDriver.SparkSubmit();
|
||||
sparkSubmit.setEntryPoint("s3://bucket/jobs/app.jar");
|
||||
JobDriver driver = new JobDriver();
|
||||
driver.setSparkSubmit(sparkSubmit);
|
||||
StartJobRunRequest request = new StartJobRunRequest();
|
||||
request.setClientToken(UUID.randomUUID().toString());
|
||||
request.setExecutionRoleArn(ROLE);
|
||||
request.setJobDriver(driver);
|
||||
request.setMode(mode);
|
||||
request.setExecutionTimeoutMinutes(executionTimeoutMinutes);
|
||||
return request;
|
||||
}
|
||||
|
||||
@Test
|
||||
void runSucceedsAsSoonAsItStartsByDefault() {
|
||||
JobRun run = service(0).startJobRun(applicationId, request(null, null));
|
||||
|
||||
assertEquals("SUCCESS", run.getState());
|
||||
assertEquals(run.getCreatedAt(), run.getStartedAt());
|
||||
assertEquals(run.getCreatedAt(), run.getEndedAt());
|
||||
assertEquals(run.getCreatedAt(), run.getUpdatedAt());
|
||||
assertEquals(0, run.getTotalExecutionDurationSeconds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void positiveDurationKeepsTheRunRunningUntilItHasPassed() {
|
||||
EmrServerlessJobRunService service = service(30);
|
||||
JobRun started = service.startJobRun(applicationId, request(null, null));
|
||||
String jobRunId = started.getJobRunId();
|
||||
Instant submittedAt = started.getCreatedAt();
|
||||
|
||||
clock.advance(Duration.ofSeconds(29));
|
||||
JobRun running = service.getJobRun(applicationId, jobRunId);
|
||||
assertEquals("RUNNING", running.getState());
|
||||
assertNull(running.getEndedAt());
|
||||
assertNull(running.getTotalExecutionDurationSeconds());
|
||||
|
||||
clock.advance(Duration.ofSeconds(1));
|
||||
JobRun finished = service.getJobRun(applicationId, jobRunId);
|
||||
assertEquals("SUCCESS", finished.getState());
|
||||
assertEquals(submittedAt.plusSeconds(30), finished.getEndedAt());
|
||||
assertEquals(submittedAt.plusSeconds(30), finished.getUpdatedAt());
|
||||
assertEquals(30, finished.getTotalExecutionDurationSeconds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cancellingARunningRunEndsItCancelled() {
|
||||
EmrServerlessJobRunService service = service(60);
|
||||
String jobRunId = service.startJobRun(applicationId, request(null, null)).getJobRunId();
|
||||
clock.advance(Duration.ofSeconds(10));
|
||||
|
||||
JobRun cancelled = service.cancelJobRun(applicationId, jobRunId);
|
||||
|
||||
assertEquals("CANCELLED", cancelled.getState());
|
||||
assertEquals(10, cancelled.getTotalExecutionDurationSeconds());
|
||||
clock.advance(Duration.ofMinutes(5));
|
||||
assertEquals("CANCELLED", service.getJobRun(applicationId, jobRunId).getState());
|
||||
}
|
||||
|
||||
@Test
|
||||
void runIsCancelledAtItsExecutionTimeoutWhenItWouldRunLonger() {
|
||||
EmrServerlessJobRunService service = service(600);
|
||||
JobRun started = service.startJobRun(applicationId, request(null, 5L));
|
||||
String jobRunId = started.getJobRunId();
|
||||
Instant submittedAt = started.getCreatedAt();
|
||||
|
||||
clock.advance(Duration.ofMinutes(5).minusSeconds(1));
|
||||
assertEquals("RUNNING", service.getJobRun(applicationId, jobRunId).getState());
|
||||
|
||||
clock.advance(Duration.ofSeconds(1));
|
||||
JobRun timedOut = service.getJobRun(applicationId, jobRunId);
|
||||
assertEquals("CANCELLED", timedOut.getState());
|
||||
assertEquals(submittedAt.plus(Duration.ofMinutes(5)), timedOut.getEndedAt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamingRunIgnoresTheRunDuration() {
|
||||
EmrServerlessJobRunService service = service(0);
|
||||
String jobRunId = service.startJobRun(applicationId, request("STREAMING", null)).getJobRunId();
|
||||
|
||||
clock.advance(Duration.ofDays(2));
|
||||
|
||||
assertEquals("RUNNING", service.getJobRun(applicationId, jobRunId).getState());
|
||||
}
|
||||
|
||||
@Test
|
||||
void retryIsRecognisedAfterTheStoredRunWasWrittenAndReadBack() throws Exception {
|
||||
EmrServerlessJobRunService service = service(0);
|
||||
StartJobRunRequest request = request("BATCH", 15L);
|
||||
request.setTags(Map.of("team", "data"));
|
||||
String jobRunId = service.startJobRun(applicationId, request).getJobRunId();
|
||||
|
||||
// As persistent storage does: the record goes out as JSON and comes back.
|
||||
JobRunRecord stored = store.get(jobRunId).orElseThrow();
|
||||
store.put(jobRunId, objectMapper.readValue(objectMapper.writeValueAsString(stored), JobRunRecord.class));
|
||||
|
||||
assertEquals(jobRunId, service.startJobRun(applicationId, request).getJobRunId());
|
||||
request.setExecutionTimeoutMinutes(30L);
|
||||
AwsException conflict = assertThrows(AwsException.class, () -> service.startJobRun(applicationId, request));
|
||||
assertEquals("ConflictException", conflict.getErrorCode());
|
||||
assertEquals(409, conflict.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void negativeRunDurationIsRefused() {
|
||||
assertThrows(IllegalArgumentException.class, () -> service(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseTimestampReadsIso8601AndEpochSeconds() {
|
||||
assertEquals(Instant.parse("2026-10-21T12:00:00Z"),
|
||||
EmrServerlessJobRunService.parseTimestamp("2026-10-21T12:00:00Z", "createdAtAfter"));
|
||||
assertEquals(Instant.parse("2026-10-21T12:00:00.500Z"),
|
||||
EmrServerlessJobRunService.parseTimestamp("1792584000.5", "createdAtAfter"));
|
||||
AwsException invalid = assertThrows(AwsException.class,
|
||||
() -> EmrServerlessJobRunService.parseTimestamp("yesterday", "createdAtAfter"));
|
||||
assertEquals("ValidationException", invalid.getErrorCode());
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package io.github.hectorvent.floci.services.emrserverless;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.PersistentStorage;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.Application;
|
||||
import io.github.hectorvent.floci.services.emrserverless.model.CreateApplicationRequest;
|
||||
import io.github.hectorvent.floci.testing.InMemoryStorageFactory;
|
||||
import io.github.hectorvent.floci.testing.MutableClock;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class EmrServerlessServiceTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
private static final TypeReference<Map<String, Application>> APPLICATIONS = new TypeReference<>() {};
|
||||
|
||||
@TempDir
|
||||
Path tempDir;
|
||||
|
||||
@Test
|
||||
void applicationIsStampedFromTheClockToTheMillisecond() {
|
||||
MutableClock clock = new MutableClock();
|
||||
clock.advance(Duration.ofNanos(250_400_000));
|
||||
EmulatorConfig config = mock(EmulatorConfig.class);
|
||||
when(config.defaultAccountId()).thenReturn(ACCOUNT_ID);
|
||||
EmrServerlessService service = new EmrServerlessService(config, new InMemoryStorageFactory(ACCOUNT_ID),
|
||||
new RegionResolver(REGION, ACCOUNT_ID), clock);
|
||||
CreateApplicationRequest create = new CreateApplicationRequest();
|
||||
create.setReleaseLabel("emr-7.5.0");
|
||||
create.setType("SPARK");
|
||||
create.setClientToken(UUID.randomUUID().toString());
|
||||
|
||||
Application created = service.createApplication(create);
|
||||
assertEquals(Instant.parse("2026-01-01T00:00:00.250Z"), created.getCreatedAt());
|
||||
assertEquals(created.getCreatedAt(), created.getUpdatedAt());
|
||||
|
||||
// The test clock moves a millisecond on every read.
|
||||
clock.advance(Duration.ofMinutes(5));
|
||||
service.startApplication(created.getApplicationId());
|
||||
Application started = service.getApplication(created.getApplicationId());
|
||||
assertEquals(Instant.parse("2026-01-01T00:00:00.250Z"), started.getCreatedAt());
|
||||
assertEquals(Instant.parse("2026-01-01T00:05:00.251Z"), started.getUpdatedAt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void applicationPersistedWithMillisecondTimestampsReadsBackAtTheSameInstant() throws IOException {
|
||||
// As Floci stored applications before their timestamps were epoch seconds.
|
||||
Path file = tempDir.resolve("emr-serverless-applications.json");
|
||||
Files.writeString(file, """
|
||||
{"00abc": {"applicationId": "00abc", "createdAt": 1792584000123, "updatedAt": 1792584060456}}
|
||||
""");
|
||||
PersistentStorage<String, Application> storage = new PersistentStorage<>(file, APPLICATIONS);
|
||||
storage.load();
|
||||
|
||||
Application app = storage.get("00abc").orElseThrow();
|
||||
assertEquals(Instant.parse("2026-10-21T12:00:00.123Z"), app.getCreatedAt());
|
||||
assertEquals(Instant.parse("2026-10-21T12:01:00.456Z"), app.getUpdatedAt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void applicationTimestampsSurviveAReload() {
|
||||
Path file = tempDir.resolve("emr-serverless-applications.json");
|
||||
Application app = new Application();
|
||||
app.setApplicationId("00abc");
|
||||
app.setCreatedAt(Instant.parse("2026-10-21T12:00:00.123Z"));
|
||||
app.setUpdatedAt(Instant.parse("2026-10-21T12:01:00.456Z"));
|
||||
new PersistentStorage<>(file, APPLICATIONS).put("00abc", app);
|
||||
|
||||
PersistentStorage<String, Application> reader = new PersistentStorage<>(file, APPLICATIONS);
|
||||
reader.load();
|
||||
|
||||
Application reloaded = reader.get("00abc").orElseThrow();
|
||||
assertEquals(app.getCreatedAt(), reloaded.getCreatedAt());
|
||||
assertEquals(app.getUpdatedAt(), reloaded.getUpdatedAt());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package io.github.hectorvent.floci.testing;
|
||||
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
/** One EMR Serverless REST JSON request, signed for a named Region. */
|
||||
public final class EmrServerlessRequests {
|
||||
private EmrServerlessRequests() {}
|
||||
|
||||
public static RequestSpecification emrServerless(String region) {
|
||||
return given()
|
||||
.header("Authorization", "AWS4-HMAC-SHA256 Credential=TEST/20260819/" + region
|
||||
+ "/emr-serverless/aws4_request, SignedHeaders=host;x-amz-date, Signature=test")
|
||||
.contentType("application/json");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user