johnjcasey commented on code in PR #31543:
URL: https://github.com/apache/beam/pull/31543#discussion_r1664422179


##########
sdks/java/io/solace/src/test/java/org/apache/beam/sdk/io/solace/it/SolaceContainerManager.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.solace.it;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.solace.Service;
+import org.testcontainers.solace.SolaceContainer;
+import org.testcontainers.utility.DockerImageName;
+
+public class SolaceContainerManager {
+
+  public static final String VPN_NAME = "default";
+  public static final String PASSWORD = "password";
+  public static final String USERNAME = "username";
+  public static final String TOPIC_NAME = "test_topic";
+  private static final Logger LOG = 
LoggerFactory.getLogger(SolaceContainerManager.class);
+  private final SolaceContainer container;
+
+  public SolaceContainerManager() {
+    this.container =
+        new 
SolaceContainer(DockerImageName.parse("solace/solace-pubsub-standard:10.7")) {
+          {
+            addFixedExposedPort(55555, 55555);
+            addFixedExposedPort(9000, 9000);
+            addFixedExposedPort(8080, 8080);
+            addFixedExposedPort(80, 80);
+          }
+        }.withVpn(VPN_NAME)
+            .withCredentials(USERNAME, PASSWORD)
+            // .withExposedPorts(Service.SMF.getPort());
+            .withTopic(TOPIC_NAME, Service.SMF)
+            .withLogConsumer(new Slf4jLogConsumer(LOG));
+    container.addExposedPort(8080);
+    container.addExposedPort(55555);
+  }
+
+  public void start() {
+    container.start();
+  }
+
+  void createQueueWithSubscriptionTopic(String queueName) {
+    executeCommand(
+        "curl",
+        "http://localhost:8080/SEMP/v2/config/msgVpns/"; + VPN_NAME + 
"/topicEndpoints",
+        "-X",
+        "POST",
+        "-u",
+        "admin:admin",
+        "-H",
+        "Content-Type:application/json",
+        "-d",
+        "{\"topicEndpointName\":\""
+            + TOPIC_NAME
+            + 
"\",\"accessType\":\"exclusive\",\"permission\":\"modify-topic\",\"ingressEnabled\":true,\"egressEnabled\":true}");
+    executeCommand(
+        "curl",
+        "http://localhost:8080/SEMP/v2/config/msgVpns/"; + VPN_NAME + "/queues",
+        "-X",
+        "POST",
+        "-u",
+        "admin:admin",
+        "-H",
+        "Content-Type:application/json",
+        "-d",
+        "{\"queueName\":\""
+            + queueName
+            + 
"\",\"accessType\":\"non-exclusive\",\"maxMsgSpoolUsage\":200,\"permission\":\"consume\",\"ingressEnabled\":true,\"egressEnabled\":true}");
+    executeCommand(
+        "curl",
+        "http://localhost:8080/SEMP/v2/config/msgVpns/";
+            + VPN_NAME
+            + "/queues/"
+            + queueName
+            + "/subscriptions",
+        "-X",
+        "POST",
+        "-u",
+        "admin:admin",
+        "-H",
+        "Content-Type:application/json",
+        "-d",
+        "{\"subscriptionTopic\":\"" + TOPIC_NAME + "\"}");
+  }
+
+  private void executeCommand(String... command) {
+    try {
+      org.testcontainers.containers.Container.ExecResult execResult =

Review Comment:
   Can this be imported normally?



##########
sdks/java/io/solace/src/test/java/org/apache/beam/sdk/io/solace/it/SolaceIOIT.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.solace.it;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.beam.sdk.PipelineResult;
+import org.apache.beam.sdk.io.solace.SolaceIO;
+import 
org.apache.beam.sdk.io.solace.broker.BasicAuthJcsmpSessionServiceFactory;
+import org.apache.beam.sdk.io.solace.broker.BasicAuthSempClientFactory;
+import org.apache.beam.sdk.io.solace.data.Solace.Queue;
+import org.apache.beam.sdk.metrics.Counter;
+import org.apache.beam.sdk.metrics.Metrics;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
+import org.apache.beam.sdk.options.StreamingOptions;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.testing.TestPipelineOptions;
+import org.apache.beam.sdk.testutils.metrics.MetricsReader;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.ParDo;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
+import org.joda.time.Duration;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class SolaceIOIT {
+  private static final String NAMESPACE = SolaceIOIT.class.getName();
+  private static final String READ_COUNT = "read_count";
+  private static SolaceContainerManager solaceContainerManager;
+  private static final TestPipelineOptions readPipelineOptions;
+
+  static {
+    readPipelineOptions = 
PipelineOptionsFactory.create().as(TestPipelineOptions.class);
+    readPipelineOptions.setBlockOnRun(false);
+    readPipelineOptions.as(TestPipelineOptions.class).setBlockOnRun(false);
+    readPipelineOptions.as(StreamingOptions.class).setStreaming(false);
+  }
+
+  @Rule public final TestPipeline readPipeline = 
TestPipeline.fromOptions(readPipelineOptions);
+
+  @BeforeClass
+  public static void setup() {
+    solaceContainerManager = new SolaceContainerManager();
+    solaceContainerManager.start();
+  }
+
+  @AfterClass
+  public static void afterClass() {
+    if (solaceContainerManager != null) {
+      solaceContainerManager.stop();
+    }
+  }
+
+  @Test
+  public void testRead() {
+    String queueName = "test_queue";
+    solaceContainerManager.createQueueWithSubscriptionTopic(queueName);
+
+    // todo this is very slow, needs to be replaced with the SolaceIO.write 
connector.

Review Comment:
   Why is this slow? if its because of syncronous work, you could spin up a 
parallel thread pool



-- 
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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to