mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test: run the EKS auto mode classes nightly and wait for a PgBouncer login (#9423)
EksAutoModeBlockStorageDockerIntegrationTest and EksAutoModeNlbDockerIntegrationTest each start a k3s node, so they become DockerNightlyIntegrationTest classes behind the nightly.checks.enabled guard, and a change under services/eks/ still runs them through the nightly selection. RdsPgBouncerDockerNightlyIntegrationTest waited for the pooler's port with a socket probe, which Docker publishes before PgBouncer listens, so the wait now completes a JDBC login and SELECT 1 for up to 30 seconds.
This commit is contained in:
1 parent
354e5b9ea9
commit
0f5d2c8886
3 files changed
+20
-15
No files matched your search
+5
-3
@@ -16,6 +16,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
@@ -31,9 +32,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(RdsMockProfile.class)
|
||||
class EksAutoModeBlockStorageDockerIntegrationTest {
|
||||
@EnabledIfSystemProperty(named = "nightly.checks.enabled", matches = "true")
|
||||
class EksAutoModeBlockStorageDockerNightlyIntegrationTest {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(EksAutoModeBlockStorageDockerIntegrationTest.class);
|
||||
private static final Logger LOG = Logger.getLogger(EksAutoModeBlockStorageDockerNightlyIntegrationTest.class);
|
||||
private static final String ACCOUNT = "000000000000";
|
||||
private static final String PROVISIONER = "floci-auto-mode-ebs-provisioner";
|
||||
|
||||
@@ -49,7 +51,7 @@ class EksAutoModeBlockStorageDockerIntegrationTest {
|
||||
void requireDocker() {
|
||||
boolean dockerAvailable = DockerAvailability.answers(dockerClient);
|
||||
if (!dockerAvailable) {
|
||||
LOG.warn("Docker daemon is not available; skipping EksAutoModeBlockStorageDockerIntegrationTest");
|
||||
LOG.warn("Docker daemon is not available; skipping EksAutoModeBlockStorageDockerNightlyIntegrationTest");
|
||||
}
|
||||
Assumptions.assumeTrue(dockerAvailable, "Docker daemon must be available for the Auto Mode block storage test");
|
||||
}
|
||||
+5
-3
@@ -22,6 +22,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
@@ -41,9 +42,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(RdsMockProfile.class)
|
||||
class EksAutoModeNlbDockerIntegrationTest {
|
||||
@EnabledIfSystemProperty(named = "nightly.checks.enabled", matches = "true")
|
||||
class EksAutoModeNlbDockerNightlyIntegrationTest {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(EksAutoModeNlbDockerIntegrationTest.class);
|
||||
private static final Logger LOG = Logger.getLogger(EksAutoModeNlbDockerNightlyIntegrationTest.class);
|
||||
private static final String ACCOUNT = "000000000000";
|
||||
private static final String REGION = "us-east-1";
|
||||
|
||||
@@ -68,7 +70,7 @@ class EksAutoModeNlbDockerIntegrationTest {
|
||||
void requireDocker() {
|
||||
boolean dockerAvailable = DockerAvailability.answers(dockerClient);
|
||||
if (!dockerAvailable) {
|
||||
LOG.warn("Docker daemon is not available; skipping EksAutoModeNlbDockerIntegrationTest");
|
||||
LOG.warn("Docker daemon is not available; skipping EksAutoModeNlbDockerNightlyIntegrationTest");
|
||||
}
|
||||
Assumptions.assumeTrue(dockerAvailable, "Docker daemon must be available for the Auto Mode NLB test");
|
||||
}
|
||||
+10
-9
@@ -17,12 +17,10 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.Duration;
|
||||
import java.util.HashSet;
|
||||
@@ -106,7 +104,8 @@ class RdsPgBouncerDockerNightlyIntegrationTest {
|
||||
pooler = lifecycle.createAndStart(spec);
|
||||
poolerLogs = logs.attachConsoleOnly(pooler.containerId(), "pgbouncer:" + suffix);
|
||||
EndpointInfo endpoint = pooler.getEndpoint(5432);
|
||||
await().atMost(Duration.ofSeconds(10)).until(() -> listening(endpoint));
|
||||
// Docker publishes the port before PgBouncer listens, so only a completed login means it is ready.
|
||||
await().atMost(Duration.ofSeconds(30)).until(() -> acceptsLogin(endpoint));
|
||||
|
||||
// server_lifetime=0 closes a pooled server after each client; distinct backend PIDs
|
||||
// prove that every iteration authenticates again rather than reusing a warm session.
|
||||
@@ -145,11 +144,13 @@ class RdsPgBouncerDockerNightlyIntegrationTest {
|
||||
return "jdbc:postgresql://" + host + ":" + port + "/appdb";
|
||||
}
|
||||
|
||||
private static boolean listening(EndpointInfo endpoint) {
|
||||
try (Socket socket = new Socket()) {
|
||||
socket.connect(new InetSocketAddress(endpoint.host(), endpoint.port()), 200);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
private static boolean acceptsLogin(EndpointInfo endpoint) {
|
||||
try (Connection connection = DriverManager.getConnection(jdbcUrl(endpoint.host(), endpoint.port()),
|
||||
credentials("app_user", "Application123!"));
|
||||
Statement statement = connection.createStatement()) {
|
||||
return statement.execute("SELECT 1");
|
||||
} catch (SQLException expected) {
|
||||
// Refused or reset while PgBouncer starts, or a login it cannot pass on yet: poll again.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user