Optimize build and fix fragile tests (#3068)

This commit dramatically optimizes the local Gradle build time, shaving over 5 minutes off a full build execution:
- Instrumented the build to identify fragileTest taking > 3 minutes.
- Refactored TestServer.java to dynamically bind to ephemeral port 0, resolving race conditions.
- Updated UploadBsaUnavailableDomainsActionTest to use the thread-safe TestServer, allowing it to run in parallel.
- Removed outdated exclusions for HostInfoFlowTest and RegistryPipelineWorkerInitializerTest.
- Moved these tests to the highly parallelized standardTest suite.
- Removed the redundant sqlIntegrationTest execution from the standard test phase.
- Stripped heavy Docker (buildNomulusImage) and 5x frontend (buildConsoleForAll) staging dependencies from the standard build task, ensuring they are only run when explicitly deployed.
This commit is contained in:
Ben McIlwain
2026-05-29 02:29:20 +00:00
committed by GitHub
parent cd65a4c9d8
commit 5286b1a0dc
5 changed files with 29 additions and 46 deletions
@@ -23,7 +23,6 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.NetworkUtils.pickUnusedPort;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.mockito.Mockito.times;
@@ -168,7 +167,7 @@ public class UploadBsaUnavailableDomainsActionTest {
private TestServer startTestServer() throws Exception {
TestServer testServer =
new TestServer(
HostAndPort.fromParts(InetAddress.getLocalHost().getHostAddress(), pickUnusedPort()),
HostAndPort.fromParts(InetAddress.getLocalHost().getHostAddress(), 0),
ImmutableMap.of(),
ImmutableList.of(Route.route("/upload", Servlet.class)));
testServer.start();
@@ -31,6 +31,8 @@ import jakarta.servlet.annotation.MultipartConfig;
import jakarta.servlet.http.HttpServlet;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -138,30 +140,39 @@ public final class TestServer {
.callWithTimeout(
() -> {
server.stop();
RegistryEnvironment.setIsInTestDriver(false);
return null;
},
SHUTDOWN_TIMEOUT_MS,
TimeUnit.MILLISECONDS);
for (var dir : multiPartTmpDirs) {
try {
Files.delete(dir);
} catch (Exception e) {
// Ignore
}
}
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
} finally {
RegistryEnvironment.setIsInTestDriver(false);
}
for (var dir : multiPartTmpDirs) {
try {
Files.delete(dir);
} catch (IOException e) {
// Nothing we can do
}
}
}
public int getPort() {
return ((ServerConnector) server.getConnectors()[0]).getLocalPort();
}
/** Returns a URL that can be used to communicate with this server. */
public URL getUrl(String path) {
checkArgument(path.startsWith("/"), "Path must start with a slash: %s", path);
try {
return new URL(String.format("http://%s%s", urlAddress, path));
} catch (MalformedURLException e) {
int port = getPort();
if (port <= 0) {
port = urlAddress.getPortOrDefault(DEFAULT_PORT);
}
return new URI(String.format("http://%s:%d%s", urlAddress.getHost(), port, path)).toURL();
} catch (MalformedURLException | URISyntaxException e) {
throw new RuntimeException(e);
}
}