Skip to content

Commit 53c591c

Browse files
authored
Move docker image to registry to address flaky test (#129660) (#131393)
* Instead of creating a new Docker image on-the-fly, it is better to create a persistent image and upload it to Docker Registry. This will help tests dependent on this image be resilient to transient issues such as #126694 and also speed up execution. * fix name (cherry picked from commit 22390d7)
1 parent df00e82 commit 53c591c

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

x-pack/test/smb-fixture/src/main/java/org/elasticsearch/test/fixtures/smb/SmbTestContainer.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,18 @@
1212
import org.elasticsearch.test.fixtures.testcontainers.DockerEnvironmentAwareTestContainer;
1313
import org.testcontainers.containers.wait.strategy.Wait;
1414
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
15-
import org.testcontainers.images.builder.ImageFromDockerfile;
15+
import org.testcontainers.images.RemoteDockerImage;
1616

1717
import java.time.Duration;
1818

1919
public final class SmbTestContainer extends DockerEnvironmentAwareTestContainer {
2020

21-
private static final String DOCKER_BASE_IMAGE = "ubuntu:24.04";
21+
private static final String DOCKER_BASE_IMAGE = "docker.elastic.co/elasticsearch-dev/es-smb-fixture:1.0";
2222
public static final int AD_LDAP_PORT = 636;
2323
public static final int AD_LDAP_GC_PORT = 3269;
2424

2525
public SmbTestContainer() {
26-
super(
27-
new ImageFromDockerfile("es-smb-fixture").withDockerfileFromBuilder(
28-
builder -> builder.from(DOCKER_BASE_IMAGE)
29-
.env("TZ", "Etc/UTC")
30-
.run("DEBIAN_FRONTEND=noninteractive apt-get update -qqy && apt-get install -qqy tzdata winbind samba ldap-utils")
31-
.copy("fixture/provision/installsmb.sh", "/fixture/provision/installsmb.sh")
32-
.copy("fixture/certs/ca.key", "/fixture/certs/ca.key")
33-
.copy("fixture/certs/ca.pem", "/fixture/certs/ca.pem")
34-
.copy("fixture/certs/cert.pem", "/fixture/certs/cert.pem")
35-
.copy("fixture/certs/key.pem", "/fixture/certs/key.pem")
36-
.run("chmod +x /fixture/provision/installsmb.sh")
37-
.cmd("/fixture/provision/installsmb.sh && service samba-ad-dc restart && echo Samba started && sleep infinity")
38-
.build()
39-
)
40-
.withFileFromClasspath("fixture/provision/installsmb.sh", "/smb/provision/installsmb.sh")
41-
.withFileFromClasspath("fixture/certs/ca.key", "/smb/certs/ca.key")
42-
.withFileFromClasspath("fixture/certs/ca.pem", "/smb/certs/ca.pem")
43-
.withFileFromClasspath("fixture/certs/cert.pem", "/smb/certs/cert.pem")
44-
.withFileFromClasspath("fixture/certs/key.pem", "/smb/certs/key.pem")
45-
);
26+
super(new RemoteDockerImage(DOCKER_BASE_IMAGE));
4627

4728
addExposedPort(AD_LDAP_PORT);
4829
addExposedPort(AD_LDAP_GC_PORT);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ubuntu:24.04
2+
3+
ENV TZ="Etc/UTC"
4+
5+
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qqy && \
6+
apt-get install -qqy tzdata winbind samba ldap-utils
7+
8+
COPY smb/provision/installsmb.sh /fixture/provision/installsmb.sh
9+
COPY smb/certs/ca.key /fixture/certs/ca.key
10+
COPY smb/certs/ca.pem /fixture/certs/ca.pem
11+
COPY smb/certs/cert.pem /fixture/certs/cert.pem
12+
COPY smb/certs/key.pem /fixture/certs/key.pem
13+
14+
RUN chmod +x /fixture/provision/installsmb.sh
15+
16+
CMD ["/bin/sh", "-c", "/fixture/provision/installsmb.sh && service samba-ad-dc restart && echo Samba started && sleep infinity"]

0 commit comments

Comments
 (0)