77
88package org .elasticsearch .test .fixtures .smb ;
99
10+ import com .github .dockerjava .api .model .Capability ;
11+
1012import org .elasticsearch .test .fixtures .testcontainers .DockerEnvironmentAwareTestContainer ;
13+ import org .testcontainers .containers .wait .strategy .Wait ;
14+ import org .testcontainers .containers .wait .strategy .WaitAllStrategy ;
1115import org .testcontainers .images .builder .ImageFromDockerfile ;
1216
17+ import java .time .Duration ;
18+
1319public final class SmbTestContainer extends DockerEnvironmentAwareTestContainer {
1420
15- private static final String DOCKER_BASE_IMAGE = "ubuntu:16 .04" ;
21+ private static final String DOCKER_BASE_IMAGE = "ubuntu:24 .04" ;
1622 public static final int AD_LDAP_PORT = 636 ;
1723 public static final int AD_LDAP_GC_PORT = 3269 ;
1824
1925 public SmbTestContainer () {
2026 super (
2127 new ImageFromDockerfile ("es-smb-fixture" ).withDockerfileFromBuilder (
2228 builder -> builder .from (DOCKER_BASE_IMAGE )
23- .run ("apt-get update -qqy && apt-get install -qqy samba ldap-utils" )
29+ .env ("TZ" , "Etc/UTC" )
30+ .run ("DEBIAN_FRONTEND=noninteractive apt-get update -qqy && apt-get install -qqy tzdata winbind samba ldap-utils" )
2431 .copy ("fixture/provision/installsmb.sh" , "/fixture/provision/installsmb.sh" )
2532 .copy ("fixture/certs/ca.key" , "/fixture/certs/ca.key" )
2633 .copy ("fixture/certs/ca.pem" , "/fixture/certs/ca.pem" )
2734 .copy ("fixture/certs/cert.pem" , "/fixture/certs/cert.pem" )
2835 .copy ("fixture/certs/key.pem" , "/fixture/certs/key.pem" )
2936 .run ("chmod +x /fixture/provision/installsmb.sh" )
30- .run ("/fixture/provision/installsmb.sh" )
31- .cmd ("service samba-ad-dc restart && sleep infinity" )
37+ .cmd ("/fixture/provision/installsmb.sh && service samba-ad-dc restart && echo Samba started && sleep infinity" )
3238 .build ()
3339 )
3440 .withFileFromClasspath ("fixture/provision/installsmb.sh" , "/smb/provision/installsmb.sh" )
@@ -37,10 +43,20 @@ public SmbTestContainer() {
3743 .withFileFromClasspath ("fixture/certs/cert.pem" , "/smb/certs/cert.pem" )
3844 .withFileFromClasspath ("fixture/certs/key.pem" , "/smb/certs/key.pem" )
3945 );
40- // addExposedPort(389);
41- // addExposedPort(3268);
46+
4247 addExposedPort (AD_LDAP_PORT );
4348 addExposedPort (AD_LDAP_GC_PORT );
49+
50+ setWaitStrategy (
51+ new WaitAllStrategy ().withStartupTimeout (Duration .ofSeconds (120 ))
52+ .withStrategy (Wait .forLogMessage (".*Samba started.*" , 1 ))
53+ .withStrategy (Wait .forListeningPort ())
54+ );
55+
56+ getCreateContainerCmdModifiers ().add (createContainerCmd -> {
57+ createContainerCmd .getHostConfig ().withCapAdd (Capability .SYS_ADMIN );
58+ return createContainerCmd ;
59+ });
4460 }
4561
4662 public String getAdLdapUrl () {
0 commit comments