fix(emr): list every emr-7.x and emr-spark release, as AWS names and orders them (#9114)

ListReleaseLabels, DescribeReleaseLabel and ListSupportedInstanceTypes
knew five releases, the newest emr-7.5.0, so they refused emr-7.13.0
and the emr-spark-8.x releases Floci runs clusters on. The catalogue
now holds every emr-7.x release, emr-7.0.0 to emr-7.14.0, and the AWS
runtime for Apache Spark's emr-spark-8.0.0, 8.1.0 and 8.2.0, beside
emr-6.15.0, emr-6.14.0 and emr-5.36.2. Each release's applications,
versions and Amazon Linux releases come from its Release Guide page,
as before; the emr-7.14.0, emr-spark-8.1.0 and emr-spark-8.2.0 pages
list no Amazon Linux release, so those report none.

Application names are spelled as AWS answers them, Spark, HBase,
ZooKeeper and JupyterHub, where they were lowercased; each page lists
them that way too, with Trino for "Trino (PrestoSQL)". The Application
filter of ListReleaseLabels still matches without regard to case.

ListReleaseLabels lists the numbered releases newest first, and the
emr-spark ones after them oldest first, the order AWS answered for
that family. DescribeReleaseLabel without a label describes the first
release listed, now emr-7.14.0.

An unknown release label gets AWS's recorded answers, which differ by
operation: DescribeReleaseLabel "The release label isn't valid." with
ErrorCode InvalidInputParameter, and ListSupportedInstanceTypes "The
supplied release label is invalid: <label>." with ErrorCode
INVALID_RELEASE_LABEL, a missing label reading null. A blank label is
refused there too, and a blank default-release-label setting no
longer adds an empty release to the list.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-20 18:08:32 -04:00
1 parent 30c37a129c
commit 89e0242167
10 files changed
+397 -196

No files matched your search

@@ -13,10 +13,10 @@ import static org.hamcrest.Matchers.hasSize;
/**
* A default release label the catalogue does not describe is still a known release: it is listed
* (newest first here) and described with no applications, so Floci never calls its own default
* unknown.
* (first here, as the newest numbered release) and described with no applications, so Floci never
* calls its own default unknown.
*
* <p>The default release label, {@code emr-7.9.0}, comes from {@link RdsMockProfile}.
* <p>The default release label, {@code emr-7.15.0}, comes from {@link RdsMockProfile}.
*/
@QuarkusTest
@TestProfile(RdsMockProfile.class)
@@ -30,9 +30,10 @@ class EmrReleaseCatalogCustomDefaultIntegrationTest {
@Test
void theConfiguredDefaultIsListedAndDescribed() {
emr("ListReleaseLabels", "{}").then().statusCode(200)
.body("ReleaseLabels[0]", equalTo("emr-7.9.0"));
emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-7.9.0\"}").then().statusCode(200)
.body("ReleaseLabel", equalTo("emr-7.9.0"))
.body("ReleaseLabels[0]", equalTo("emr-7.15.0"))
.body("ReleaseLabels[1]", equalTo("emr-7.14.0"));
emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-7.15.0\"}").then().statusCode(200)
.body("ReleaseLabel", equalTo("emr-7.15.0"))
.body("Applications", hasSize(0));
}
}
@@ -28,10 +28,16 @@ class EmrReleaseCatalogIntegrationTest {
}
@Test
void listReleaseLabelsNewestFirstWithFiltersAndPaging() {
void listReleaseLabelsInAwsOrderWithFiltersAndPaging() {
// The numbered releases newest first, then the emr-spark ones oldest first.
emr("ListReleaseLabels", "{}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-7.5.0", "emr-7.4.0", "emr-6.15.0", "emr-6.14.0", "emr-5.36.2"))
.body("ReleaseLabels", contains("emr-7.14.0", "emr-7.13.0", "emr-7.12.0", "emr-7.11.0", "emr-7.10.0",
"emr-7.9.0", "emr-7.8.0", "emr-7.7.0", "emr-7.6.0", "emr-7.5.0", "emr-7.4.0", "emr-7.3.0",
"emr-7.2.0", "emr-7.1.0", "emr-7.0.0", "emr-6.15.0", "emr-6.14.0", "emr-5.36.2",
"emr-spark-8.0.0", "emr-spark-8.1.0", "emr-spark-8.2.0"))
.body("NextToken", nullValue());
emr("ListReleaseLabels", "{\"Filters\":{\"Prefix\":\"emr-spark\"}}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-spark-8.0.0", "emr-spark-8.1.0", "emr-spark-8.2.0"));
emr("ListReleaseLabels", "{\"Filters\":{\"Prefix\":\"emr-6\"}}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-6.15.0", "emr-6.14.0"));
emr("ListReleaseLabels", "{\"Filters\":{\"Application\":\"Spark@3.4.1\"}}").then().statusCode(200)
@@ -39,15 +45,18 @@ class EmrReleaseCatalogIntegrationTest {
// The version matches without regard to case too: the catalogue holds 4.14.3-HBase-1.4.
emr("ListReleaseLabels", "{\"Filters\":{\"Application\":\"phoenix@4.14.3-hbase-1.4\"}}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-5.36.2"));
// Every release but emr-5.36.2 has Delta.
emr("ListReleaseLabels", "{\"Filters\":{\"Application\":\"delta\"}}").then().statusCode(200)
.body("ReleaseLabels", everyItem(startsWith("emr-")))
.body("ReleaseLabels", hasSize(4));
.body("ReleaseLabels", hasSize(20));
emr("ListReleaseLabels", "{\"Filters\":{\"Application\":\"spark@4.1.1\"}}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-spark-8.1.0"));
String token = emr("ListReleaseLabels", "{\"MaxResults\":2}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-7.5.0", "emr-7.4.0"))
.body("ReleaseLabels", contains("emr-7.14.0", "emr-7.13.0"))
.extract().path("NextToken");
emr("ListReleaseLabels", "{\"MaxResults\":2,\"NextToken\":\"" + token + "\"}").then().statusCode(200)
.body("ReleaseLabels", contains("emr-6.15.0", "emr-6.14.0"));
.body("ReleaseLabels", contains("emr-7.12.0", "emr-7.11.0"));
// A token belongs to the filters it was issued for.
String filtered = emr("ListReleaseLabels", "{\"MaxResults\":1,\"Filters\":{\"Prefix\":\"emr-6\"}}")
@@ -64,14 +73,28 @@ class EmrReleaseCatalogIntegrationTest {
@Test
void describeReleaseLabelReportsApplicationsAndOsReleases() {
// Names as AWS spells them, versions without the -amzn-N build suffix.
emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-7.5.0\"}").then().statusCode(200)
.body("ReleaseLabel", equalTo("emr-7.5.0"))
.body("Applications.find { it.Name == 'spark' }.Version", equalTo("3.5.2"))
.body("Applications.find { it.Name == 'hadoop' }.Version", equalTo("3.4.0"))
.body("Applications.find { it.Name == 'Spark' }.Version", equalTo("3.5.2"))
.body("Applications.find { it.Name == 'Hadoop' }.Version", equalTo("3.4.0"))
.body("Applications.find { it.Name == 'HBase' }.Version", equalTo("2.5.10"))
.body("Applications.find { it.Name == 'ZooKeeper' }.Version", equalTo("3.9.2"))
.body("Applications.find { it.Name == 'Trino' }.Version", equalTo("446"))
.body("AvailableOSReleases.Label", hasItem(startsWith("2023.")));
// No label: the latest release.
emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-7.13.0\"}").then().statusCode(200)
.body("Applications.find { it.Name == 'Spark' }.Version", equalTo("3.5.6"))
.body("Applications.find { it.Name == 'Hadoop' }.Version", equalTo("3.4.2"))
.body("AvailableOSReleases.Label", contains("2023.12.20260803.3", "2023.12.20260727.0"));
// The AWS runtime for Apache Spark has no Hadoop, and its page lists no Amazon Linux release.
emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-spark-8.1.0\"}").then().statusCode(200)
.body("Applications.Name", contains("AmazonCloudWatchAgent", "Delta", "Hudi", "Iceberg",
"JupyterEnterpriseGateway", "Livy", "Spark"))
.body("Applications.find { it.Name == 'Spark' }.Version", equalTo("4.1.1"))
.body("AvailableOSReleases", hasSize(0));
// No label: the first release listed.
emr("DescribeReleaseLabel", "{}").then().statusCode(200)
.body("ReleaseLabel", equalTo("emr-7.5.0"));
.body("ReleaseLabel", equalTo("emr-7.14.0"));
// MaxResults is reserved for future use: every application comes back, with no token.
int all = emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-5.36.2\"}").then().statusCode(200)
.extract().path("Applications.size()");
@@ -89,6 +112,24 @@ class EmrReleaseCatalogIntegrationTest {
.body("SupportedInstanceTypes.find { it.Type == 'm6g.xlarge' }.Architecture", equalTo("AARCH64"))
.body("SupportedInstanceTypes.find { it.Type == 'm5.xlarge' }.Architecture", equalTo("X86_64"))
.body("SupportedInstanceTypes.find { it.Type == 'm5d.xlarge' }.StorageGB", equalTo(150));
emr("ListSupportedInstanceTypes", "{\"ReleaseLabel\":\"emr-spark-8.2.0\"}").then().statusCode(200)
.body("SupportedInstanceTypes.Type", hasItem("m5.xlarge"));
}
@Test
void anUnknownReleaseLabelIsRefusedInEachOperationsOwnWording() {
emr("DescribeReleaseLabel", "{\"ReleaseLabel\":\"emr-99.99.0\"}").then().statusCode(400)
.body("__type", equalTo("InvalidRequestException"))
.body("message", equalTo("The release label isn't valid."))
.body("ErrorCode", equalTo("InvalidInputParameter"));
emr("ListSupportedInstanceTypes", "{\"ReleaseLabel\":\"emr-99.99.0\"}").then().statusCode(400)
.body("__type", equalTo("InvalidRequestException"))
.body("message", equalTo("The supplied release label is invalid: emr-99.99.0."))
.body("ErrorCode", equalTo("INVALID_RELEASE_LABEL"));
emr("ListSupportedInstanceTypes", "{}").then().statusCode(400)
.body("__type", equalTo("InvalidRequestException"))
.body("message", equalTo("The supplied release label is invalid: null."))
.body("ErrorCode", equalTo("INVALID_RELEASE_LABEL"));
}
@Test
@@ -0,0 +1,46 @@
package io.floci.aws.services.emr;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class EmrReleaseCatalogTest {
@Test
void theCatalogueIsInListingOrder() {
List<String> labels = EmrReleaseCatalog.RELEASES.stream().map(EmrReleaseCatalog.Release::label).toList();
List<String> sorted = new ArrayList<>(labels);
Collections.shuffle(sorted, new Random(77));
sorted.sort(EmrReleaseCatalog.LISTING_ORDER);
assertEquals(labels, sorted);
assertEquals(labels.size(), new HashSet<>(labels).size());
}
@Test
void numberedReleasesComeNewestFirstByNumberAndTheSparkRuntimeOnesAfterOldestFirst() {
List<String> labels = new ArrayList<>(List.of("emr-spark-8.3.0", "emr-6.9.0", "emr-7.15.0",
"emr-spark-8.0.0", "emr-6.15.0", "emr-5.36.2", "emr-7.9.0", "emr-7.10.0"));
labels.sort(EmrReleaseCatalog.LISTING_ORDER);
assertEquals(List.of("emr-7.15.0", "emr-7.10.0", "emr-7.9.0", "emr-6.15.0", "emr-6.9.0", "emr-5.36.2",
"emr-spark-8.0.0", "emr-spark-8.3.0"), labels);
}
@Test
void applicationsCarryAwsNamesAndConciseVersions() {
for (EmrReleaseCatalog.Release release : EmrReleaseCatalog.RELEASES) {
assertTrue(release.applications().stream().anyMatch(a -> a.name().equals("Spark")), release.label());
for (EmrReleaseCatalog.Application app : release.applications()) {
assertFalse(app.version().contains("-amzn-"), release.label() + " " + app);
assertTrue(Character.isUpperCase(app.name().charAt(0)), release.label() + " " + app);
}
}
}
}
@@ -427,6 +427,15 @@ final class EmrServiceFixture {
iam);
}
/** A new service on the same storage and clock, as {@link #restart} builds, with this default release label. */
EmrService withDefaultReleaseLabel(String label) {
EmulatorConfig config = config(false);
when(config.services().emr().defaultReleaseLabel()).thenReturn(label);
return new EmrService(storage, config, new RegionResolver(REGION, ACCOUNT), publisher, clock,
mock(EmrService.Wakeups.class), runner, bootstrap, clusterStorage, releaseImages, this::handToThread,
iam);
}
private EmulatorConfig config(boolean reconcile) {
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
when(config.services().emr().defaultReleaseLabel()).thenReturn("emr-7.5.0");
@@ -852,6 +852,17 @@ class EmrServiceTest {
/** ListSteps' states, newest step first, as it lists them. */
@Test
void aBlankDefaultReleaseLabelIsNoReleaseAndAnEmptyLabelIsRefused() {
EmrService blank = new EmrServiceFixture().withDefaultReleaseLabel("");
List<String> catalogue = EmrReleaseCatalog.RELEASES.stream().map(EmrReleaseCatalog.Release::label).toList();
assertEquals(catalogue, blank.listReleaseLabels(null, null, null, null).items());
AwsException refused = assertThrows(AwsException.class, () -> blank.listSupportedInstanceTypes("", null));
assertEquals("InvalidRequestException", refused.getErrorCode());
assertEquals("The supplied release label is invalid: .", refused.getMessage());
assertEquals(Map.of("ErrorCode", "INVALID_RELEASE_LABEL"), refused.getExtendedData());
}
private static List<String> ids(List<EmrStep> steps) {
return steps.stream().map(EmrStep::getId).toList();
}
@@ -42,7 +42,7 @@ import java.util.Set;
* <li>{@code floci.services.iot.enabled=false} turns IoT off, so its data-plane host routing never
* sees a request. {@code ApiGatewayCustomDomainIamAuthIntegrationTest} relies on it, to check the
* custom-domain invocation path with IoT disabled.</li>
* <li>{@code floci.services.emr.default-release-label=emr-7.9.0} sets a default release the
* <li>{@code floci.services.emr.default-release-label=emr-7.15.0} sets a default release the
* catalogue does not describe. {@code EmrReleaseCatalogCustomDefaultIntegrationTest} relies on
* it.</li>
* <li>{@code floci.services.firehose.flush-record-count=2} delivers a batch of two records inline.
@@ -102,7 +102,7 @@ public class RdsMockProfile implements QuarkusTestProfile {
Map.entry("quarkus.http.test-port", String.valueOf(TEST_PORT)),
Map.entry("quarkus.http.port", String.valueOf(TEST_PORT)),
Map.entry("floci.services.iot.enabled", "false"),
Map.entry("floci.services.emr.default-release-label", "emr-7.9.0"),
Map.entry("floci.services.emr.default-release-label", "emr-7.15.0"),
Map.entry("floci.services.firehose.flush-record-count", "2"),
Map.entry("floci.services.elasticache.default-image", ELASTICACHE_SHELL_LESS_IMAGE),
Map.entry("floci.services.elasticache.shell-less-backend", "true"),