reschke commented on code in PR #1143:
URL: https://github.com/apache/jackrabbit-oak/pull/1143#discussion_r1352093896


##########
oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzuriteDockerRule.java:
##########
@@ -16,55 +16,88 @@
  */
 package org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage;
 
-import com.arakelian.docker.junit.DockerRule;
-import com.arakelian.docker.junit.model.ImmutableDockerConfig;
 import com.microsoft.azure.storage.CloudStorageAccount;
 import com.microsoft.azure.storage.StorageException;
 import com.microsoft.azure.storage.blob.CloudBlobClient;
 import com.microsoft.azure.storage.blob.CloudBlobContainer;
-import com.spotify.docker.client.DefaultDockerClient;
-import com.spotify.docker.client.auth.FixedRegistryAuthSupplier;
-import java.net.URISyntaxException;
-import java.security.InvalidKeyException;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.jetbrains.annotations.NotNull;
 import org.junit.Assume;
-import org.junit.rules.TestRule;
+import org.junit.rules.ExternalResource;
 import org.junit.runner.Description;
+import org.junit.runners.model.MultipleFailureException;
 import org.junit.runners.model.Statement;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.utility.DockerImageName;
 
-public class AzuriteDockerRule implements TestRule {
+import java.net.URISyntaxException;
+import java.security.InvalidKeyException;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
 
-    private static final String IMAGE = 
"mcr.microsoft.com/azure-storage/azurite:3.19.0";
+public class AzuriteDockerRule extends ExternalResource {
 
+    private static final DockerImageName DOCKER_IMAGE_NAME = 
DockerImageName.parse("mcr.microsoft.com/azure-storage/azurite:3.19.0");
     public static final String ACCOUNT_KEY = 
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
     public static final String ACCOUNT_NAME = "devstoreaccount1";
+    private static final AtomicReference<Exception> STARTUP_EXCEPTION = new 
AtomicReference<>();
 
-    private static final String CONTAINER_SUFFIX = 
UUID.randomUUID().toString().substring(0, 8);
+    private GenericContainer<?> azuriteContainer;
 
-    private final DockerRule wrappedRule;
+    @Override
+    protected void before() throws Throwable {
+        azuriteContainer = new GenericContainer<>(DOCKER_IMAGE_NAME)
+                .withExposedPorts(10000)
+                .withEnv(Map.of("executable", "blob"))
+                .withStartupTimeout(Duration.ofSeconds(30));
 
-    private static final AtomicReference<Exception> STARTUP_EXCEPTION = new 
AtomicReference<>();
+        try {
+            azuriteContainer.start();
+        } catch (IllegalStateException e) {
+            STARTUP_EXCEPTION.set(e);
+            throw e;
+        }
+    }
 
-    public AzuriteDockerRule() {
-        wrappedRule = new DockerRule(ImmutableDockerConfig.builder()
-            .image(IMAGE)
-            .name("oak-test-azurite-" + CONTAINER_SUFFIX)
-            .ports("10000")
-            .addStartedListener(container -> {
+    @Override
+    protected void after() {
+        if (azuriteContainer != null) {
+            azuriteContainer.stop();
+        }
+    }
+
+    @Override
+    public Statement apply(Statement base, Description description) {

Review Comment:
   Please avoid moving around methods when not needed.



##########
oak-blob-cloud-azure/pom.xml:
##########
@@ -191,10 +191,10 @@
             <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
-
         <dependency>
-            <groupId>com.arakelian</groupId>
-            <artifactId>docker-junit-rule</artifactId>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <version>${testcontainers.version}</version>

Review Comment:
   Why do we need the bersion property?



##########
oak-lucene/pom.xml:
##########
@@ -471,5 +471,11 @@
       <version>1.19.0</version>
       <scope>test</scope>
     </dependency>
+    <dependency>

Review Comment:
   It seems we're adding unneeded dependencies here...



##########
oak-segment-azure/src/test/resources/logback-test.xml:
##########
@@ -21,11 +21,19 @@
             <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level 
%logger{36} - %msg%n</pattern>
         </encoder>
     </appender>
-    <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
+    <statusListener class="ch.qos.logback.core.status.NopStatusListener"/>

Review Comment:
   Is this related to switching to testcontainers?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to