ci: 백엔드 CI를 runner에서 초록으로 만들고 job 준비 비용을 줄인다 #13

Merged
donghyeon.kang merged 24 commits from claude/w2-be-ci-perf-e89fe7 into main 2026-11-12 09:43:42 +00:00
2 changed files with 35 additions and 7 deletions
Showing only changes of commit ecc1400486 - Show all commits
@@ -15,6 +15,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.MountableFile;
import software.amazon.awssdk.services.s3.S3AsyncClient;
@@ -53,7 +54,11 @@ class MinioS3ManagedObjectProviderContractTest extends ObjectStorageProviderCont
String secretKey = UUID.randomUUID().toString().replace("-", "") + UUID.randomUUID();
byte[] keyBytes = new byte[32];
SECURE_RANDOM.nextBytes(keyBytes);
Path certificates = SelfSignedServerCertificate.writeTo(Files.createTempDirectory("minio-tls"));
// The host the mapped port is published on: localhost on a workstation, the Docker daemon's
// address inside a CI job container. The certificate has to name it.
String containerHost = DockerClientFactory.instance().dockerHostIpAddress();
Path certificates =
SelfSignedServerCertificate.writeTo(Files.createTempDirectory("minio-tls"), containerHost);
trustStoreBefore = SelfSignedServerCertificate.trustForThisJvm(certificates);
minio =
new GenericContainer<>(QualificationImages.minio())
@@ -90,7 +95,12 @@ class MinioS3ManagedObjectProviderContractTest extends ObjectStorageProviderCont
.retryBaseDelay(Duration.ofMillis(10))
.retryMaximumBackoff(Duration.ofMillis(20))
.shutdownGrace(Duration.ofSeconds(2))
.endpointOverride(URI.create("https://localhost:" + minio.getMappedPort(9000)))
.endpointOverride(
URI.create(
"https://"
+ endpointHost(containerHost)
+ ":"
+ minio.getMappedPort(9000)))
.pathStyleAccess(true)
.staticCredentials(accessKey, secretKey)
.build());
@@ -138,4 +148,9 @@ class MinioS3ManagedObjectProviderContractTest extends ObjectStorageProviderCont
protected ObjectStorageProvider provider() {
return provider;
}
// An IPv6 literal needs brackets in a URI authority.
private static String endpointHost(String containerHost) {
return containerHost.contains(":") ? "[" + containerHost + "]" : containerHost;
}
}
@@ -11,10 +11,14 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* A throwaway localhost server certificate for one lane run, made with the running JDK's keytool so
* no key material is committed. MinIO reads {@code public.crt} and {@code private.key} (PKCS#8 PEM)
* from its certs directory; the JVM trusts the same certificate through its default trust store
* A throwaway server certificate for one lane run, made with the running JDK's keytool so no key
* material is committed. MinIO reads {@code public.crt} and {@code private.key} (PKCS#8 PEM) from
* its certs directory; the JVM trusts the same certificate through its default trust store
* properties, which the SDK's Netty client reads.
*
* <p>The certificate names localhost and the host the test reaches the container on. They differ
* when the tests run inside a CI job container: there the Docker daemon is another host, and {@code
* localhost} is the job container itself.
*/
final class SelfSignedServerCertificate {
@@ -23,7 +27,7 @@ final class SelfSignedServerCertificate {
private SelfSignedServerCertificate() {}
static Path writeTo(Path directory) throws Exception {
static Path writeTo(Path directory, String containerHost) throws Exception {
String password = password(directory);
Path keytool = Path.of(System.getProperty("java.home"), "bin", "keytool");
Process process =
@@ -44,7 +48,7 @@ final class SelfSignedServerCertificate {
"-dname",
"CN=localhost",
"-ext",
"SAN=dns:localhost,ip:127.0.0.1",
subjectAlternativeNames(containerHost),
"-storetype",
"PKCS12",
"-keystore",
@@ -74,6 +78,15 @@ final class SelfSignedServerCertificate {
return directory;
}
private static String subjectAlternativeNames(String containerHost) {
String names = "SAN=dns:localhost,ip:127.0.0.1";
if (containerHost.equals("localhost") || containerHost.equals("127.0.0.1")) {
return names;
}
boolean ipLiteral = containerHost.contains(":") || containerHost.matches("[0-9.]+");
return names + (ipLiteral ? ",ip:" : ",dns:") + containerHost;
}
/** Points the JVM default trust store at the certificate; the returned action restores it. */
static Runnable trustForThisJvm(Path directory) throws Exception {
String[] names = {