ARTEMIS-4308 Allowing individual DatabasePagingTest tests, also adding postgres to the list

This commit is contained in:
Clebert Suconic 2023-06-12 17:56:36 -04:00 committed by clebertsuconic
parent b61ec81656
commit 4a202bccfe
8 changed files with 142 additions and 18 deletions

View File

@ -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;#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>

View File

@ -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);

View File

@ -0,0 +1,21 @@
#!/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-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

View File

@ -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

View File

@ -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

View File

@ -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
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

View File

@ -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-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

View File

@ -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 postgres-artemis-test
podman rm postgres-artemis-test