From 6be05b9cbe976acb9c1af507e59f344dd1fb2a5d Mon Sep 17 00:00:00 2001
From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
Date: Tue, 20 Oct 2026 18:17:35 -0400
Subject: [PATCH] test: share two persistent-storage profiles across six test
classes (#6079)
Slice 2 of #4542.
Six classes each declared a profile that put some storage on disk in a
directory of their own. They now share two:
PersistentStorageProfile puts every service on persistent storage in
one directory, for the Athena, CloudFormation and Glue classes that
read their service's file back. Each deletes and reads only its own
file, and is the only class in the group that calls its service.
PerServicePersistentStorageProfile leaves the test default, memory, in
place and puts only DynamoDB, ACM and S3 on disk, for the StorageFactory
duplicate backend test, the StorageFactory per-service mode test and
the CloudFront S3 disk origin test. The two StorageFactory profiles
also restated floci.storage.mode=memory, which the test
application.yml already sets, so that is dropped.
The profiles' javadoc lists each override, the class that relies on
it, and why it is inert for the others. Each class gains a javadoc
paragraph saying what it gets from them.
Since the classes now share an application, each deletes what it
creates: the Athena class its workgroups, the CloudFormation class its
stack and with it the bucket, waiting for the deletion to finish, the
Glue class its configurations, including the one it left in a second
account, and the CloudFront class its distribution as well as its
bucket. The per-service mode test builds its ACM store on a factory of
its own, so the application never holds it, and deletes its file
afterwards. The duplicate backend test writes placeholder strings into
DynamoDB's table store, and now clears them after the test as well as
before.
Two classes passed without the setting they test. The per-service mode
test asserted that StorageFactory returns an AccountAwareStorageBackend,
which it does in every mode since #753 wrapped every backend in one; it
now checks that an ACM store written to reaches disk. The CloudFront
test serves the same bytes whether S3 keeps the object in memory or in
a file; it now checks that the object is a file before fetching it
through the distribution.
---
.../StorageFactoryDuplicateBackendTest.java | 31 ++++++-----
...eFactoryServiceCatalogIntegrationTest.java | 54 ++++++++++++-------
...teWorkGroupPersistenceIntegrationTest.java | 43 +++++++++++----
...udFormationPersistenceIntegrationTest.java | 37 ++++++++-----
.../CloudFrontS3DiskOriginServingTest.java | 53 +++++++++++++-----
...eSecurityConfigurationIntegrationTest.java | 43 ++++++++++-----
.../PerServicePersistentStorageProfile.java | 49 +++++++++++++++++
.../testing/PersistentStorageProfile.java | 43 +++++++++++++++
8 files changed, 271 insertions(+), 82 deletions(-)
create mode 100644 src/test/java/io/github/hectorvent/floci/testing/PerServicePersistentStorageProfile.java
create mode 100644 src/test/java/io/github/hectorvent/floci/testing/PersistentStorageProfile.java
diff --git a/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryDuplicateBackendTest.java b/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryDuplicateBackendTest.java
index ea55e886e0..a53cde729a 100644
--- a/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryDuplicateBackendTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryDuplicateBackendTest.java
@@ -1,10 +1,11 @@
package io.github.hectorvent.floci.core.storage;
import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.testing.PerServicePersistentStorageProfile;
import io.quarkus.test.junit.QuarkusTest;
-import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -13,18 +14,22 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
+import static io.github.hectorvent.floci.testing.PerServicePersistentStorageProfile.STORAGE_DIR;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Reproduces issue #1921: two components request the same storage file, the factory hands out
* two independent backends, and on graceful shutdown the stale duplicate flushes last and
* clobbers the persisted state written by the active instance.
+ *
+ *
DynamoDB on persistent storage comes from {@link PerServicePersistentStorageProfile}, which
+ * this class shares with other classes that each call a different service. The placeholder
+ * entries it writes go into DynamoDB's table store, so it clears them again after the test.
*/
@QuarkusTest
-@TestProfile(StorageFactoryDuplicateBackendTest.PersistentProfile.class)
+@TestProfile(PerServicePersistentStorageProfile.class)
class StorageFactoryDuplicateBackendTest {
- private static final String STORAGE_PATH = "/tmp/floci-dedupe-backend-test";
private static final String FILE_NAME = "dynamodb-tables.json";
@Inject
@@ -36,7 +41,12 @@ class StorageFactoryDuplicateBackendTest {
// exist and hold in-memory state from app startup. Clear all backends (wipes memory + disk),
// then remove the file so both create() calls below start from an empty store.
storageFactory.clearAll();
- Files.deleteIfExists(Path.of(STORAGE_PATH, FILE_NAME));
+ Files.deleteIfExists(Path.of(STORAGE_DIR, FILE_NAME));
+ }
+
+ @AfterEach
+ void clearPlaceholders() throws IOException {
+ reset();
}
@Test
@@ -59,21 +69,10 @@ class StorageFactoryDuplicateBackendTest {
// Read the persisted file back with an independent reader.
PersistentStorage reader =
- new PersistentStorage<>(Path.of(STORAGE_PATH, FILE_NAME), typeRef);
+ new PersistentStorage<>(Path.of(STORAGE_DIR, FILE_NAME), typeRef);
reader.load();
assertEquals(60, reader.keys().size(),
"persisted table definitions should survive flushAll despite the duplicate backend");
}
-
- public static final class PersistentProfile implements QuarkusTestProfile {
- @Override
- public Map getConfigOverrides() {
- return Map.of(
- "floci.storage.mode", "memory",
- "floci.storage.services.dynamodb.mode", "persistent",
- "floci.storage.persistent-path", STORAGE_PATH
- );
- }
- }
}
diff --git a/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryServiceCatalogIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryServiceCatalogIntegrationTest.java
index ee6d06406b..9c1c6ebcd6 100644
--- a/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryServiceCatalogIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/storage/StorageFactoryServiceCatalogIntegrationTest.java
@@ -1,43 +1,61 @@
package io.github.hectorvent.floci.core.storage;
import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.config.EmulatorConfig;
+import io.github.hectorvent.floci.core.common.ServiceConfigAccess;
+import io.github.hectorvent.floci.testing.PerServicePersistentStorageProfile;
import io.quarkus.test.junit.QuarkusTest;
-import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Map;
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static io.github.hectorvent.floci.testing.PerServicePersistentStorageProfile.STORAGE_DIR;
import static org.junit.jupiter.api.Assertions.assertTrue;
+/**
+ * A per-service storage mode takes effect: with the test default, memory, for storage as a whole
+ * and ACM's own mode set to persistent, an ACM store writes through to its file.
+ *
+ * The ACM override comes from {@link PerServicePersistentStorageProfile}, which also puts
+ * DynamoDB and S3 on disk for the other classes on it. This class creates only the ACM store, so
+ * those two never reach it. It creates that store on a factory of its own, built from the
+ * application's configuration, so the application never holds it and no later flush of the
+ * application's stores writes the file back after the test deletes it.
+ */
@QuarkusTest
-@TestProfile(StorageFactoryServiceCatalogIntegrationTest.AcmPersistentStorageProfile.class)
+@TestProfile(PerServicePersistentStorageProfile.class)
class StorageFactoryServiceCatalogIntegrationTest {
+ private static final String FILE_NAME = "acm-test.json";
+
@Inject
- StorageFactory storageFactory;
+ EmulatorConfig config;
+
+ @Inject
+ ServiceConfigAccess serviceConfigAccess;
@Test
- void acmStorageOverrideIsApplied() {
- StorageBackend backend = storageFactory.create(
+ void acmStorageOverrideIsApplied() throws IOException {
+ Path file = Path.of(STORAGE_DIR, FILE_NAME);
+ Files.deleteIfExists(file);
+ StorageFactory factory = new StorageFactory(config, serviceConfigAccess);
+ StorageBackend backend = factory.create(
"acm",
- "acm-test.json",
+ FILE_NAME,
new TypeReference