Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

test: fold the CUR and Lambda one-off profiles into shared ones (#4813)

Priamo Germosene2f2f0f9d1a5
diff --git a/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java
index edb71c2908..153288144e 100644
--- a/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java
@@ -1,7 +1,7 @@
package io.github.hectorvent.floci.services.cur;
-import io.github.hectorvent.floci.testing.FixedPortNoEmissionProfile;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
+import io.github.hectorvent.floci.testing.SidecarContainersProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
@@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.equalTo;
* {@code NoSuchBucket}.
*/
@QuarkusTest
-@TestProfile(FixedPortNoEmissionProfile.class)
+@TestProfile(SidecarContainersProfile.class)
@EnabledIfEnvironmentVariable(named = "FLOCI_DUCK_CROSS_CONTAINER_TEST", matches = "1|true|yes")
class CurDailyEmissionAccountIsolationIntegrationTest {
diff --git a/src/test/java/io/github/hectorvent/floci/services/cur/ParquetEmitterIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cur/ParquetEmitterIntegrationTest.java
index 0eaff3dea6..236e3e4376 100644
--- a/src/test/java/io/github/hectorvent/floci/services/cur/ParquetEmitterIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/cur/ParquetEmitterIntegrationTest.java
@@ -3,7 +3,7 @@ package io.github.hectorvent.floci.services.cur;
import io.github.hectorvent.floci.core.common.UsageLine;
import io.github.hectorvent.floci.services.floci.duck.FlociDuckClient;
import io.github.hectorvent.floci.services.s3.S3Service;
-import io.github.hectorvent.floci.testing.FixedPortNoEmissionProfile;
+import io.github.hectorvent.floci.testing.SidecarContainersProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import jakarta.inject.Inject;
@@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* runner that adds the host alias).
*/
@QuarkusTest
-@TestProfile(FixedPortNoEmissionProfile.class)
+@TestProfile(SidecarContainersProfile.class)
@EnabledIfEnvironmentVariable(named = "FLOCI_DUCK_CROSS_CONTAINER_TEST", matches = "1|true|yes")
class ParquetEmitterIntegrationTest {
diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaExternalLayerArnAcceptedIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaExternalLayerArnAcceptedIntegrationTest.java
index c79c8c585b..491dac3dd0 100644
--- a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaExternalLayerArnAcceptedIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaExternalLayerArnAcceptedIntegrationTest.java
@@ -1,13 +1,12 @@
package io.github.hectorvent.floci.services.lambda;
+import io.github.hectorvent.floci.testing.LambdaCodeSourcesProfile;
import io.quarkus.test.junit.QuarkusTest;
-import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.util.Base64;
-import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -29,7 +28,7 @@ import static org.hamcrest.Matchers.hasSize;
* such an ARN invalid outright.
*/
@QuarkusTest
-@TestProfile(LambdaExternalLayerArnAcceptedIntegrationTest.AcceptExternalLayerArnsProfile.class)
+@TestProfile(LambdaCodeSourcesProfile.class)
class LambdaExternalLayerArnAcceptedIntegrationTest {
private static final String POWERTOOLS_ARN =
@@ -143,15 +142,4 @@ class LambdaExternalLayerArnAcceptedIntegrationTest {
.statusCode(400)
.body("__type", equalTo("InvalidParameterValueException"));
}
-
- public static final class AcceptExternalLayerArnsProfile implements QuarkusTestProfile {
- @Override
- public Map<String, String> getConfigOverrides() {
- return Map.of(
- "floci.services.lambda.accept-external-layer-arns", "true",
- "quarkus.http.test-port", "4588",
- "floci.port", "4588",
- "floci.base-url", "http://localhost:4588");
- }
- }
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaHotReloadAllowListIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaHotReloadAllowListIntegrationTest.java
index 804b1537b4..f54a35a58a 100644
--- a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaHotReloadAllowListIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaHotReloadAllowListIntegrationTest.java
@@ -1,14 +1,12 @@
package io.github.hectorvent.floci.services.lambda;
+import io.github.hectorvent.floci.testing.LambdaCodeSourcesProfile;
import io.quarkus.test.junit.QuarkusTest;
-import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.response.ValidatableResponse;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
-import java.util.Map;
-
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@@ -17,7 +15,7 @@ import static org.hamcrest.Matchers.equalTo;
* {@code ..}, or that merely shares its prefix, must be refused over the wire.
*/
@QuarkusTest
-@TestProfile(LambdaHotReloadAllowListIntegrationTest.HotReloadAllowListProfile.class)
+@TestProfile(LambdaCodeSourcesProfile.class)
class LambdaHotReloadAllowListIntegrationTest {
private static int counter;
@@ -58,15 +56,4 @@ class LambdaHotReloadAllowListIntegrationTest {
void createFunctionAcceptsTheAllowedDirectoryAndItsChildren(String s3Key) {
createFunction(s3Key).statusCode(201);
}
-
- public static final class HotReloadAllowListProfile implements QuarkusTestProfile {
- @Override
- public Map<String, String> getConfigOverrides() {
- return Map.of(
- "floci.services.lambda.hot-reload.allowed-paths", "/home/ci/code",
- "quarkus.http.test-port", "4589",
- "floci.port", "4589",
- "floci.base-url", "http://localhost:4589");
- }
- }
}
diff --git a/src/test/java/io/github/hectorvent/floci/testing/FixedPortNoEmissionProfile.java b/src/test/java/io/github/hectorvent/floci/testing/FixedPortNoEmissionProfile.java
deleted file mode 100644
index 417ace0ef8..0000000000
--- a/src/test/java/io/github/hectorvent/floci/testing/FixedPortNoEmissionProfile.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.github.hectorvent.floci.testing;
-
-import io.quarkus.test.junit.QuarkusTestProfile;
-
-import java.util.Map;
-
-/**
- * Pins the Floci HTTP port so the DuckDB sidecar can reach Floci S3 over the network, and names
- * both billing emitters as off so a report is only written when the test drives the emitter
- * itself. {@code CurEmissionScheduler} acts only on {@code daily} and {@code synchronous}, so
- * every other value leaves the emitters idle; the configured test default already resolves to one
- * of those inert values, and spelling it out here keeps the assumption visible.
- *
- * <p>Quarkus builds the application once per distinct profile class, so the classes that need this
- * share one profile rather than each declaring their own.
- */
-public class FixedPortNoEmissionProfile implements QuarkusTestProfile {
-
- @Override
- public Map<String, String> getConfigOverrides() {
- return Map.of(
- "quarkus.http.test-port", "4566",
- "floci.base-url", "http://localhost:4566",
- "floci.services.cur.emit-mode", "off",
- "floci.services.bcm-data-exports.emit-mode", "off");
- }
-}
diff --git a/src/test/java/io/github/hectorvent/floci/testing/LambdaCodeSourcesProfile.java b/src/test/java/io/github/hectorvent/floci/testing/LambdaCodeSourcesProfile.java
new file mode 100644
index 0000000000..43755d425b
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/testing/LambdaCodeSourcesProfile.java
@@ -0,0 +1,22 @@
+package io.github.hectorvent.floci.testing;
+
+import io.quarkus.test.junit.QuarkusTestProfile;
+
+import java.util.Map;
+
+/**
+ * Sets where a Lambda function's code may come from, for the classes that test it: foreign-account
+ * layer ARNs are accepted (recorded verbatim, never mounted), and hot-reload mounts are limited to
+ * an allow-list under {@code /home/ci/code}. Each setting only changes the requests its own class
+ * makes, so the two classes share this profile, and Quarkus builds one application for both
+ * rather than one each.
+ */
+public class LambdaCodeSourcesProfile implements QuarkusTestProfile {
+
+ @Override
+ public Map<String, String> getConfigOverrides() {
+ return Map.of(
+ "floci.services.lambda.accept-external-layer-arns", "true",
+ "floci.services.lambda.hot-reload.allowed-paths", "/home/ci/code");
+ }
+}
diff --git a/src/test/java/io/github/hectorvent/floci/testing/SidecarContainersProfile.java b/src/test/java/io/github/hectorvent/floci/testing/SidecarContainersProfile.java
index a4b703b187..7c1c8a9c5e 100644
--- a/src/test/java/io/github/hectorvent/floci/testing/SidecarContainersProfile.java
+++ b/src/test/java/io/github/hectorvent/floci/testing/SidecarContainersProfile.java
@@ -18,9 +18,9 @@ import java.util.Map;
/**
* Shared by every integration test that runs a real sidecar container, started by its manager
* exactly as in production: the AppSync GraphQL sidecar, the CodeArtifact Reposilite and Verdaccio
- * sidecars, and the Verified Permissions Cedar sidecar. Quarkus builds the application once per
- * distinct profile class, so these classes share one application rather than each paying for
- * their own.
+ * sidecars, the Verified Permissions Cedar sidecar, and the floci-duck sidecar behind the CUR
+ * Parquet emitter. Quarkus builds the application once per distinct profile class, so these
+ * classes share one application rather than each paying for their own.
*
* <p>Namespaces the containers as {@code floci-aws-sidecar-test-<hostkey>-<pid>-<sidecar>}. Each
* manager removes any container of its name before starting one, and the test config uses the same
@@ -36,10 +36,16 @@ import java.util.Map;
* is built from the base URL's port, which in production is the port Floci listens on. Under
* {@code @QuarkusTest} the application listens on the test port instead, so without this the
* sidecar would call back to 4566 and every resolver-backed field would fail with a connection
- * error. The port is a free one chosen once when the class loads, rather than a fixed number, so
- * two runs on the same machine do not collide on it. It is released before Quarkus binds it, so
- * another process can still take it in between; the application then fails to start rather than
- * sharing anything with that process.
+ * error, and floci-duck would reach for Floci's S3 on the wrong port. The port is a free one
+ * chosen once when the class loads, rather than a fixed number, so two runs on the same machine do
+ * not collide on it. It is released before Quarkus binds it, so another process can still take it
+ * in between; the application then fails to start rather than sharing anything with that process.
+ *
+ * <p>Names both billing emitters as off, so a CUR or BCM report is only written when a test drives
+ * the emitter itself. {@code CurEmissionScheduler} acts only on {@code daily} and
+ * {@code synchronous}, so every other value leaves the emitters idle; the configured test default
+ * already resolves to one of those inert values, and spelling it out here keeps the assumption
+ * visible for the CUR classes that rely on it.
*/
public class SidecarContainersProfile implements QuarkusTestProfile {
@@ -58,7 +64,9 @@ public class SidecarContainersProfile implements QuarkusTestProfile {
return Map.of(
"floci.docker.resource-namespace", NAMESPACE,
"quarkus.http.test-port", String.valueOf(TEST_PORT),
- "floci.base-url", "http://localhost:" + TEST_PORT);
+ "floci.base-url", "http://localhost:" + TEST_PORT,
+ "floci.services.cur.emit-mode", "off",
+ "floci.services.bcm-data-exports.emit-mode", "off");
}
/**