feat(core): have the JVMs in Lambda, ECS, Batch and Flink containers trust Floci's CA (#6945)

With TLS on, Floci writes its CA bundle as a Java trust store too, but
only EMR's containers got it: a launcher had to copy it in with
ContainerLifecycleManager.copyJavaTrustStore and point its JVMs at it
with a shell line. So a Java Lambda function, ECS task, Batch job or
Flink application calling Floci over HTTPS still failed with "PKIX
path building failed" unless it brought a trust store of its own.

ContainerBuilder now has withJavaTrustStore(). For a container whose
spec asks for it, the lifecycle manager copies the trust store in
beside the CA bundle as it creates the container, and sets
JAVA_TOOL_OPTIONS to Floci's -Djavax.net.ssl.trustStore ahead of the
value the spec gives it, or the image's own when the spec sets none,
so a trust store the workload names itself still replaces Floci's. A
copy that fails creates the container again without any of the trust
variables, as a failed bundle copy already did, so JAVA_TOOL_OPTIONS
never names a file that is not there.

Lambda functions on a Java runtime or from a container image, ECS task
containers, Batch jobs, and Flink's JobManager and TaskManager ask for
it, and so do EMR steps and EMR Serverless job runs, whose
spark-submit starts directly again. The bootstrap actions' container
keeps the separate copy and the shell line, since it is kept as the
steps' image, which would keep a JAVA_TOOL_OPTIONS set at its
creation. Other containers are unchanged.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-10-29 18:04:46 -05:00
1 parent 62527ebaa8
commit 743bede481
22 files changed
+470 -81

No files matched your search

