This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new b61ec81656 ARTEMIS-4308 Adding Soak tests for Paging and JDBC
b61ec81656 is described below

commit b61ec816565251fcb312f842366be4f1b3d7b9a7
Author: Clebert Suconic <clebertsuco...@apache.org>
AuthorDate: Fri Jun 9 08:59:05 2023 -0400

    ARTEMIS-4308 Adding Soak tests for Paging and JDBC
    
    I am also allowing optionally testing with mysql.
    The CLI maven plugin is creating a server and downloading the JDBC jar 
directly into the ./server/lib folder.
    Notice this is a test dependency only and it will be used only if mysql is 
set to true.
---
 tests/soak-tests/pom.xml                           |  50 +++++++++
 .../tests/soak/paging/DatabasePagingTest.java      | 122 +++++++++++++++++++++
 .../src/test/scripts/client-mysql-podman.sh        |  20 ++++
 .../src/test/scripts/parameters-paging.sh          |   6 +
 tests/soak-tests/src/test/scripts/parameters.sh    |   6 +
 .../src/test/scripts/start-mysql-podman.sh         |  22 ++++
 .../src/test/scripts/stop-mysql-podman.sh          |  22 ++++
 7 files changed, 248 insertions(+)

diff --git a/tests/soak-tests/pom.xml b/tests/soak-tests/pom.xml
index ace4bbcf1c..7a28173bc7 100644
--- a/tests/soak-tests/pom.xml
+++ b/tests/soak-tests/pom.xml
@@ -512,6 +512,56 @@
                      </args>
                   </configuration>
                </execution>
+               <execution>
+                  <phase>test-compile</phase>
+                  <id>create-database-paging</id>
+                  <goals>
+                     <goal>create</goal>
+                  </goals>
+                  <configuration>
+                     <!-- this makes it easier in certain envs -->
+                     <javaOptions>-Djava.net.preferIPv4Stack=true</javaOptions>
+                     
<instance>${basedir}/target/database-paging/derby</instance>
+                     
<configuration>${basedir}/target/classes/servers/database-paging/derby</configuration>
+                     <libList>
+                        
<arg>org.apache.derby:derby:${apache.derby.version}</arg>
+                     </libList>
+                     <args>
+                        <arg>--jdbc</arg>
+                        <arg>--global-max-messages</arg>
+                        <arg>100</arg>
+                        <arg>--java-options</arg>
+                        <arg>-ea</arg>
+                     </args>
+                  </configuration>
+               </execution>
+               <execution>
+                  <phase>test-compile</phase>
+                  <id>create-database-paging-mysql</id>
+                  <goals>
+                     <goal>create</goal>
+                  </goals>
+                  <configuration>
+                     <!-- this makes it easier in certain envs -->
+                     <javaOptions>-Djava.net.preferIPv4Stack=true</javaOptions>
+                     
<instance>${basedir}/target/database-paging/mysql</instance>
+                     
<configuration>${basedir}/target/classes/servers/database-paging/mysql</configuration>
+                     <libListWithDeps>
+                        <arg>com.mysql:mysql-connector-j:8.0.33</arg>
+                     </libListWithDeps>
+                     <args>
+                        <arg>--jdbc</arg>
+                        <arg>--jdbc-connection-url</arg>
+                        
<arg>jdbc:mysql://localhost/ARTEMIS-TEST?user=root&#38;#38;password=artemis</arg>
+                        <arg>--jdbc-driver-class-name</arg>
+                        <arg>com.mysql.cj.jdbc.Driver</arg>
+                        <arg>--global-max-messages</arg>
+                        <arg>100</arg>
+                        <arg>--java-options</arg>
+                        <arg>-ea</arg>
+                     </args>
+                  </configuration>
+               </execution>
             </executions>
          </plugin>
 
diff --git 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/DatabasePagingTest.java
 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/DatabasePagingTest.java
