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 4a202bccfe ARTEMIS-4308 Allowing individual DatabasePagingTest tests,
also adding postgres to the list
4a202bccfe is described below
commit 4a202bccfe59699678cf0f4ec4c6db27bd827cd0
Author: Clebert Suconic <[email protected]>
AuthorDate: Mon Jun 12 17:56:36 2023 -0400
ARTEMIS-4308 Allowing individual DatabasePagingTest tests, also adding
postgres to the list
---
tests/soak-tests/pom.xml | 29 ++++++++++++-
.../tests/soak/paging/DatabasePagingTest.java | 50 +++++++++++++++++-----
...t-mysql-podman.sh => client-postgres-podman.sh} | 7 ++-
.../src/test/scripts/parameters-paging.sh | 10 ++---
tests/soak-tests/src/test/scripts/parameters.sh | 4 +-
.../src/test/scripts/start-mysql-podman.sh | 2 +-
...rt-mysql-podman.sh => start-postgres-podman.sh} | 4 +-
...art-mysql-podman.sh => stop-postgres-podman.sh} | 6 +--
8 files changed, 85 insertions(+), 27 deletions(-)
diff --git a/tests/soak-tests/pom.xml b/tests/soak-tests/pom.xml
index 7a28173bc7..39b6bcba92 100644
--- a/tests/soak-tests/pom.xml
+++ b/tests/soak-tests/pom.xml
@@ -562,7 +562,34 @@
</args>
</configuration>
</execution>
- </executions>
+ <execution>
+ <phase>test-compile</phase>
+ <id>create-database-paging-postgres</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/postgres</instance>
+
<configuration>${basedir}/target/classes/servers/database-paging/postgres</configuration>
+ <libListWithDeps>
+ <arg>org.postgresql:postgresql:42.6.0</arg>
+ </libListWithDeps>
+ <args>
+ <arg>--jdbc</arg>
+ <arg>--jdbc-connection-url</arg>
+
<arg>jdbc:postgresql:artemis?user=artemis&#38;password=artemis</arg>
+ <arg>--jdbc-driver-class-name</arg>
+ <arg>org.postgresql.Driver</arg>
+ <arg>--global-max-messages</arg>
+ <arg>100</arg>
+ <arg>--java-options</arg>
+ <arg>-ea</arg>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<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
index 80b3d6ae96..9d3678f0aa 100644
---
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
@@ -25,26 +25,33 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.tests.util.RandomUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static
org.apache.activemq.artemis.tests.soak.TestParameters.testProperty;
+@RunWith(Parameterized.class)
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"));
+ // you can use ./start-${database}-podman.sh scripts from
./src/test/scripts to start the databases.
+ // support values are derby, mysql and postgres
+ private static final String DB_LIST = testProperty(TEST_NAME, "DB_LIST",
"derby");
private static final int MAX_MESSAGES =
Integer.parseInt(testProperty(TEST_NAME, "MAX_MESSAGES", "200"));
@@ -52,15 +59,36 @@ public class DatabasePagingTest extends SoakTestBase {
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;
+ final String database;
+
+ final String serverName;
+
+ @Parameterized.Parameters(name = "protocol={0}")
+ public static Collection<Object[]> parameters() {
+ String[] protocols = DB_LIST.split(",");
+
+ ArrayList<Object[]> parameters = new ArrayList<>();
+ for (String str : protocols) {
+ logger.info("Adding {} to the list for the test", str);
+ parameters.add(new Object[]{str});
+ }
+
+ return parameters;
+ }
+
+ public DatabasePagingTest(String database) {
+ this.database = database;
+ serverName = "database-paging/" + database;
+ }
+
+
@Before
public void before() throws Exception {
- cleanupData(SERVER_NAME_0);
+ cleanupData(serverName);
- serverProcess = startServer(SERVER_NAME_0, 0, 60_000);
+ serverProcess = startServer(serverName, 0, 60_000);
}
@@ -72,7 +100,9 @@ public class DatabasePagingTest extends SoakTestBase {
}
public void testPaging(String protocol) throws Exception {
- logger.info("performing paging test on {}", protocol);
+ logger.info("performing paging test on protocol={} and db={}", protocol,
database);
+
+ final String queueName = "QUEUE_" + RandomUtil.randomString() + "_" +
protocol + "_" + database;
ConnectionFactory connectionFactory =
CFUtil.createConnectionFactory(protocol, "tcp://localhost:61616");
@@ -80,7 +110,7 @@ public class DatabasePagingTest extends SoakTestBase {
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);
+ Queue queue = session.createQueue(queueName);
MessageProducer producer = session.createProducer(queue);
for (int i = 0; i < MAX_MESSAGES; i++) {
BytesMessage message = session.createBytesMessage();
@@ -99,13 +129,13 @@ public class DatabasePagingTest extends SoakTestBase {
serverProcess.waitFor(1, TimeUnit.MINUTES);
Assert.assertFalse(serverProcess.isAlive());
- serverProcess = startServer(SERVER_NAME_0, 0, 60_000);
+ serverProcess = startServer(serverName, 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);
+ Queue queue = session.createQueue(queueName);
MessageConsumer consumer = session.createConsumer(queue);
for (int i = 0; i < MAX_MESSAGES; i++) {
BytesMessage message = (BytesMessage) consumer.receive(5000);
diff --git a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
b/tests/soak-tests/src/test/scripts/client-postgres-podman.sh
similarity index 75%
copy from tests/soak-tests/src/test/scripts/start-mysql-podman.sh
copy to tests/soak-tests/src/test/scripts/client-postgres-podman.sh
index 3020bd00b2..5c0a745e63 100755
--- a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
+++ b/tests/soak-tests/src/test/scripts/client-postgres-podman.sh
@@ -16,7 +16,6 @@
# 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
+# Start a command line mysql for the Database started with
./start-postgres-podman.sh
+podman exec -it postgres-artemis-test psql -U artemis artemis
+#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 67dec27e4a..e39b1225d2 100755
--- a/tests/soak-tests/src/test/scripts/parameters-paging.sh
+++ b/tests/soak-tests/src/test/scripts/parameters-paging.sh
@@ -16,14 +16,12 @@
# specific language governing permissions and limitations
# under the License.
-# this script contains a suggest set of variables to run the
HorizontalPagingTest in a medium environment and hit some issues we used to
have with paging
+# this script contains a suggest set of variables to run the soak tests.
## Generic variable:
-# It is possible to save the producer's time. If you set this variable the
test will reuse previously sent data by zip and unzipping the data folder
+# Some tests will support saving the producer's state before consumption. If
you set this variable these tests will hold a zip file and recover it
approprieatedly.
#export TEST_ZIP_LOCATION=~/zipTest/
-echo "parameters-paging has been deprecated, please use parameters.sh"
-
#HorizontalPagingTest
export TEST_HORIZONTAL_TEST_ENABLED=true
@@ -101,7 +99,9 @@ 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_DB_LIST=derby
+# use this to allow all the databases
+#export TEST_PGDB_DB_LIST=derby,postgres,mysql
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 3d95440c97..e39b1225d2 100755
--- a/tests/soak-tests/src/test/scripts/parameters.sh
+++ b/tests/soak-tests/src/test/scripts/parameters.sh
@@ -99,7 +99,9 @@ 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_DB_LIST=derby
+# use this to allow all the databases
+#export TEST_PGDB_DB_LIST=derby,postgres,mysql
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
index 3020bd00b2..28ad4157f7 100755
--- a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
+++ b/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
@@ -19,4 +19,4 @@
# 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
+podman run -d -p 3306:3306 --name mysql-artemis-test --rm -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/start-mysql-podman.sh
b/tests/soak-tests/src/test/scripts/start-postgres-podman.sh
similarity index 81%
copy from tests/soak-tests/src/test/scripts/start-mysql-podman.sh
copy to tests/soak-tests/src/test/scripts/start-postgres-podman.sh
index 3020bd00b2..b18d966423 100755
--- a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
+++ b/tests/soak-tests/src/test/scripts/start-postgres-podman.sh
@@ -18,5 +18,5 @@
# 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
+./stop-postgres-podman.sh
+podman run --name postgres-artemis-test --rm -d -e POSTGRES_USER=artemis -e
POSTGRES_PASSWORD=artemis -e POSTGRES_DB=artemis -p 5432:5432 -p 9876:80
postgres
diff --git a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
b/tests/soak-tests/src/test/scripts/stop-postgres-podman.sh
similarity index 75%
copy from tests/soak-tests/src/test/scripts/start-mysql-podman.sh
copy to tests/soak-tests/src/test/scripts/stop-postgres-podman.sh
index 3020bd00b2..298fbac33c 100755
--- a/tests/soak-tests/src/test/scripts/start-mysql-podman.sh
+++ b/tests/soak-tests/src/test/scripts/stop-postgres-podman.sh
@@ -16,7 +16,7 @@
# specific language governing permissions and limitations
# under the License.
-# This script shows a simple way to start a mysql with podman
+# This script shows a simple way to stop 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
+podman kill postgres-artemis-test
+podman rm postgres-artemis-test
\ No newline at end of file