@@ -267,6 +267,32 @@ class ContainerCaBundleTest {
assertEquals(ContainerCaBundle.env(), ContainerCaBundle.appendEnv(List.of()));
}
// Options after Floci's win, so a trust store they name replaces it, as the JVM test below shows.
@Test
void appendJavaTrustEnvPutsFlocisOptionAheadOfTheContainersOwnWhichReplacesTheImages() {
assertEquals(List.of("FOO=bar", "JAVA_TOOL_OPTIONS=" + ContainerCaBundle.JAVA_TRUST_OPTIONS + " -Xss2m"),
ContainerCaBundle.appendJavaTrustEnv(List.of("FOO=bar", "JAVA_TOOL_OPTIONS=-Xss2m"),
List.of("JAVA_TOOL_OPTIONS=-Dimage=1")));
}
@Test
void appendJavaTrustEnvPutsFlocisOptionAheadOfTheImagesLastWhenTheContainerSetsNone() {
assertEquals(List.of("FOO=bar", "JAVA_TOOL_OPTIONS=" + ContainerCaBundle.JAVA_TRUST_OPTIONS + " -Dimage=2"),
ContainerCaBundle.appendJavaTrustEnv(List.of("FOO=bar"),
List.of("PATH=/bin", "JAVA_TOOL_OPTIONS=-Dimage=1", "JAVA_TOOL_OPTIONS=-Dimage=2")));
}
@Test
void appendJavaTrustEnvGivesFlocisOptionAloneWhenNothingElseIsSet() {
List<String> alone = List.of("JAVA_TOOL_OPTIONS=" + ContainerCaBundle.JAVA_TRUST_OPTIONS);
assertEquals(alone, ContainerCaBundle.appendJavaTrustEnv(List.of(), List.of("PATH=/bin")));
assertEquals(alone, ContainerCaBundle.appendJavaTrustEnv(List.of("JAVA_TOOL_OPTIONS="), List.of()));
// A bare key unsets the image's value, so none is kept.
assertEquals(alone, ContainerCaBundle.appendJavaTrustEnv(List.of("JAVA_TOOL_OPTIONS"),
List.of("JAVA_TOOL_OPTIONS=-Dimage=1")));
}
@Test
void theJavaTrustStoreHoldsEveryCertificateOfTheBundleAsATrustedEntry() throws Exception {
Path tlsDir = tempDir.resolve("tls");
@@ -12,6 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -116,6 +117,14 @@ class ContainerBuilderTest {
assertEquals("host", spec.cgroupnsMode());
}
@Test
void withJavaTrustStoreRecordsThatTheContainersJvmsTrustFlocisCa() {
TestFixture fixture = new TestFixture();
assertTrue(fixture.builder.newContainer("alpine").withJavaTrustStore().build().javaTrustStore());
assertFalse(fixture.builder.newContainer("alpine").build().javaTrustStore());
}
@Test
void withUserAndGroupAddRoundTripIntoSpec() {
TestFixture fixture = new TestFixture();
@@ -34,7 +34,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* HTTPS site. Python is the runtime because it honours {@code SSL_CERT_FILE}, the variable that
* replaces the trust store: the image's own root directory is pointed away, so if the bundle
* lacked the public roots the second call would fail, and if it lacked the Floci CA the first
* would. Skipped without a Docker daemon, like the other {@code *DockerIntegrationTest} classes.
* would. A JVM ignores that variable, so a Java container that asks for the trust store makes
* the same two calls on Corretto 8, the JVM of Lambda's oldest Java runtime: it reads the PKCS12
* store through {@code JAVA_TOOL_OPTIONS}, and that store replaces the JDK's own. Skipped without
* a Docker daemon, like the other {@code *DockerIntegrationTest} classes.
*/
@QuarkusTest
@TestProfile(ContainerCaBundleDockerIntegrationTest.Profile.class)
@@ -89,6 +92,55 @@ class ContainerCaBundleDockerIntegrationTest {
.withEntrypoint(List.of("python3", "-c", script))
.build();
assertExitsCleanly(spec);
}
@Test
void javaContainerAskingForTheTrustStoreTrustsFlociAndPublicRootsKeepingItsOwnOptions() {
String probe = """
import java.net.HttpURLConnection;
import java.net.URL;
public class Probe {
public static void main(String[] args) throws Exception {
check(200, status("https://host.docker.internal:%d/_floci/ca.pem"));
// Any status will do: a handshake the store cannot verify throws instead.
status("https://public.ecr.aws/");
check("/etc/floci-ca-bundle.p12", System.getProperty("javax.net.ssl.trustStore"));
check("kept", System.getProperty("floci.probe"));
System.out.println("ok");
}
static int status(String url) throws Exception {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setConnectTimeout(20000);
connection.setReadTimeout(20000);
return connection.getResponseCode();
}
static void check(Object expected, Object actual) {
if (!expected.equals(actual)) {
throw new AssertionError("expected " + expected + ", got " + actual);
}
}
}
""".formatted(testSslPort);
ContainerSpec spec = containerBuilder.newContainer(TestImages.CORRETTO_8)
.withName("floci-java-trust-store-test-" + Long.toString(System.nanoTime(), 36))
.withHostDockerInternalOnLinux()
// The task's own option, which Floci's has to join rather than replace.
.withEnv("JAVA_TOOL_OPTIONS", "-Dfloci.probe=kept")
.withEnv("PROBE_SOURCE", probe)
.withJavaTrustStore()
.withEntrypoint(List.of("sh", "-c", "printf '%s' \"$PROBE_SOURCE\" > /tmp/Probe.java"
+ " && javac -d /tmp /tmp/Probe.java && java -cp /tmp Probe"))
.build();
assertExitsCleanly(spec);
}
private void assertExitsCleanly(ContainerSpec spec) {
ContainerLifecycleManager.ContainerInfo info = lifecycle.createAndStart(spec);
try {
Integer status = dockerClient.waitContainerCmd(info.containerId())
@@ -127,10 +179,11 @@ class ContainerCaBundleDockerIntegrationTest {
/**
* Lays down what a TLS-on boot writes: the local CA, a leaf whose SANs include the name the
* container dials, and the bundle. The bootstrap config source reads system properties and the
* environment, which a test profile does not set, so the files are prepared here and the
* registry keys point at them; {@code floci.tls.enabled} is what makes the lifecycle manager
* inject the bundle. Quarkus binds every interface so the container reaches the test port.
* container dials, the bundle and its Java trust store. The bootstrap config source reads
* system properties and the environment, which a test profile does not set, so the files are
* prepared here and the registry keys point at them; {@code floci.tls.enabled} is what makes
* the lifecycle manager inject the bundle. Quarkus binds every interface so the container
* reaches the test port.
*/
public static final class Profile implements QuarkusTestProfile {
@@ -146,7 +199,7 @@ class ContainerCaBundleDockerIntegrationTest {
List.of("localhost", "127.0.0.1", "host.docker.internal"), KeyAlgorithm.RSA_2048, null);
Files.writeString(CERT_FILE, leaf.certificatePem());
Files.writeString(KEY_FILE, leaf.privateKeyPem());
ContainerCaBundle.write(TLS_DIR, ca.certificatePath());
ContainerCaBundle.writeJavaTrustStore(ContainerCaBundle.write(TLS_DIR, ca.certificatePath()));
} catch (IOException | GeneralSecurityException e) {
throw new IllegalStateException("Failed to prepare the TLS test files", e);
}
@@ -4,8 +4,12 @@ import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.CopyArchiveToContainerCmd;
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.command.InspectImageCmd;
import com.github.dockerjava.api.command.InspectImageResponse;
import com.github.dockerjava.api.command.RemoveContainerCmd;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.ContainerConfig;
import io.github.hectorvent.floci.config.ContainerCaBundle;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.config.TlsConfigSource;
import io.github.hectorvent.floci.services.lambda.launcher.ImageCacheService;
@@ -317,11 +321,146 @@ class ContainerLifecycleManagerCaBundleTest {
assertFalse(manager().copyJavaTrustStore("container-id"));
}
@Test
void aSpecAskingForTheJavaTrustStoreGetsItBesideTheBundleWithJavaToolOptionsAheadOfTheImages() throws Exception {
when(tlsConfig.enabled()).thenReturn(true);
writeBundle();
byte[] trustStore = writeJavaTrustStore();
CreateContainerCmd createCmd = stubCreateContainer();
stubImageEnv("PATH=/usr/bin", "JAVA_TOOL_OPTIONS=-Dimage=1");
List<byte[]> archives = stubCopies();
assertEquals("container-id", manager().create(javaSpecWithEnv(List.of("FOO=bar"))));
List<String> expected = new ArrayList<>(List.of("FOO=bar"));
expected.addAll(ContainerCaBundle.env());
expected.add("JAVA_TOOL_OPTIONS=-Djavax.net.ssl.trustStore=/etc/floci-ca-bundle.p12 -Dimage=1");
assertEquals(expected, capturedEnv(createCmd));
assertEquals(2, archives.size());
assertBundleArchive(new ByteArrayInputStream(archives.get(0)));
assertSingleFileArchive(new ByteArrayInputStream(archives.get(1)), "floci-ca-bundle.p12", trustStore);
}
@Test
void aSpecThatDoesNotAskLeavesItsJvmsOnTheImagesTrustStore() throws Exception {
when(tlsConfig.enabled()).thenReturn(true);
writeBundle();
writeJavaTrustStore();
CreateContainerCmd createCmd = stubCreateContainer();
List<byte[]> archives = stubCopies();
manager().create(specWithEnv(List.of("FOO=bar")));
assertTrue(capturedEnv(createCmd).stream().noneMatch(entry -> entry.startsWith("JAVA_TOOL_OPTIONS")));
assertEquals(1, archives.size());
verify(dockerClient, never()).inspectImageCmd(anyString());
}
@Test
void withoutATrustStoreFromTheBootASpecAskingForOneGetsTheBundleAlone() throws Exception {
when(tlsConfig.enabled()).thenReturn(true);
writeBundle();
CreateContainerCmd createCmd = stubCreateContainer();
List<byte[]> archives = stubCopies();
manager().create(javaSpecWithEnv(List.of("FOO=bar")));
assertEquals(6, capturedEnv(createCmd).size());
assertEquals(1, archives.size());
verify(dockerClient, never()).inspectImageCmd(anyString());
}
@Test
void anImageWhoseEnvironmentCannotBeReadKeepsItsJvmsOnItsOwnTrustStore() throws Exception {
// Floci's JAVA_TOOL_OPTIONS would replace the image's, which it could not read to keep.
when(tlsConfig.enabled()).thenReturn(true);
writeBundle();
writeJavaTrustStore();
CreateContainerCmd createCmd = stubCreateContainer();
InspectImageCmd inspectCmd = mock(InspectImageCmd.class);
when(dockerClient.inspectImageCmd("busybox:stable")).thenReturn(inspectCmd);
when(inspectCmd.exec()).thenThrow(new NotFoundException("No such image"));
List<byte[]> archives = stubCopies();
manager().create(javaSpecWithEnv(List.of("FOO=bar")));
List<String> env = capturedEnv(createCmd);
assertEquals(6, env.size());
assertTrue(env.containsAll(ContainerCaBundle.env()));
assertEquals(1, archives.size());
}
@Test
void aTrustStoreThatCannotBeCopiedRecreatesTheContainerWithoutAnyTrustVariables() throws Exception {
// JAVA_TOOL_OPTIONS must never name a trust store that is not there: the JVM would trust nothing.
when(tlsConfig.enabled()).thenReturn(true);
writeBundle();
writeJavaTrustStore();
CreateContainerCmd createCmd = mock(CreateContainerCmd.class, RETURNS_SELF);
when(dockerClient.createContainerCmd("busybox:stable")).thenReturn(createCmd);
CreateContainerResponse first = mock(CreateContainerResponse.class);
when(first.getId()).thenReturn("container-id");
CreateContainerResponse second = mock(CreateContainerResponse.class);
when(second.getId()).thenReturn("container-id-2");
when(createCmd.exec()).thenReturn(first, second);
stubImageEnv();
CopyArchiveToContainerCmd copyCmd = mock(CopyArchiveToContainerCmd.class, RETURNS_SELF);
when(dockerClient.copyArchiveToContainerCmd("container-id")).thenReturn(copyCmd);
// The bundle goes in; its trust store does not.
when(copyCmd.exec()).thenAnswer(copied -> null)
.thenThrow(new NotFoundException("Could not find the file /etc"));
RemoveContainerCmd removeCmd = mock(RemoveContainerCmd.class, RETURNS_SELF);
when(dockerClient.removeContainerCmd("container-id")).thenReturn(removeCmd);
assertEquals("container-id-2", manager().create(javaSpecWithEnv(List.of("FOO=bar"))));
verify(removeCmd).exec();
@SuppressWarnings("unchecked")
ArgumentCaptor<List<String>> env = ArgumentCaptor.forClass((Class<List<String>>) (Class<?>) List.class);
verify(createCmd, times(2)).withEnv(env.capture());
assertEquals(7, env.getAllValues().get(0).size(), "the first attempt carried the trust variables");
assertEquals(List.of("FOO=bar"), env.getAllValues().get(1), "the retry carries only the spec's own");
verify(dockerClient, never()).copyArchiveToContainerCmd("container-id-2");
}
private Path writeBundle() throws Exception {
Path tlsDir = Files.createDirectories(tempDir.resolve("tls"));
return Files.writeString(tlsDir.resolve("floci-ca-bundle.pem"), BUNDLE_PEM);
}
private byte[] writeJavaTrustStore() throws Exception {
byte[] trustStore = {0x30, (byte) 0x82, 0x01, 0x02};
Files.write(Files.createDirectories(tempDir.resolve("tls")).resolve("floci-ca-bundle.p12"), trustStore);
return trustStore;
}
private void stubImageEnv(String... env) {
InspectImageCmd inspectCmd = mock(InspectImageCmd.class);
when(dockerClient.inspectImageCmd("busybox:stable")).thenReturn(inspectCmd);
InspectImageResponse image = mock(InspectImageResponse.class);
when(inspectCmd.exec()).thenReturn(image);
ContainerConfig imageConfig = mock(ContainerConfig.class);
when(image.getConfig()).thenReturn(imageConfig);
when(imageConfig.getEnv()).thenReturn(env);
}
// Every archive copied into "container-id", in the order they went in.
private List<byte[]> stubCopies() {
CopyArchiveToContainerCmd copyCmd = mock(CopyArchiveToContainerCmd.class, RETURNS_SELF);
when(dockerClient.copyArchiveToContainerCmd("container-id")).thenReturn(copyCmd);
List<InputStream> streams = new ArrayList<>();
when(copyCmd.withTarInputStream(any(InputStream.class))).thenAnswer(invocation -> {
streams.add(invocation.getArgument(0));
return copyCmd;
});
List<byte[]> archives = new ArrayList<>();
when(copyCmd.exec()).thenAnswer(invocation -> {
archives.add(streams.getLast().readAllBytes());
return null;
});
return archives;
}
private static void assertBundleArchive(InputStream stream) throws IOException {
assertSingleFileArchive(stream, "floci-ca-bundle.pem", BUNDLE_PEM.getBytes(StandardCharsets.UTF_8));
}
@@ -347,6 +486,13 @@ class ContainerLifecycleManagerCaBundleTest {
List.of(), List.of(), List.of(), Map.of(), null, false, null, List.of(), null, null, List.of());
}
// As ContainerBuilder.Builder.withJavaTrustStore() builds it.
private static ContainerSpec javaSpecWithEnv(List<String> env) {
return new ContainerSpec("busybox:stable", null, env, null, null, null, Map.of(), List.of(), List.of(), null,
List.of(), List.of(), List.of(), List.of(), Map.of(), null, false, null, List.of(), null, null,
List.of(), List.of(), null, null, false, List.of(), Map.of(), false, LinuxOptions.NONE, true);
}
private CreateContainerCmd stubCreateContainer() {
CreateContainerCmd createCmd = mock(CreateContainerCmd.class, RETURNS_SELF);
when(dockerClient.createContainerCmd("busybox:stable")).thenReturn(createCmd);
@@ -111,6 +111,8 @@ class BatchDockerRunnerTest {
"io.floci.resource-id", "job-1",
"io.floci.account", "000000000000",
"io.floci.region", "us-east-1"));
// A job's JVMs trust Floci's CA as well.
verify(builder).withJavaTrustStore();
}
@Test
@@ -127,6 +127,19 @@ class EcsContainerManagerAwsBaselineTest {
assertTrue(env.contains("APP_ONLY=1"));
}
@Test
void aTaskContainersJvmsTrustFlocisCa() {
TaskDefinition taskDef = new TaskDefinition();
taskDef.setFamily("test-family");
taskDef.setContainerDefinitions(List.of(containerDef("app", "app:latest", List.of())));
EcsTask task = new EcsTask();
task.setTaskArn("arn:aws:ecs:us-east-1:000000000000:task/test-cluster/abc123");
manager.startTask(task, taskDef, null, "us-east-1");
verify(builder).withJavaTrustStore();
}
@Test
void runTaskOverrideWinsOverBaseline() {
ContainerDefinition app = containerDef("app", "app:latest", List.of());
@@ -6,7 +6,6 @@ import com.github.dockerjava.api.exception.InternalServerErrorException;
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.api.model.StreamType;
import io.github.hectorvent.floci.config.ContainerCaBundle;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.docker.ContainerBuilder;
@@ -136,16 +135,16 @@ class EmrServerlessSparkRunnerTest {
runner(builder).run(job(Duration.ZERO), progress);
verify(builder).newContainer("public.ecr.aws/emr-serverless/spark/emr-7.5.0:latest");
// bash -c runs Floci's wrapper with "floci" as its $0 and spark-submit and its arguments as "$@".
verify(spec).withEntrypoint(List.of("/bin/bash", "-c",
ContainerCaBundle.JAVA_TRUST_SHELL_LINE + "\nexec \"$@\"", "floci"));
verify(spec).withCmd(argThat((List<String> cmd) -> "/usr/lib/spark/bin/spark-submit".equals(cmd.getFirst())
&& List.of("--master", "local[*]").equals(cmd.subList(1, 3))
verify(spec).withEntrypoint(List.of("/usr/lib/spark/bin/spark-submit"));
verify(spec).withCmd(argThat((List<String> cmd) -> List.of("--master", "local[*]").equals(cmd.subList(0, 2))
&& "s3://bucket/jobs/app.jar".equals(cmd.getLast())));
verify(spec).withName(ContainerStorageHelper.dockerName(config, "emr-serverless-00f0000000000001"));
verify(spec).withDockerNetwork(Optional.of("floci-network"));
verify(spec).withLabels(argThat(labels ->
"emr-serverless".equals(labels.get(ContainerStorageHelper.SERVICE_LABEL))));
// Its JVMs trust Floci's CA, the trust store going in with the CA bundle as the container is created.
verify(spec).withJavaTrustStore();
verify(lifecycle, never()).copyJavaTrustStore(anyString());
}
@Test
@@ -160,23 +159,14 @@ class EmrServerlessSparkRunnerTest {
// bash -c runs Floci's wrapper with "floci" as its $0 and the command as "$@".
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.size() == 4
&& entrypoint.subList(0, 2).equals(List.of("/bin/bash", "-c"))
&& entrypoint.get(2).startsWith(ContainerCaBundle.JAVA_TRUST_SHELL_LINE + "\n")
&& entrypoint.get(2).contains("export SPARK_CONF_DIR=") && entrypoint.get(2).endsWith("exec \"$@\"")
&& "floci".equals(entrypoint.get(3))));
verify(spec).withCmd(command);
verify(spec).withEnv(eq("FLOCI_SPARK_DEFAULTS"),
argThat(file -> file.startsWith("spark.master local[*]\n")
&& file.endsWith("\nspark.executor.cores 4")));
}
@Test
void theJavaTrustStoreGoesIntoTheDriversContainerBeforeItStarts() {
runner().run(job(Duration.ZERO), progress);
InOrder order = inOrder(lifecycle);
order.verify(lifecycle).create(any());
order.verify(lifecycle).copyJavaTrustStore("driver");
order.verify(lifecycle).startCreated(eq("driver"), any());
verify(spec, never()).withEntrypoint(List.of("/usr/lib/spark/bin/spark-submit"));
verify(spec).withJavaTrustStore();
}
@Test
@@ -287,13 +277,14 @@ class EmrServerlessSparkRunnerTest {
}
@Test
void aRunStoppedWhileTheTrustStoreIsCopiedNeverStartsItsDriver() {
void aRunStoppedWhileItsContainerIsCreatedNeverStartsItsDriver() {
EmrServerlessSparkRunner runner = runner();
SparkJobRunner.Job job = job(Duration.ZERO);
// The copy can wait on Docker, and a stop only marks the run.
when(lifecycle.copyJavaTrustStore("driver")).thenAnswer(copy -> {
// The create pulls the image and copies the trust store in, either of which can wait on Docker, and a
// stop only marks the run.
when(lifecycle.create(any())).thenAnswer(creating -> {
runner.stop(job.runId());
return true;
return "driver";
});
SparkJobRunner.Outcome outcome = runner.run(job, progress);
@@ -304,24 +295,6 @@ class EmrServerlessSparkRunnerTest {
verify(lifecycle).stopAndRemove("driver", null, 0);
}
@Test
void aRunCancelledWhileTheTrustStoreIsCopiedNeverStartsItsDriver() {
EmrServerlessSparkRunner runner = runner();
AtomicBoolean cancelled = new AtomicBoolean();
when(progress.cancelled()).thenAnswer(look -> cancelled.get());
when(lifecycle.copyJavaTrustStore("driver")).thenAnswer(copy -> {
cancelled.set(true);
return true;
});
SparkJobRunner.Outcome outcome = runner.run(job(Duration.ZERO), progress);
assertTrue(outcome.stopped());
verify(progress, never()).started();
verify(lifecycle, never()).startCreated(anyString(), any());
verify(lifecycle).stopAndRemove("driver", null, 0);
}
@Test
void aRunningDriverWhoseRunIsGoneIsStoppedAtTheNextLook() {
EmrServerlessSparkRunner runner = runner();
@@ -372,6 +372,9 @@ class FlinkContainerManagerTest {
"FLINK_PROPERTIES=jobmanager.rpc.address: localhost\ntaskmanager.numberOfTaskSlots: 3"));
assertEquals("container:jm-id", tmSpec.networkMode());
verify(awsEnv).sdkBaselineEnv("us-west-2", Optional.empty());
// Both JVMs trust Floci's CA, as the job's SDK clients need for Floci over HTTPS.
assertTrue(jmSpec.javaTrustStore());
assertTrue(tmSpec.javaTrustStore());
}
@Test
@@ -580,6 +580,31 @@ class ContainerLauncherTest {
spec.labels());
}
@ParameterizedTest
@CsvSource({"java21, true", "java8.al2, true", "java17, true", "nodejs20.x, false", "python3.13, false",
"provided.al2023, false"})
void launchFunction_hasTheJvmsOfAJavaRuntimeTrustFlocisCa(String runtime, boolean javaTrustStore)
throws Exception {
Path codePath = Files.createDirectory(tempDir.resolve("code"));
LambdaFunction fn = new LambdaFunction();
fn.setFunctionName("runtime-fn");
fn.setRuntime(runtime);
fn.setHandler("index.handler");
fn.setCodeLocalPath(codePath.toString());
launcher.launch(fn);
assertEquals(javaTrustStore, captureRealContainerSpec().javaTrustStore());
}
@Test
void launchFunction_hasTheJvmsOfAContainerImageTrustFlocisCa() {
launcher.launch(imageFunction());
assertTrue(captureRealContainerSpec().javaTrustStore());
}
@Test
void launchFunction_createsWithoutBindMountsOrVolume_forSmallCode() throws Exception {
Path codePath = Files.createDirectory(tempDir.resolve("code"));
@@ -27,6 +27,9 @@ public final class TestImages {
public static final String PYTHON_ALPINE = "python:3.12-alpine";
/** Corretto 8, the JVM of Lambda's oldest Java runtime, as a JDK so a test compiles its probe in the container. */
public static final String CORRETTO_8 = "amazoncorretto:8-alpine-jdk";
public static final String PGBOUNCER = "edoburu/pgbouncer:v1.24.0-p1";
/** The same image AWS publishes at {@code public.ecr.aws/aws-observability/aws-for-fluent-bit:3}. */