new file mode 100644
index 0000000000..80b3d6ae96
--- /dev/null
+++ 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/DatabasePagingTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.activemq.artemis.tests.soak.paging;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.lang.invoke.MethodHandles;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.tests.soak.SoakTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static 
org.apache.activemq.artemis.tests.soak.TestParameters.testProperty;
+
+public class DatabasePagingTest extends SoakTestBase {
+
+   private static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+   private static final String TEST_NAME = "PGDB";
+
+   // if you set this property to true, you can use the 
./start-mysql-podman.sh from ./src/test/scripts
+   private static final boolean USE_MYSQL = 
Boolean.parseBoolean(testProperty(TEST_NAME, "USE_MYSQL", "false"));
+
+   private static final int MAX_MESSAGES = 
Integer.parseInt(testProperty(TEST_NAME, "MAX_MESSAGES", "200"));
+
+   private static final int MESSAGE_SIZE = 
Integer.parseInt(testProperty(TEST_NAME, "MESSAGE_SIZE", "200"));
+
+   private static final int COMMIT_INTERVAL = 
Integer.parseInt(testProperty(TEST_NAME, "COMMIT_INTERVAL", "100"));
+
+   public static final String SERVER_NAME_0 = "database-paging/" + (USE_MYSQL 
? "mysql" : "derby");
+
+   Process serverProcess;
+
+   @Before
+   public void before() throws Exception {
+      cleanupData(SERVER_NAME_0);
+
+      serverProcess = startServer(SERVER_NAME_0, 0, 60_000);
+   }
+
+
+   @Test
+   public void testPaging() throws Exception {
+      testPaging("CORE");
+      testPaging("AMQP");
+      testPaging("OPENWIRE");
+   }
+
+   public void testPaging(String protocol) throws Exception {
+      logger.info("performing paging test on {}", protocol);
+
+      ConnectionFactory connectionFactory = 
CFUtil.createConnectionFactory(protocol, "tcp://localhost:61616");
+
+
+      try (Connection connection = connectionFactory.createConnection()) {
+         byte[] messageLoad = new byte[MESSAGE_SIZE];
+         Session session = connection.createSession(true, 
Session.SESSION_TRANSACTED);
+         Queue queue = session.createQueue("MY_QUEUE" + protocol);
+         MessageProducer producer = session.createProducer(queue);
+         for (int i = 0; i < MAX_MESSAGES; i++) {
+            BytesMessage message = session.createBytesMessage();
+            message.writeBytes(messageLoad);
+            message.setIntProperty("i", i);
+            producer.send(message);
+            if (i % COMMIT_INTERVAL == 0) {
+               session.commit();
+            }
+         }
+         session.commit();
+
+      }
+
+      serverProcess.destroyForcibly();
+      serverProcess.waitFor(1, TimeUnit.MINUTES);
+      Assert.assertFalse(serverProcess.isAlive());
+
+      serverProcess = startServer(SERVER_NAME_0, 0, 60_000);
+
+
+      try (Connection connection = connectionFactory.createConnection()) {
+         connection.start();
+         Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+         Queue queue = session.createQueue("MY_QUEUE" + protocol);
+         MessageConsumer consumer = session.createConsumer(queue);
+         for (int i = 0; i < MAX_MESSAGES; i++) {
+            BytesMessage message = (BytesMessage) consumer.receive(5000);
+            Assert.assertNotNull(message);
+            Assert.assertEquals(i, message.getIntProperty("i"));
+            Assert.assertEquals(MESSAGE_SIZE, message.getBodyLength());
+         }
+         Assert.assertNull(consumer.receiveNoWait());
+      }
+
+
+   }
+
+}
diff --git a/tests/soak-tests/src/test/scripts/client-mysql-podman.sh 
b/tests/soak-tests/src/test/scripts/client-mysql-podman.sh
new file mode 100755
index 0000000000..bd37ee2455
--- /dev/null
+++ b/tests/soak-tests/src/test/scripts/client-mysql-podman.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# 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.
+
+# Start a command line mysql for the Database started with 
./start-mysql-podman.sh
+podman exec -it mysql-artemis-test mysql ARTEMIS-TEST -u root 
--password=artemis
diff --git a/tests/soak-tests/src/test/scripts/parameters-paging.sh 
b/tests/soak-tests/src/test/scripts/parameters-paging.sh
index 09d64f3d99..67dec27e4a 100755
--- a/tests/soak-tests/src/test/scripts/parameters-paging.sh
+++ b/tests/soak-tests/src/test/scripts/parameters-paging.sh
@@ -99,3 +99,9 @@ export TEST_OW_LEAK_OPENWIRE_NUMBER_OF_MESSAGES=15
 export TEST_OW_LEAK_OPENWIRE_PRODUCERS=1
 export TEST_OW_LEAK_OPENWIRE_MESSAGE_SIZE=2000000
 export TEST_OW_LEAK_PRINT_INTERVAL=1
+
+#DatabasePagingTest
+export TEST_PGDB_USE_MYSQL=false
+export TEST_PGDB_MAX_MESSAGES=500
+export TEST_PGDB_MESSAGE_SIZE=100
+export TEST_PGDB_COMMIT_INTERVAL=50
diff --git a/tests/soak-tests/src/test/scripts/parameters.sh 
b/tests/soak-tests/src/test/scripts/parameters.sh
index 7f74595853..3d95440c97 100755
--- a/tests/soak-tests/src/test/scripts/parameters.sh
+++ b/tests/soak-tests/src/test/scripts/parameters.sh
@@ -97,3 +97,9 @@ export TEST_OW_LEAK_OPENWIRE_NUMBER_OF_MESSAGES=15
 export TEST_OW_LEAK_OPENWIRE_PRODUCERS=1
 export TEST_OW_LEAK_OPENWIRE_MESSAGE_SIZE=2000000
 export TEST_OW_LEAK_PRINT_INTERVAL=1
+
+#DatabasePagingTest
+export TEST_PGDB_USE_MYSQL=false
+export TEST_PGDB_MAX_MESSAGES=500
+export TEST_PGDB_MESSAGE_SIZE=100
+export TEST_PGDB_COMMIT_INTERVAL=50
diff --git a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh 
b/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
new file mode 100755
index 0000000000..3020bd00b2
--- /dev/null
+++ b/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# 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.
+
+# This script shows a simple way to start a mysql with podman
+
+./stop-mysql-podman.sh
+podman run -d -p 3306:3306 --name mysql-artemis-test -e 
MYSQL_ROOT_PASSWORD=artemis -e MYSQL_USER=artemis -e MYSQL_PASSWORD=artemis -e 
MYSQL_DATABASE=ARTEMIS-TEST mysql:8
\ No newline at end of file
diff --git a/tests/soak-tests/src/test/scripts/stop-mysql-podman.sh 
b/tests/soak-tests/src/test/scripts/stop-mysql-podman.sh
new file mode 100755
index 0000000000..e23a1159b8
--- /dev/null
+++ b/tests/soak-tests/src/test/scripts/stop-mysql-podman.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# 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.
+
+# This script shows a simple way to stop a mysql with podman
+
+podman kill mysql-artemis-test
+podman rm mysql-artemis-test
\ No newline at end of file

Reply via email to