ARTEMIS-3371 Adding TestContainers support and adding QpidDispatchPeerTest

This is testing peer integration with qpid-dispatch by using TestContainer and a docker image for Artemis
Also, as I added QpidDispatchTest, I reorganized the brokerConnect tests a bit into a brokerConnect folder.
This commit is contained in:
Clebert Suconic 2021-06-29 13:58:48 -04:00 committed by clebertsuconic
parent 2585ef3e7b
commit 200e436931
21 changed files with 1072 additions and 14 deletions

View File

@ -246,6 +246,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
getLog().debug("***** Server created at " + instance + " with home=" + home + " *****"); getLog().debug("***** Server created at " + instance + " with home=" + home + " *****");
instance.mkdirs();
File commandLine = new File(instance.getParentFile(), "create-" + instance.getName() + ".sh"); File commandLine = new File(instance.getParentFile(), "create-" + instance.getName() + ".sh");
FileOutputStream outputStream; FileOutputStream outputStream;
try { try {

View File

@ -147,10 +147,16 @@
<version>3.14.0</version> <version>3.14.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.15.3</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>selenium</artifactId> <artifactId>selenium</artifactId>
<version>1.15.1</version> <version>1.15.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- this dependency is needed for CFUtil and other tools from integration-tests --> <!-- this dependency is needed for CFUtil and other tools from integration-tests -->
@ -717,8 +723,8 @@
<user>A</user> <user>A</user>
<password>A</password> <password>A</password>
<noWeb>true</noWeb> <noWeb>true</noWeb>
<instance>${basedir}/target/brokerConnectBridgeSecurityA</instance> <instance>${basedir}/target/brokerConnect/bridgeSecurityA</instance>
<configuration>${basedir}/target/classes/servers/brokerConnectBridgeSecurityA</configuration> <configuration>${basedir}/target/classes/servers/brokerConnect/bridgeSecurityA</configuration>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
@ -733,8 +739,8 @@
<password>B</password> <password>B</password>
<noWeb>true</noWeb> <noWeb>true</noWeb>
<portOffset>100</portOffset> <portOffset>100</portOffset>
<instance>${basedir}/target/brokerConnectBridgeSecurityB</instance> <instance>${basedir}/target/brokerConnect/bridgeSecurityB</instance>
<configuration>${basedir}/target/classes/servers/brokerConnectBridgeSecurityB</configuration> <configuration>${basedir}/target/classes/servers/brokerConnect/bridgeSecurityB</configuration>
</configuration> </configuration>
</execution> </execution>
<!-- used on BrokerConnectionBridgeSecurityTest --> <!-- used on BrokerConnectionBridgeSecurityTest -->
@ -749,8 +755,8 @@
<user>A</user> <user>A</user>
<password>A</password> <password>A</password>
<noWeb>true</noWeb> <noWeb>true</noWeb>
<instance>${basedir}/target/brokerConnectMirrorSecurityA</instance> <instance>${basedir}/target/brokerConnect/mirrorSecurityA</instance>
<configuration>${basedir}/target/classes/servers/brokerConnectMirrorSecurityA</configuration> <configuration>${basedir}/target/classes/servers/brokerConnect/mirrorSecurityA</configuration>
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
@ -765,8 +771,8 @@
<password>B</password> <password>B</password>
<noWeb>true</noWeb> <noWeb>true</noWeb>
<portOffset>1</portOffset> <portOffset>1</portOffset>
<instance>${basedir}/target/brokerConnectMirrorSecurityB</instance> <instance>${basedir}/target/brokerConnect/mirrorSecurityB</instance>
<configuration>${basedir}/target/classes/servers/brokerConnectMirrorSecurityB</configuration> <configuration>${basedir}/target/classes/servers/brokerConnect/mirrorSecurityB</configuration>
</configuration> </configuration>
</execution> </execution>
@ -826,6 +832,22 @@
</args> </args>
</configuration> </configuration>
</execution> </execution>
<execution>
<phase>test-compile</phase>
<id>create-qdr</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<role>amq</role>
<user>artemis</user>
<password>artemis</password>
<allowAnonymous>false</allowAnonymous>
<noWeb>false</noWeb>
<instance>${basedir}/target/brokerConnect/qdr</instance>
<configuration>${basedir}/target/classes/servers/brokerConnect/qdr</configuration>
</configuration>
</execution>
</executions> </executions>
<dependencies> <dependencies>
<dependency> <dependency>

View File

@ -0,0 +1,24 @@
# 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 directory contains files supporting reusing a broker image inside a DockerImage.
The method ContainerService::prepareInstance will copy files from this directory into a broker's home instance
to allow it being used inside a docker image generated by ./artemis-docker.
*******************************************************************************************************************************

View File

@ -0,0 +1,136 @@
#!/usr/bin/env 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.
if [ -z "$ARTEMIS_INSTANCE" ] ; then
## resolve links - $0 may be a link to ActiveMQ's home
PRG="$0"
progname=`basename "$0"`
saveddir=`pwd`
# need this for relative symlinks
dirname_prg=`dirname "$PRG"`
cd "$dirname_prg"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
ARTEMIS_INSTANCE=`dirname "$PRG"`
cd "$saveddir"
# make it fully qualified
ARTEMIS_INSTANCE=`cd "$ARTEMIS_INSTANCE/.." && pwd`
fi
# Load Profile Data
ARTEMIS_INSTANCE_ETC='/var/lib/artemis-instance/etc'
. "$ARTEMIS_INSTANCE_ETC/artemis.profile"
# Set Defaults Properties
ARTEMIS_LOGGING_CONF="$ARTEMIS_INSTANCE_ETC_URI/logging.properties"
ARTEMIS_LOG_MANAGER=org.jboss.logmanager.LogManager
CLASSPATH="$ARTEMIS_HOME/lib/artemis-boot.jar"
# OS specific support.
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*) cygwin=true
OSTYPE=cygwin
export OSTYPE
;;
Darwin*) darwin=true
if [ -z "$JAVA_HOME" ] ; then
JAVA_HOME=$(/usr/libexec/java_home)
fi
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$ARTEMIS_INSTANCE" ] &&
ARTEMIS_INSTANCE=`cygpath --unix "$ARTEMIS_INSTANCE"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD=java
fi
fi
if $cygwin ; then
JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
ARTEMIS_HOME=`cygpath --windows "$ARTEMIS_HOME"`
CLASSPATH=`cygpath --windows "$CLASSPATH"`
fi
# finding the Log Manager
LOG_MANAGER=`ls $ARTEMIS_HOME/lib/jboss-logmanager*jar 2>/dev/null`
if [ -z "$LOG_MANAGER" ] ; then
# this is the one found when the server was created
LOG_MANAGER="$ARTEMIS_HOME/lib/jboss-logmanager-2.1.10.Final.jar"
fi
WILDFLY_COMMON=`ls $ARTEMIS_HOME/lib/wildfly-common*jar 2>/dev/null`
if [ -z "$WILDFLY_COMMON" ] ; then
# this is the one found when the server was created
WILDFLY_COMMON="$ARTEMIS_HOME/lib/wildfly-common-1.5.2.Final.jar"
fi
if [ -f "$ARTEMIS_OOME_DUMP" ] ; then
# backup the last OOME heap dump
mv $ARTEMIS_OOME_DUMP $ARTEMIS_OOME_DUMP.bkp
fi
exec "$JAVACMD" \
$JAVA_ARGS \
-Dhawtio.role="$HAWTIO_ROLE" \
-Xbootclasspath/a:"$LOG_MANAGER:$WILDFLY_COMMON" \
-Djava.security.auth.login.config="$ARTEMIS_INSTANCE_ETC/login.config" \
$ARTEMIS_CLUSTER_PROPS \
-classpath "$CLASSPATH" \
-Dartemis.home="$ARTEMIS_HOME" \
-Dartemis.instance="$ARTEMIS_INSTANCE" \
-Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-$(uname -m)" \
-Djava.io.tmpdir="$ARTEMIS_INSTANCE/tmp" \
-Ddata.dir="$ARTEMIS_DATA_DIR" \
-Dartemis.instance.etc="$ARTEMIS_INSTANCE_ETC" \
-Djava.util.logging.manager="$ARTEMIS_LOG_MANAGER" \
-Dlogging.configuration="$ARTEMIS_LOGGING_CONF" \
$DEBUG_ARGS \
org.apache.activemq.artemis.boot.Artemis "$@"

View File

@ -0,0 +1,38 @@
# 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 is to replace the artemis.profile on an instance meant to be used as part of a docker image.
ARTEMIS_HOME='/opt/activemq-artemis'
ARTEMIS_INSTANCE='/var/lib/artemis-instance'
ARTEMIS_DATA_DIR='/var/lib/artemis-instance/data'
ARTEMIS_ETC_DIR='/var/lib/artemis-instance/etc'
ARTEMIS_OOME_DUMP='/var/lib/artemis-instance/log/oom_dump.hprof'
# The logging config will need an URI
# this will be encoded in case you use spaces or special characters
# on your directory structure
ARTEMIS_INSTANCE_URI='file:/var/lib/artemis-instance/./'
ARTEMIS_INSTANCE_ETC_URI='file:/var/lib/artemis-instance/./etc/'
# Hawtio Properties
HAWTIO_ROLE='amq'
# Java Opts
if [ -z "$JAVA_ARGS" ]; then
JAVA_ARGS="-XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms128M -Xmx512M -Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml "
fi

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<broker xmlns="http://activemq.org/schema">
<jaas-security domain="activemq"/>
<!-- artemis.URI.instance is parsed from artemis.instance by the CLI startup.
This is to avoid situations where you could have spaces or special characters on this URI -->
<server configuration="file:/var/lib/artemis-instance/./etc//broker.xml"/>
<!-- The web server is only bound to localhost by default -->
<web bind="http://localhost:8161" path="web">
<app url="activemq-branding" war="activemq-branding.war"/>
<app url="artemis-plugin" war="artemis-plugin.war"/>
<app url="console" war="console.war"/>
</web>
</broker>

View File

@ -120,7 +120,11 @@ under the License.
<page-sync-timeout>40000</page-sync-timeout> <page-sync-timeout>40000</page-sync-timeout>
<broker-connections>
<amqp-connection uri="tcp://localhost:61616" name="outgoing" reconnect-attempts="-1" retry-interval="100" user="A" password="A">
<mirror/>
</amqp-connection>
</broker-connections>
<acceptors> <acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true</acceptor> <acceptor name="artemis">tcp://0.0.0.0:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true</acceptor>
</acceptors> </acceptors>

View File

@ -0,0 +1,251 @@
<?xml version='1.0'?>
<!--
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.
-->
<configuration xmlns="urn:activemq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:activemq:core ">
<name>ServerA</name>
<persistence-enabled>true</persistence-enabled>
<!-- this could be ASYNCIO, MAPPED, NIO
ASYNCIO: Linux Libaio
MAPPED: mmap files
NIO: Plain Java Files
-->
<journal-type>NIO</journal-type>
<paging-directory>data/paging</paging-directory>
<bindings-directory>data/bindings</bindings-directory>
<journal-directory>data/journal</journal-directory>
<large-messages-directory>data/large-messages</large-messages-directory>
<journal-datasync>true</journal-datasync>
<journal-min-files>2</journal-min-files>
<journal-pool-files>10</journal-pool-files>
<journal-device-block-size>4096</journal-device-block-size>
<journal-file-size>10M</journal-file-size>
<!--
This value was determined through a calculation.
Your system could perform 25 writes per millisecond
on the current journal configuration.
That translates as a sync write every 40000 nanoseconds.
Note: If you specify 0 the system will perform writes directly to the disk.
We recommend this to be 0 if you are using journalType=MAPPED and journal-datasync=false.
-->
<journal-buffer-timeout>40000</journal-buffer-timeout>
<!--
When using ASYNCIO, this will determine the writing queue depth for libaio.
-->
<journal-max-io>1</journal-max-io>
<!--
You can verify the network health of a particular NIC by specifying the <network-check-NIC> element.
<network-check-NIC>theNicName</network-check-NIC>
-->
<!--
Use this to use an HTTP server to validate the network
<network-check-URL-list>http://www.apache.org</network-check-URL-list> -->
<!-- <network-check-period>10000</network-check-period> -->
<!-- <network-check-timeout>1000</network-check-timeout> -->
<!-- this is a comma separated list, no spaces, just DNS or IPs
it should accept IPV6
Warning: Make sure you understand your network topology as this is meant to validate if your network is valid.
Using IPs that could eventually disappear or be partially visible may defeat the purpose.
You can use a list of multiple IPs, and if any successful ping will make the server OK to continue running -->
<!-- <network-check-list>10.0.0.1</network-check-list> -->
<!-- use this to customize the ping used for ipv4 addresses -->
<!-- <network-check-ping-command>ping -c 1 -t %d %s</network-check-ping-command> -->
<!-- use this to customize the ping used for ipv6 addresses -->
<!-- <network-check-ping6-command>ping6 -c 1 %2$s</network-check-ping6-command> -->
<!-- how often we are looking for how many bytes are being used on the disk in ms -->
<disk-scan-period>5000</disk-scan-period>
<!-- once the disk hits this limit the system will block, or close the connection in certain protocols
that won't support flow control. -->
<max-disk-usage>90</max-disk-usage>
<!-- should the broker detect dead locks and other issues -->
<critical-analyzer>true</critical-analyzer>
<critical-analyzer-timeout>120000</critical-analyzer-timeout>
<critical-analyzer-check-period>60000</critical-analyzer-check-period>
<critical-analyzer-policy>HALT</critical-analyzer-policy>
<page-sync-timeout>40000</page-sync-timeout>
<acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true</acceptor>
</acceptors>
<broker-connections>
<amqp-connection uri="tcp://qdr:5672" name="another" retry-interval="100" reconnect-attempts="-1">
<peer address-match="queue.test0"/>
<peer address-match="queue.test1"/>
<peer address-match="queue.test2"/>
<peer address-match="queue.test3"/>
<peer address-match="queue.test4"/>
<peer address-match="queue.test5"/>
<peer queue-name="distinct.dist"/>
</amqp-connection>
</broker-connections>
<security-settings>
<security-setting match="#">
<permission type="createNonDurableQueue" roles="amq"/>
<permission type="deleteNonDurableQueue" roles="amq"/>
<permission type="createDurableQueue" roles="amq"/>
<permission type="deleteDurableQueue" roles="amq"/>
<permission type="createAddress" roles="amq"/>
<permission type="deleteAddress" roles="amq"/>
<permission type="consume" roles="amq"/>
<permission type="browse" roles="amq"/>
<permission type="send" roles="amq"/>
<!-- we need this otherwise ./artemis data imp wouldn't work -->
<permission type="manage" roles="amq"/>
</security-setting>
</security-settings>
<address-settings>
<!-- if you define auto-create on certain queues, management has to be auto-create -->
<address-setting match="activemq.management#">
<dead-letter-address>DLQ</dead-letter-address>
<expiry-address>ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<!-- with -1 only the global-max-size is in use for limiting -->
<max-size-bytes>-1</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>PAGE</address-full-policy>
<auto-create-queues>false</auto-create-queues>
<auto-create-addresses>false</auto-create-addresses>
<auto-create-jms-queues>false</auto-create-jms-queues>
<auto-create-jms-topics>false</auto-create-jms-topics>
</address-setting>
<!--default for catch all-->
<address-setting match="#">
<dead-letter-address>DLQ</dead-letter-address>
<expiry-address>ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<!-- with -1 only the global-max-size is in use for limiting -->
<max-size-bytes>-1</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>PAGE</address-full-policy>
<auto-create-queues>false</auto-create-queues>
<auto-create-addresses>false</auto-create-addresses>
<auto-create-jms-queues>false</auto-create-jms-queues>
<auto-create-jms-topics>false</auto-create-jms-topics>
</address-setting>
</address-settings>
<addresses>
<address name="DLQ">
<anycast>
<queue name="DLQ" />
</anycast>
</address>
<address name="ExpiryQueue">
<anycast>
<queue name="ExpiryQueue" />
</anycast>
</address>
<address name="queue.test0">
<anycast>
<queue name="queue.test0" />
</anycast>
</address>
<address name="queue.test1">
<anycast>
<queue name="queue.test1" />
</anycast>
</address>
<address name="queue.test2">
<anycast>
<queue name="queue.test2" />
</anycast>
</address>
<address name="queue.test3">
<anycast>
<queue name="queue.test3" />
</anycast>
</address>
<address name="queue.test4">
<anycast>
<queue name="queue.test4" />
</anycast>
</address>
<address name="queue.test5">
<anycast>
<queue name="queue.test5" />
</anycast>
</address>
<address name="queue.dist">
<anycast>
<queue name="distinct.dist" />
</anycast>
</address>
</addresses>
<!-- Uncomment the following if you want to use the Standard LoggingActiveMQServerPlugin pluging to log in events
<broker-plugins>
<broker-plugin class-name="org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin">
<property key="LOG_ALL_EVENTS" value="true"/>
<property key="LOG_CONNECTION_EVENTS" value="true"/>
<property key="LOG_SESSION_EVENTS" value="true"/>
<property key="LOG_CONSUMER_EVENTS" value="true"/>
<property key="LOG_DELIVERING_EVENTS" value="true"/>
<property key="LOG_SENDING_EVENTS" value="true"/>
<property key="LOG_INTERNAL_EVENTS" value="true"/>
</broker-plugin>
</broker-plugins>
-->
</core>
</configuration>

View File

@ -0,0 +1,40 @@
#
# 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.
#
router {
mode: standalone
id: INT.A
}
log {
module: DEFAULT
enable: trace+
outputFile: /routerlog/qdrouterd.log
}
# Clients connect to this port
listener {
saslMechanisms: ANONYMOUS
host: 0.0.0.0
role: normal
authenticatePeer: no
port: 5672
}
address {
prefix: queue
waypoint: yes
}

View File

@ -34,8 +34,8 @@ import org.apache.activemq.artemis.tests.util.CFUtil;
public class BrokerConnectionBridgeSecurityTest extends SmokeTestBase { public class BrokerConnectionBridgeSecurityTest extends SmokeTestBase {
public static final String SERVER_NAME_A = "brokerConnectBridgeSecurityA"; public static final String SERVER_NAME_A = "brokerConnect/bridgeSecurityA";
public static final String SERVER_NAME_B = "brokerConnectBridgeSecurityB"; public static final String SERVER_NAME_B = "brokerConnect/bridgeSecurityB";
@Before @Before
public void before() throws Exception { public void before() throws Exception {

View File

@ -34,8 +34,8 @@ import org.junit.Test;
public class BrokerConnectionMirrorSecurityTest extends SmokeTestBase { public class BrokerConnectionMirrorSecurityTest extends SmokeTestBase {
public static final String SERVER_NAME_A = "brokerConnectMirrorSecurityA"; public static final String SERVER_NAME_A = "brokerConnect/mirrorSecurityA";
public static final String SERVER_NAME_B = "brokerConnectMirrorSecurityB"; public static final String SERVER_NAME_B = "brokerConnect/mirrorSecurityB";
@Before @Before
public void before() throws Exception { public void before() throws Exception {

View File

@ -0,0 +1,195 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smoke.brokerConnection;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.tests.smoke.common.ContainerService;
import org.jboss.logging.Logger;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* You need to build the Artemis Centos image before this test is executed.
* Follow the instructions under artemis-docker and build the Docker-centos image.
*/
public class QpidDispatchPeerTest extends SmokeTestBase {
private static final Logger logger = Logger.getLogger(QpidDispatchPeerTest.class);
static Object network;
static Object qpidServer;
static Object artemisServer;
static ContainerService service = ContainerService.getService();
@Before
public void disableThreadcheck() {
disableCheckThread();
}
private static final String QDR_HOME = basedir + "/target/brokerConnect/qdr";
@BeforeClass
public static void startServers() {
try {
Assert.assertNotNull(basedir);
network = service.newNetwork();
artemisServer = service.newBrokerImage();
service.setNetwork(artemisServer, network);
service.exposePorts(artemisServer, 61616);
service.prepareInstance(QDR_HOME);
service.exposeBrokerHome(artemisServer, QDR_HOME);
service.startLogging(artemisServer, "ArtemisServer:");
qpidServer = service.newInterconnectImage();
service.setNetwork(qpidServer, network);
service.exposePorts(qpidServer, 5672);
service.exposeHosts(qpidServer, "qdr");
service.exposeFile(qpidServer, basedir + "/src/main/resources/servers/brokerConnect/qdr/qdrouterd.conf", "/tmp/qdrouterd.conf");
service.exposeFolder(qpidServer, basedir + "/target/brokerConnect/qdr", "/routerlog");
service.startLogging(qpidServer, "qpid-dispatch:");
service.start(qpidServer);
recreateBrokerDirectory(QDR_HOME);
service.start(artemisServer);
} catch (Exception e) {
e.printStackTrace();
Assume.assumeNoException("Docker not available", e);
}
}
@AfterClass
public static void stopServer() {
service.stop(artemisServer);
service.stop(qpidServer);
}
@Test
public void testSendReceive() throws Exception {
int numberOfMessages = 100;
for (int dest = 0; dest < 5; dest++) {
{
ConnectionFactory factoryProducer = service.createCF(qpidServer, "amqp", 5672, "?amqpIdleTimeout=1000");
Connection connection = null;
connection = createConnectionDumbRetry(factoryProducer);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("queue.test" + dest);
MessageProducer producer = session.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
for (int i = 0; i < numberOfMessages; i++) {
logger.debug("Sending " + i);
producer.send(session.createTextMessage("hello " + i));
}
connection.close();
}
{
ConnectionFactory factoryConsumer = service.createCF(artemisServer, "amqp", 61616, "?amqpIdleTimeout=1000");
Connection connectionConsumer = factoryConsumer.createConnection("artemis", "artemis");
Session sessionConsumer = connectionConsumer.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queueConsumer = sessionConsumer.createQueue("queue.test" + dest);
MessageConsumer consumer = sessionConsumer.createConsumer(queueConsumer);
connectionConsumer.start();
for (int i = 0; i < numberOfMessages; i++) {
Message message = consumer.receive(5000);
Assert.assertNotNull(message);
}
connectionConsumer.close();
}
}
}
@Test
public void testSendReceiveDistinct() throws Exception {
int numberOfMessages = 100;
{
ConnectionFactory factoryProducer = service.createCF(qpidServer, "amqp", 5672, "?amqpIdleTimeout=1000");
Connection connection = null;
connection = createConnectionDumbRetry(factoryProducer);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("queue.dist");
MessageProducer producer = session.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
for (int i = 0; i < numberOfMessages; i++) {
logger.debug("Sending " + i);
producer.send(session.createTextMessage("hello " + i));
}
connection.close();
}
{
ConnectionFactory factoryConsumer = service.createCF(artemisServer, "amqp", 61616, "?amqpIdleTimeout=1000");
Connection connectionConsumer = factoryConsumer.createConnection("artemis", "artemis");
Session sessionConsumer = connectionConsumer.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queueConsumer = sessionConsumer.createQueue("queue.dist::distinct.dist");
MessageConsumer consumer = sessionConsumer.createConsumer(queueConsumer);
connectionConsumer.start();
for (int i = 0; i < numberOfMessages; i++) {
Message message = consumer.receive(5000);
Assert.assertNotNull(message);
}
connectionConsumer.close();
}
}
private Connection createConnectionDumbRetry(ConnectionFactory factoryProducer) throws InterruptedException {
for (int i = 0; i < 100; i++) {
try {
// Some retry
return factoryProducer.createConnection();
} catch (Exception e) {
Thread.sleep(10);
}
}
return null;
}
}

View File

@ -0,0 +1,283 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smoke.common;
import javax.jms.ConnectionFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.function.Consumer;
import org.apache.activemq.artemis.tests.util.CFUtil;
import org.junit.Assert;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
/**
* I am intentionally not depending directly into TestContainer
* I intend in a near future to support kubernetes and podman and I would like to keep an interface between our tests and the Container provider.
*/
public abstract class ContainerService {
public static final ContainerService service;
static {
ContainerService loadingService;
try {
String providerName = System.getProperty(ContainerService.class.getName() + ".service");
if (providerName == null) {
loadingService = new TestContainerImpl();
} else {
loadingService = (ContainerService) Class.forName(providerName).newInstance();
}
} catch (Throwable e) {
e.printStackTrace();
loadingService = null;
}
service = loadingService;
}
public static ContainerService getService() {
return service;
}
public abstract Object newNetwork();
public abstract Object newBrokerImage();
public abstract Object newInterconnectImage();
public abstract void setNetwork(Object container, Object network);
public abstract void exposePorts(Object container, Integer... ports);
public abstract void exposeFile(Object container, String hostPath, String containerPath);
public abstract void exposeFolder(Object container, String hostPath, String containerPath);
public abstract void copyFileToContainer(Object container, String hostPath, String containerPath);
public abstract void exposeBrokerHome(Object container, String brokerHome);
public abstract void startLogging(Object container, String prefix);
public abstract void start(Object container);
public abstract void kill(Object container);
public abstract void stop(Object container);
public abstract void restart(Object container);
public abstract int getPort(Object container, int mappedPort);
public abstract void exposeHosts(Object container, String... hosts);
/** prepare the instance folder to run inside the docker image */
public abstract void prepareInstance(String home) throws Exception;
public String getHost(Object container) {
return "localhost";
}
public abstract ConnectionFactory createCF(Object container, String protocol);
public abstract String createURI(Object container, int port);
public abstract ConnectionFactory createCF(Object container, String protocol, int port);
public abstract ConnectionFactory createCF(Object container, String protocol, int port, String extraURL);
public boolean waitForServerToStart(Object container, String username, String password, long timeout) throws InterruptedException {
long realTimeout = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < realTimeout) {
try {
ConnectionFactory cf = createCF(container, "core");
cf.createConnection(username, password).close();
if (cf instanceof AutoCloseable) {
((AutoCloseable)cf).close();
}
System.out.println("server started");
} catch (Exception e) {
System.out.println("awaiting server start at ");
Thread.sleep(500);
continue;
}
return true;
}
return false;
}
public abstract void logWait(Object container, String log);
private static class TestContainerImpl extends ContainerService {
@Override
public ConnectionFactory createCF(Object container, String protocol) {
return createCF(container, protocol, 61616);
}
@Override
public void prepareInstance(String home) throws Exception {
File homeFile = new File(home);
Assert.assertTrue(homeFile.exists());
Assert.assertTrue(homeFile.isDirectory());
copyFile("artemis", home + "/bin/artemis");
copyFile("artemis.profile", home + "/etc/artemis.profile");
copyFile("bootstrap.xml", home + "/etc/bootstrap.xml");
}
private void copyFile(String from, String to) throws IOException {
File file = new File(SmokeTestBase.basedir + "/src/main/resources/containerService/" + from);
Files.copy(file.toPath(), new File(to).toPath(), StandardCopyOption.REPLACE_EXISTING);
}
@Override
public ConnectionFactory createCF(Object container, String protocol, int port) {
return CFUtil.createConnectionFactory("amqp", "tcp://" + getHost(container) + ":" + getPort(container, port));
}
@Override
public ConnectionFactory createCF(Object container, String protocol, int port, String extraURI) {
System.out.println("tcp://" + getHost(container) + ":" + getPort(container, port) + extraURI);
return CFUtil.createConnectionFactory("amqp", "tcp://" + getHost(container) + ":" + getPort(container, port) + extraURI);
}
@Override
public Object newNetwork() {
return Network.newNetwork();
}
@Override
public Object newBrokerImage() {
return new GenericContainer<>(DockerImageName.parse("artemis-centos"));
}
@Override
public Object newInterconnectImage() {
return new GenericContainer<>(DockerImageName.parse("quay.io/interconnectedcloud/qdrouterd:latest"));
}
@Override
public void setNetwork(Object container, Object network) {
((GenericContainer)container).setNetwork((Network)network);
}
@Override
public void exposePorts(Object container, Integer... ports) {
((GenericContainer)container).withExposedPorts(ports);
}
@Override
public void exposeFile(Object container, String hostPath, String containerPath) {
File file = new File(hostPath);
Assert.assertTrue(file.exists());
Assert.assertFalse(file.isDirectory());
((GenericContainer)container).withFileSystemBind(hostPath, containerPath);
}
@Override
public void exposeFolder(Object container, String hostPath, String containerPath) {
File file = new File(hostPath);
Assert.assertTrue(file.exists());
Assert.assertTrue(file.isDirectory());
((GenericContainer)container).withFileSystemBind(hostPath, containerPath);
}
@Override
public void copyFileToContainer(Object container, String hostPath, String containerPath) {
File file = new File(hostPath);
Assert.assertTrue(file.exists());
Assert.assertFalse(file.isDirectory());
((GenericContainer)container).withCopyFileToContainer(MountableFile.forHostPath(hostPath), containerPath);
}
@Override
public void exposeBrokerHome(Object container, String brokerHome) {
exposeFolder(container, brokerHome, "/var/lib/artemis-instance");
}
@Override
public void start(Object container) {
((GenericContainer)container).setStartupCheckStrategy(new IsRunningStartupCheckStrategy());
((GenericContainer)container).start();
}
@Override
public void restart(Object containerObj) {
kill(containerObj);
start(containerObj);
}
@Override
public void kill(Object containerObj) {
GenericContainer container = (GenericContainer) containerObj;
container.getDockerClient().killContainerCmd(container.getContainerId()).exec();
container.stop();
}
@Override
public int getPort(Object container, int mappedPort) {
return ((GenericContainer)container).getMappedPort(mappedPort);
}
@Override
public void exposeHosts(Object container, String... hosts) {
((GenericContainer)container).withNetworkAliases(hosts);
}
@Override
public void stop(Object container) {
if (container != null) {
((GenericContainer) container).stop();
}
}
@Override
public void startLogging(Object container, String prefix) {
((GenericContainer)container).withLogConsumer(new Consumer<OutputFrame>() {
@Override
public void accept(OutputFrame outputFrame) {
System.out.print(prefix + outputFrame.getUtf8String());
}
});
}
@Override
public void logWait(Object container, String log) {
LogMessageWaitStrategy logMessageWaitStrategy = new LogMessageWaitStrategy();
logMessageWaitStrategy.withRegEx(log);
((GenericContainer)container).setWaitStrategy(logMessageWaitStrategy);
}
@Override
public String createURI(Object container, int port) {
GenericContainer genericContainer = (GenericContainer) container;
return "tcp://" + genericContainer.getHost() + ":" + genericContainer.getMappedPort(port);
}
}
}

View File

@ -25,7 +25,9 @@ import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.cli.commands.Stop; import org.apache.activemq.artemis.cli.commands.Stop;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.util.ServerUtil; import org.apache.activemq.artemis.util.ServerUtil;
import org.junit.After; import org.junit.After;
@ -71,6 +73,7 @@ public class SmokeTestBase extends ActiveMQTestBase {
public static void cleanupData(String serverName) { public static void cleanupData(String serverName) {
String location = getServerLocation(serverName); String location = getServerLocation(serverName);
deleteDirectory(new File(location, "data")); deleteDirectory(new File(location, "data"));
deleteDirectory(new File(location, "log"));
} }
public void addProcess(Process process) { public void addProcess(Process process) {
@ -109,4 +112,28 @@ public class SmokeTestBase extends ActiveMQTestBase {
} }
return jmxConnector; return jmxConnector;
} }
protected static final void recreateBrokerDirectory(final String homeInstance) {
recreateDirectory(homeInstance + "/data");
recreateDirectory(homeInstance + "/logs");
}
public boolean waitForServerToStart(String uri, String username, String password, long timeout) throws InterruptedException {
long realTimeout = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < realTimeout) {
try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) {
cf.createConnection(username, password).close();
System.out.println("server " + uri + " started");
} catch (Exception e) {
System.out.println("awaiting server " + uri + " start at ");
Thread.sleep(500);
continue;
}
return true;
}
return false;
}
} }