mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test: fold the CUR and Lambda one-off profiles into shared ones (#4813)
FixedPortNoEmissionProfile pinned port 4566 so the floci-duck sidecar could reach Floci's S3, and turned the billing emitters off. Its two CUR classes move onto SidecarContainersProfile, which already keeps the port and floci.base-url in step (floci-duck takes its port from the base URL) and now also names both emitters as off, which is inert for the other classes. Both CUR classes are gated on FLOCI_DUCK_CROSS_CONTAINER_TEST, so on CI that profile was built on every run and never started. LambdaExternalLayerArnAcceptedIntegrationTest and LambdaHotReloadAllowListIntegrationTest each pinned a port, floci.port and the base URL, though neither starts a container. They now share LambdaCodeSourcesProfile, which carries only their two settings: foreign layer ARNs accepted, and the hot-reload allow-list. Each only changes the requests its own class makes. Part of #4542.
This commit is contained in:
1 parent
8fdf23d303
commit
e2f2f0f9d1
7 files changed
+46
-68
No files matched your search
+2
-2
@@ -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 {
|
||||
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
|
||||
+2
-14
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user