test(emr): check a cluster-mode driver's output reaches containers/ (#8016)

The archive of a cluster's YARN container logs was covered by
EmrClusterStorageTest only. The Docker case that runs a Spark step in
either deploy mode now gives its cluster a LogUri, and checks that the
cluster-mode driver's own output, which the step's logs do not hold, is
in a container's stdout.gz under
<LogUri>/<cluster-id>/containers/<application>/<container>/, where a
user reads it.

Reading a gzipped object back from S3 was private to two Docker classes
already; it is now S3TestClients.gunzipped, which those two use too.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-11 10:53:35 -06:00
1 parent 0716f162f5
commit 21cfcea3dd
4 files changed
+41 -19

No files matched your search

@@ -50,6 +50,7 @@ import static io.floci.aws.testing.EmrServerlessRequests.deleteApplication;
import static io.floci.aws.testing.EmrServerlessRequests.startJobRun;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
@@ -188,18 +189,25 @@ class EmrDockerRunnerDockerIntegrationTest {
executors = sc.parallelize(range(4), 4).map(lambda _: socket.gethostname()).distinct().collect()
where = " ".join([sc.master, sc.getConf().get("spark.submit.deployMode"),
str(socket.gethostname() in executors)])
print("driver: " + where, flush=True)
spark.createDataFrame([(where,)], ["value"]).coalesce(1).write.text(sys.argv[1])
""");
startCluster("[]");
startCluster("[]", s3Uri("logs/"));
// Its driver in the step's container, its executors on the primary node.
assertEquals("COMPLETED", runStep("command-runner.jar", "spark-submit",
s3Uri("side/where.py"), s3Uri("client/")));
assertEquals("yarn client False\n", partFiles("client/"));
// Its driver on the primary node too.
// Its driver on the primary node too, whose output is in its application's container logs, where a user
// reads it, the step's own holding only the client's.
assertEquals("COMPLETED", runStep("command-runner.jar", "spark-submit", "--deploy-mode", "cluster",
s3Uri("side/where.py"), s3Uri("cluster/")));
assertEquals("yarn cluster True\n", partFiles("cluster/"));
List<String> driverLogs = containerStdoutsHolding("driver: yarn cluster True");
assertEquals(1, driverLogs.size(), () -> "container stdouts with the driver's line: " + driverLogs);
String containers = "logs/" + clusterId + "/containers/";
assertTrue(driverLogs.get(0).matches(containers + "application_\\d+_\\d+/container_\\w+/stdout\\.gz"),
driverLogs.get(0));
}
@Test
@@ -331,7 +339,13 @@ class EmrDockerRunnerDockerIntegrationTest {
/** A one-primary cluster of the cached release, with {@code configurations} as its Configurations. */
private void startCluster(String configurations) {
startCluster(configurations, null);
}
/** The same, its logs under {@code logUri} when that is not null, as the cluster's {@code LogUri}. */
private void startCluster(String configurations, String logUri) {
clusterId = emr("RunJobFlow", "{\"Name\":\"docker-runner\",\"ReleaseLabel\":\"emr-7.5.0\","
+ (logUri == null ? "" : "\"LogUri\":\"" + logUri + "\",")
+ "\"Applications\":[{\"Name\":\"Hadoop\"},{\"Name\":\"Spark\"}],"
+ "\"Configurations\":" + configurations + ","
+ "\"Instances\":{\"KeepJobFlowAliveWhenNoSteps\":true,\"InstanceGroups\":[{\"Name\":\"primary\","
@@ -375,6 +389,16 @@ class EmrDockerRunnerDockerIntegrationTest {
return counts;
}
/** The keys of the cluster's container {@code stdout} logs under {@code logs/} that hold {@code line}. */
private List<String> containerStdoutsHolding(String line) {
String prefix = "logs/" + clusterId + "/containers/";
return s3.listObjectsV2Paginator(request -> request.bucket(bucket).prefix(prefix)).contents().stream()
.map(S3Object::key)
.filter(key -> key.endsWith("/stdout.gz"))
.filter(key -> S3TestClients.gunzipped(s3, bucket, key).contains(line))
.toList();
}
/** What a job wrote under {@code prefix}: its part files, in key order, one after the other. */
private String partFiles(String prefix) {
StringBuilder text = new StringBuilder();
@@ -26,11 +26,9 @@ import software.amazon.awssdk.services.s3.model.S3Object;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
import static io.floci.aws.testing.EmrRequests.awaitStep;
import static io.floci.aws.testing.EmrRequests.emr;
@@ -248,12 +246,7 @@ class EmrHiveStepsDockerIntegrationTest {
/** A log of the step's, in the step log folder of the Management Guide's "Log locations". */
private String stepLog(String stepId, String name) {
String key = "logs/" + clusterId + "/steps/" + stepId + "/" + name;
try (GZIPInputStream in = new GZIPInputStream(s3.getObject(request -> request.bucket(bucket).key(key)))) {
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return S3TestClients.gunzipped(s3, bucket, "logs/" + clusterId + "/steps/" + stepId + "/" + name);
}
private void put(String key, String text) {
@@ -20,12 +20,8 @@ import software.amazon.awssdk.services.glue.model.Table;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.S3Object;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
import static io.floci.aws.testing.EmrServerlessRequests.awaitJobRun;
import static io.floci.aws.testing.EmrServerlessRequests.createApplication;
@@ -171,10 +167,6 @@ class EmrServerlessHiveDockerIntegrationTest {
}
private String gunzipped(String key) {
try (GZIPInputStream in = new GZIPInputStream(s3.getObject(request -> request.bucket(bucket).key(key)))) {
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return S3TestClients.gunzipped(s3, bucket, key);
}
}
@@ -7,7 +7,11 @@ import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
/** AWS SDK S3 clients pointed at the Floci instance a {@code @QuarkusTest} runs, and what a test does with them. */
public final class S3TestClients {
@@ -32,4 +36,13 @@ public final class S3TestClients {
.forEach(object -> s3.deleteObject(request -> request.bucket(bucket).key(object.key())));
s3.deleteBucket(request -> request.bucket(bucket));
}
/** The object at {@code key} in {@code bucket}, gunzipped, as a test reads back a log Floci wrote there. */
public static String gunzipped(S3Client s3, String bucket, String key) {
try (GZIPInputStream in = new GZIPInputStream(s3.getObject(request -> request.bucket(bucket).key(key)))) {
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}