sijie commented on a change in pull request #2101: Migrate compaction and s3 
offload test to testcontainers
URL: https://github.com/apache/incubator-pulsar/pull/2101#discussion_r202238372
 
 

 ##########
 File path: 
tests/integration/s3-offload/src/test/java/org/apache/pulsar/tests/integration/TestS3Offload.java
 ##########
 @@ -33,58 +34,58 @@
 import org.apache.pulsar.client.api.Producer;
 import org.apache.pulsar.client.api.PulsarClient;
 
-import org.apache.pulsar.tests.DockerUtils;
-import org.apache.pulsar.tests.PulsarClusterUtils;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.arquillian.testng.Arquillian;
+import org.apache.pulsar.tests.containers.BrokerContainer;
+import org.apache.pulsar.tests.containers.S3Container;
+import org.apache.pulsar.tests.topologies.PulsarCluster;
+import org.apache.pulsar.tests.topologies.PulsarClusterSpec;
+import org.apache.pulsar.tests.topologies.PulsarClusterTestBase;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-public class TestS3Offload extends Arquillian {
-    private static final Logger log = 
LoggerFactory.getLogger(TestS3Offload.class);
+import static java.util.stream.Collectors.joining;
+
+@Slf4j
+public class TestS3Offload extends PulsarClusterTestBase {
 
-    private static final String CLUSTER_NAME = "test";
     private static final int ENTRY_SIZE = 1024;
     private static final int ENTRIES_PER_LEDGER = 1024;
 
-    @ArquillianResource
-    DockerClient docker;
-
-    @BeforeMethod
-    public void configureAndStartBrokers() throws Exception {
-
-        String s3ip = DockerUtils.cubeIdsWithLabels(
-                docker, ImmutableMap.of("service", "s3", "cluster", 
CLUSTER_NAME))
-            .stream().map((c) -> DockerUtils.getContainerIP(docker, 
c)).findFirst().get();
-
-        String brokerConfFile = "/pulsar/conf/broker.conf";
-        for (String b : PulsarClusterUtils.brokerSet(docker, CLUSTER_NAME)) {
-            PulsarClusterUtils.updateConf(docker, b, brokerConfFile,
-                    "managedLedgerMaxEntriesPerLedger", 
String.valueOf(ENTRIES_PER_LEDGER));
-            PulsarClusterUtils.updateConf(docker, b, brokerConfFile,
-                    "managedLedgerMinLedgerRolloverTimeMinutes", "0");
-            PulsarClusterUtils.updateConf(docker, b, brokerConfFile,
-                    "managedLedgerOffloadDriver", "s3");
-            PulsarClusterUtils.updateConf(docker, b, brokerConfFile,
-                    "s3ManagedLedgerOffloadBucket", "pulsar-integtest");
-            PulsarClusterUtils.updateConf(docker, b, brokerConfFile,
-                    "s3ManagedLedgerOffloadServiceEndpoint", "http://"; + s3ip 
+ ":9090");
+    @Override
+    @BeforeClass
+    public void setupCluster() throws Exception {
+        PulsarClusterSpec spec = PulsarClusterSpec.builder()
+            .numBookies(2)
+            .numBrokers(1)
+            .enableTieredStorage(true)
+            .clusterName(Stream.of(this.getClass().getSimpleName(), 
randomName(5))
+                .filter(s -> s != null && !s.isEmpty())
+                .collect(joining("-")))
+            .build();
+
+        log.info("Setting up cluster {} with {} bookies, {} brokers",
+                spec.clusterName(), spec.numBookies(), spec.numBrokers());
+
+        pulsarCluster = PulsarCluster.forSpec(spec);
+
+        for(BrokerContainer brokerContainer : pulsarCluster.getBrokers()){
+            brokerContainer.withEnv("managedLedgerMaxEntriesPerLedger", 
String.valueOf(ENTRIES_PER_LEDGER));
+            
brokerContainer.withEnv("managedLedgerMinLedgerRolloverTimeMinutes", "0");
+            brokerContainer.withEnv("managedLedgerOffloadDriver", "s3");
+            brokerContainer.withEnv("s3ManagedLedgerOffloadBucket", 
"pulsar-integtest");
+            brokerContainer.withEnv("s3ManagedLedgerOffloadServiceEndpoint", 
"http://"; + S3Container.NAME + ":9090");
         }
 
-        Assert.assertTrue(PulsarClusterUtils.startAllBrokers(docker, 
CLUSTER_NAME));
-        Assert.assertTrue(PulsarClusterUtils.startAllProxies(docker, 
CLUSTER_NAME));
-    }
-
-    @AfterMethod
-    public void teardownBrokers() throws Exception {
-        PulsarClusterUtils.stopAllProxies(docker, CLUSTER_NAME);
-        Assert.assertTrue(PulsarClusterUtils.stopAllBrokers(docker, 
CLUSTER_NAME));
+        Collection<BrokerContainer> brokers = pulsarCluster.getBrokers();
+        log.info(brokers.size() + " ");
 
 Review comment:
   - please give more meaningful logging
   - use `{}` rather than '+'

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to