mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 16:11:48 -05:00
feat(emr-serverless): tag job runs and report their attempts (#6297)
TagResource, UntagResource and ListTagsForResource now take job run ARNs
(.../applications/<id>/jobruns/<id>), which the model's ResourceArn
allows ("the supported resources are Amazon EMR Serverless applications
and job runs"). They work on the tags StartJobRun stores, so GetJobRun
reports the current set, under the same rules as an application's: at
most 50 tags, no "aws:" prefix. An ARN must be the run's own, so one of
another application or account names nothing, and once an application
is deleted its runs' ARNs name nothing, as its own ARN already does. A
session ARN, which the pattern also allows, now answers
ResourceNotFoundException rather than ValidationException, as sessions
are not emulated.
ListJobRunAttempts (GET .../jobruns/{jobRunId}/attempts) and GetJobRun's
attempt parameter report attempts. Nothing runs, so no run fails and
none is retried: every run is one attempt, number 1, created and updated
with the run. GetJobRun, ListJobRuns and ListJobRunAttempts carry it.
GetJobRun with attempt 1 or none returns the run; another attempt
answers ResourceNotFoundException, in Floci's words, as no source shows
AWS's answer for an attempt a run never made, and leaves the run as it
was.
Also from the #6202 review:
- From release emr-7.11.0 a BATCH run's executionTimeoutMinutes must be
1 to 10080. The model: "the maximum value is 10080 minutes (7 days)
starting with Amazon EMR release 7.11. Setting a value of 0 to disable
the timeout is no longer supported for BATCH mode job runs." Earlier
releases and STREAMING runs keep 0 to 1,000,000. No source gives the
error; ValidationException, in Floci's words. The check runs before
auto-start, under the application's lock, so a refused run leaves the
application as it was.
- ListJobRuns refuses a state or mode that does not exist and more than
8 states, and ListApplications a state that does not exist and more
than 7, with the framework ValidationException. A typo listed nothing
before. ListApplications' maxResults outside 1 to 50 now answers the
same framework message, joined with any states violation.
- EmrServerlessRegionIntegrationTest uses EmrServerlessRequests, which
gains tagsPath, and pins a job run ARN across Regions;
EmrServerlessTagIntegrationTest moves onto the same helpers.
The enum and range violations are now SmithyValidationErrors.notInEnum,
notAllInEnum and outOfRange, which EMR Serverless uses.
Part of #6046 (part 9).
This commit is contained in:
1 parent
581cd62790
commit
63d577a245
18 files changed
+887
-137
No files matched your search
+41
@@ -9,9 +9,11 @@ import software.amazon.awssdk.services.emrserverless.model.Application;
|
||||
import software.amazon.awssdk.services.emrserverless.model.ApplicationState;
|
||||
import software.amazon.awssdk.services.emrserverless.model.ConflictException;
|
||||
import software.amazon.awssdk.services.emrserverless.model.JobRun;
|
||||
import software.amazon.awssdk.services.emrserverless.model.JobRunAttemptSummary;
|
||||
import software.amazon.awssdk.services.emrserverless.model.JobRunMode;
|
||||
import software.amazon.awssdk.services.emrserverless.model.JobRunState;
|
||||
import software.amazon.awssdk.services.emrserverless.model.JobRunSummary;
|
||||
import software.amazon.awssdk.services.emrserverless.model.ResourceNotFoundException;
|
||||
import software.amazon.awssdk.services.emrserverless.model.StartJobRunResponse;
|
||||
import software.amazon.awssdk.services.emrserverless.model.ValidationException;
|
||||
|
||||
@@ -146,4 +148,43 @@ class EmrServerlessJobRunTest {
|
||||
emr.cancelJobRun(r -> r.applicationId(applicationId).jobRunId(streaming));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("A run is its one attempt: GetJobRun and ListJobRunAttempts report attempt 1")
|
||||
void attempts() {
|
||||
String jobRunId = startSparkRun(JobRunMode.BATCH).jobRunId();
|
||||
|
||||
JobRun run = emr.getJobRun(r -> r.applicationId(applicationId).jobRunId(jobRunId).attempt(1)).jobRun();
|
||||
assertThat(run.attempt()).isEqualTo(1);
|
||||
assertThat(run.attemptCreatedAt()).isEqualTo(run.createdAt());
|
||||
assertThat(run.attemptUpdatedAt()).isEqualTo(run.updatedAt());
|
||||
|
||||
List<JobRunAttemptSummary> attempts = emr.listJobRunAttempts(r -> r
|
||||
.applicationId(applicationId).jobRunId(jobRunId)).jobRunAttempts();
|
||||
assertThat(attempts).singleElement().satisfies(attempt -> {
|
||||
assertThat(attempt.id()).isEqualTo(jobRunId);
|
||||
assertThat(attempt.attempt()).isEqualTo(1);
|
||||
assertThat(attempt.jobCreatedAt()).isEqualTo(run.createdAt());
|
||||
assertThat(attempt.state()).isEqualTo(JobRunState.SUCCESS);
|
||||
assertThat(attempt.mode()).isEqualTo(JobRunMode.BATCH);
|
||||
});
|
||||
|
||||
assertThatThrownBy(() -> emr.getJobRun(r -> r.applicationId(applicationId).jobRunId(jobRunId).attempt(2)))
|
||||
.isInstanceOf(ResourceNotFoundException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("A run's ARN takes tags, which GetJobRun reports")
|
||||
void jobRunTags() {
|
||||
StartJobRunResponse started = startSparkRun(JobRunMode.BATCH);
|
||||
|
||||
emr.tagResource(r -> r.resourceArn(started.arn()).tags(Map.of("env", "dev")));
|
||||
assertThat(emr.listTagsForResource(r -> r.resourceArn(started.arn())).tags())
|
||||
.containsEntry("team", "data")
|
||||
.containsEntry("env", "dev");
|
||||
|
||||
emr.untagResource(r -> r.resourceArn(started.arn()).tagKeys("env"));
|
||||
assertThat(emr.getJobRun(r -> r.applicationId(applicationId).jobRunId(started.jobRunId())).jobRun().tags())
|
||||
.containsOnlyKeys("team");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user