ARTEMIS-1089 Moving smoke tests under ./tests/smoke-tests This is moving the smoke tests creates as part of the relication tests.
They are also now based on junit tests. And to support starting servers I am exposing basedir to unit tests in general. Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/dd27fb58 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/dd27fb58 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/dd27fb58 Branch: refs/heads/master Commit: dd27fb587f1862b74dcf1c72115022351ca1ed67 Parents: f0ce8a8 Author: Clebert Suconic <[email protected]> Authored: Tue Apr 4 20:20:56 2017 -0400 Committer: Martyn Taylor <[email protected]> Committed: Wed Apr 5 13:06:55 2017 +0100 ---------------------------------------------------------------------- .../src/test/scripts/run-examples.sh | 5 - examples/pom.xml | 1 - examples/smoke/ha/pom.xml | 61 ----- .../smoke/ha/replicated-flowcontrol/pom.xml | 112 -------- .../example/ReplicatedFailbackStaticSmoke.java | 225 ---------------- .../main/resources/activemq/server0/broker.xml | 118 -------- .../main/resources/activemq/server1/broker.xml | 121 --------- .../src/main/resources/jndi.properties | 20 -- examples/smoke/pom.xml | 60 ----- examples/smoke/readme.md | 8 - pom.xml | 4 +- tests/pom.xml | 1 + tests/smoke-tests/pom.xml | 48 ++++ tests/smoke-tests/readme.md | 6 + .../smoke-tests/replicated-flowcontrol/pom.xml | 203 ++++++++++++++ .../main/resources/activemq/server0/broker.xml | 118 ++++++++ .../main/resources/activemq/server1/broker.xml | 121 +++++++++ .../ReplicatedFailbackSmokeTest.java | 268 +++++++++++++++++++ 18 files changed, 768 insertions(+), 732 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/artemis-distribution/src/test/scripts/run-examples.sh ---------------------------------------------------------------------- diff --git a/artemis-distribution/src/test/scripts/run-examples.sh b/artemis-distribution/src/test/scripts/run-examples.sh index e9f2651..e5f5f00 100755 --- a/artemis-distribution/src/test/scripts/run-examples.sh +++ b/artemis-distribution/src/test/scripts/run-examples.sh @@ -133,10 +133,5 @@ cd scale-down; mvn verify; cd .. cd transaction-failover; mvn verify; cd .. - -cd $ARTEMIS_HOME/examples/smoke/ha -cd replicated-flowcontrol; mvn verify; cd .. - - cd $CURRENT_DIR rm -rf target http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/pom.xml ---------------------------------------------------------------------- diff --git a/examples/pom.xml b/examples/pom.xml index 26b77ed..06713b6 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -96,7 +96,6 @@ under the License. <modules> <module>features</module> <module>protocols</module> - <module>smoke</module> </modules> </project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/ha/pom.xml ---------------------------------------------------------------------- diff --git a/examples/smoke/ha/pom.xml b/examples/smoke/ha/pom.xml deleted file mode 100644 index 5e0eef1..0000000 --- a/examples/smoke/ha/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.smoke</groupId> - <artifactId>smoke</artifactId> - <version>2.1.0-SNAPSHOT</version> - </parent> - - <groupId>org.apache.activemq.examples.smoke.ha</groupId> - <artifactId>smoke-ha</artifactId> - <packaging>pom</packaging> - <name>ActiveMQ Artemis Failover Examples</name> - - <!-- Properties --> - <properties> - <!-- - Explicitly declaring the source encoding eliminates the following - message: [WARNING] Using platform encoding (UTF-8 actually) to copy - filtered resources, i.e. build is platform dependent! - --> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <profiles> - <profile> - <id>release</id> - <modules> - <module>replicated-flowcontrol</module> - </modules> - </profile> - <profile> - <id>examples</id> - <modules> - <module>replicated-flowcontrol</module> - </modules> - </profile> - </profiles> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/ha/replicated-flowcontrol/pom.xml ---------------------------------------------------------------------- diff --git a/examples/smoke/ha/replicated-flowcontrol/pom.xml b/examples/smoke/ha/replicated-flowcontrol/pom.xml deleted file mode 100644 index 011ea2a..0000000 --- a/examples/smoke/ha/replicated-flowcontrol/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ -<?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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.smoke.ha</groupId> - <artifactId>smoke-ha</artifactId> - <version>2.1.0-SNAPSHOT</version> - </parent> - - <artifactId>replicated-flowcontrol</artifactId> - <packaging>jar</packaging> - <name>Smoke test for replication, simulating large flow conrol</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.qpid</groupId> - <artifactId>qpid-jms-client</artifactId> - <version>${qpid.jms.version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <!-- this makes it easier in certain envs --> - <javaOptions>-Djava.net.preferIPv4Stack=true</javaOptions> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <!-- this makes it easier in certain envs --> - <javaOptions>-Djava.net.preferIPv4Stack=true</javaOptions> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ReplicatedFailbackStaticSmoke</clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.smoke.ha</groupId> - <artifactId>replicated-flowcontrol</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/ha/replicated-flowcontrol/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticSmoke.java ---------------------------------------------------------------------- diff --git a/examples/smoke/ha/replicated-flowcontrol/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticSmoke.java b/examples/smoke/ha/replicated-flowcontrol/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticSmoke.java deleted file mode 100644 index 723c6c3..0000000 --- a/examples/smoke/ha/replicated-flowcontrol/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticSmoke.java +++ /dev/null @@ -1,225 +0,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. - */ -package org.apache.activemq.artemis.jms.example; - -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 javax.naming.InitialContext; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.util.ServerUtil; -import org.apache.activemq.artemis.utils.ReusableLatch; -import org.apache.qpid.jms.JmsConnectionFactory; - -/** - * Example of live and replicating backup pair. - * <p> - * After both servers are started, the live server is killed and the backup becomes active ("fails-over"). - * <p> - * Later the live server is restarted and takes back its position by asking the backup to stop ("fail-back"). - */ -public class ReplicatedFailbackStaticSmoke { - - private static Process server0; - - private static Process server1; - - static final int NUM_MESSAGES = 300_000; - static final int START_CONSUMERS = 100_000; - static final int START_SERVER = 101_000; - static final int KILL_SERVER = -1; // not killing the server right now.. just for future use - static final int NUMBER_OF_CONSUMERS = 10; - static final ReusableLatch latch = new ReusableLatch(NUM_MESSAGES); - - static AtomicBoolean running = new AtomicBoolean(true); - static AtomicInteger totalConsumed = new AtomicInteger(0); - - public static void main(final String[] args) throws Exception { - - Connection connection = null; - - InitialContext initialContext = null; - - try { - server0 = ServerUtil.startServer(args[0], ReplicatedFailbackStaticSmoke.class.getSimpleName() + "0", 0, 30000); - - initialContext = new InitialContext(); - - ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - connection = connectionFactory.createConnection(); - - Session session = connection.createSession(true, Session.SESSION_TRANSACTED); - - Queue queue = session.createQueue("exampleQueue"); - - connection.start(); - - MessageProducer producer = session.createProducer(queue); - - BytesMessage bytesMessage = session.createBytesMessage(); - bytesMessage.writeBytes(new byte[20 * 1024]); - - for (int i = 0; i < NUM_MESSAGES; i++) { - - producer.send(bytesMessage); - if (i % 1000 == 0) { - System.out.println("Sent " + i + " messages, consumed=" + totalConsumed.get()); - session.commit(); - } - - if (i == START_CONSUMERS) { - System.out.println("Starting consumers"); - startConsumers(); - } - - if (KILL_SERVER >= 0 && i == KILL_SERVER) { - System.out.println("Killing server"); - ServerUtil.killServer(server0); - } - - if (i == START_SERVER) { - System.out.println("Starting extra server"); - server1 = ServerUtil.startServer(args[1], ReplicatedFailbackStaticSmoke.class.getSimpleName() + "1", 1, 10000); - } - - } - - session.commit(); - - System.out.println("Awaiting all consumers to finish"); - while (!latch.await(5, TimeUnit.SECONDS)) { - System.out.println("Missing " + latch.getCount() + ", totalConsumed = " + totalConsumed); - } - - } finally { - - running.set(false); - - if (connection != null) { - connection.close(); - } - - if (initialContext != null) { - initialContext.close(); - } - - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - } - } - - static void startConsumers() { - for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) { - Consumer consumer = new Consumer(i % 2 == 0, i); - consumer.start(); - - } - } - - static class Consumer extends Thread { - - ConnectionFactory factory; - Connection connection; - Session session; - Queue queue; - MessageConsumer consumer; - int count = 0; - int totalCount = 0; - - final int consumerID; - - final boolean amqp; - - Consumer(boolean amqp, int id) { - super("amqp=" + amqp + ", id=" + id); - this.amqp = amqp; - this.consumerID = id; - } - - @Override - public String toString() { - return "Consumer " + consumerID + ", amqp::" + amqp; - } - - void connect() throws Exception { - count = 0; - if (amqp) { - factory = new JmsConnectionFactory("amqp://localhost:61616"); - } else { - factory = new ActiveMQConnectionFactory(); // using default is fine here - } - - connection = factory.createConnection(); - session = connection.createSession(true, Session.SESSION_TRANSACTED); - queue = session.createQueue("exampleQueue"); - consumer = session.createConsumer(queue); - connection.start(); - } - - @Override - public void run() { - while (running.get()) { - try { - if (connection == null) { - connect(); - } - - totalCount++; - if (totalCount % 1000 == 0) { - System.out.println(this + " received " + totalCount + " messages"); - } - - BytesMessage message = (BytesMessage) consumer.receive(5000); - if (message == null) { - System.out.println("Consumer " + this + " couldn't get a message"); - if (count > 0) { - session.commit(); - latch.countDown(count); - totalConsumed.addAndGet(count); - count = 0; - } - } else { - count++; - - if (count == 100) { - session.commit(); - latch.countDown(count); - totalConsumed.addAndGet(count); - count = 0; - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - } - - System.out.println("Giving up the loop " + this); - - } - - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml b/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 0e58838..0000000 --- a/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -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" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <cluster-user>exampleUser</cluster-user> - - <cluster-password>secret</cluster-password> - - <ha-policy> - <replication> - <master> - <!--we need this for auto failback--> - <check-for-live-server>true</check-for-live-server> - </master> - </replication> - </ha-policy> - - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - <connector name="netty-backup-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <connector-ref>netty-connector</connector-ref> - <static-connectors> - <connector-ref>netty-backup-connector</connector-ref> - </static-connectors> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="exampleQueue"> - <permission roles="guest" type="createDurableQueue"/> - <permission roles="guest" type="deleteDurableQueue"/> - <permission roles="guest" type="createNonDurableQueue"/> - <permission roles="guest" type="deleteNonDurableQueue"/> - <permission roles="guest" type="consume"/> - <permission roles="guest" type="send"/> - </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>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</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>200MB</max-size-bytes> - <page-size-bytes>100MB</page-size-bytes> - - <message-counter-history-day-limit>10</message-counter-history-day-limit> - <address-full-policy>PAGE</address-full-policy> - <auto-create-queues>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</auto-create-jms-topics> - </address-setting> - </address-settings> - - <addresses> - <address name="exampleQueue"> - <anycast> - <queue name="exampleQueue"/> - </anycast> - </address> - </addresses> - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml b/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index e67613d..0000000 --- a/examples/smoke/ha/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,121 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -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" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <cluster-user>exampleUser</cluster-user> - - <cluster-password>secret</cluster-password> - - <ha-policy> - <replication> - <slave> - <allow-failback>true</allow-failback> - <!-- not needed but tells the backup not to restart after failback as there will be > 0 backups saved --> - <max-saved-replicated-journals-size>0</max-saved-replicated-journals-size> - </slave> - </replication> - </ha-policy> - - <!-- Connectors --> - <connectors> - <connector name="netty-live-connector">tcp://localhost:61616</connector> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <connector-ref>netty-connector</connector-ref> - <static-connectors> - <connector-ref>netty-live-connector</connector-ref> - </static-connectors> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="exampleQueue"> - <permission roles="guest" type="createDurableQueue"/> - <permission roles="guest" type="deleteDurableQueue"/> - <permission roles="guest" type="createNonDurableQueue"/> - <permission roles="guest" type="deleteNonDurableQueue"/> - <permission roles="guest" type="consume"/> - <permission roles="guest" type="send"/> - </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>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</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>200MB</max-size-bytes> - <page-size-bytes>100MB</page-size-bytes> - - <message-counter-history-day-limit>10</message-counter-history-day-limit> - <address-full-policy>PAGE</address-full-policy> - <auto-create-queues>true</auto-create-queues> - <auto-create-addresses>true</auto-create-addresses> - <auto-create-jms-queues>true</auto-create-jms-queues> - <auto-create-jms-topics>true</auto-create-jms-topics> - </address-setting> - </address-settings> - - <addresses> - <address name="exampleQueue"> - <anycast> - <queue name="exampleQueue"/> - </anycast> - </address> - </addresses> - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/ha/replicated-flowcontrol/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/smoke/ha/replicated-flowcontrol/src/main/resources/jndi.properties b/examples/smoke/ha/replicated-flowcontrol/src/main/resources/jndi.properties deleted file mode 100644 index 7f7a19f..0000000 --- a/examples/smoke/ha/replicated-flowcontrol/src/main/resources/jndi.properties +++ /dev/null @@ -1,20 +0,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. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1 -queue.queue/exampleQueue=exampleQueue http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/pom.xml ---------------------------------------------------------------------- diff --git a/examples/smoke/pom.xml b/examples/smoke/pom.xml deleted file mode 100644 index 5c0c08e..0000000 --- a/examples/smoke/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples</groupId> - <artifactId>artemis-examples</artifactId> - <version>2.1.0-SNAPSHOT</version> - </parent> - - <groupId>org.apache.activemq.examples.smoke</groupId> - <artifactId>smoke</artifactId> - <packaging>pom</packaging> - <name>ActiveMQ Artemis Smoke Tests</name> - - <!-- Properties --> - <properties> - <!-- - Explicitly declaring the source encoding eliminates the following - message: [WARNING] Using platform encoding (UTF-8 actually) to copy - filtered resources, i.e. build is platform dependent! - --> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <activemq.basedir>${project.basedir}/../..</activemq.basedir> - </properties> - - <profiles> - <profile> - <id>examples</id> - <modules> - <module>ha</module> - </modules> - </profile> - <profile> - <id>release</id> - <modules> - <module>ha</module> - </modules> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/examples/smoke/readme.md ---------------------------------------------------------------------- diff --git a/examples/smoke/readme.md b/examples/smoke/readme.md deleted file mode 100644 index 2b99851..0000000 --- a/examples/smoke/readme.md +++ /dev/null @@ -1,8 +0,0 @@ -# Smoke Tests - -Everything under this folder is not meant for "educational" purposes. - -These represent production-like scenarios. - -In cases where a testcase may be too short lived, we use these smoke tests -to validate production like scenarios http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2110c59..3f636ec 100644 --- a/pom.xml +++ b/pom.xml @@ -116,6 +116,7 @@ <skipJmsTests>true</skipJmsTests> <skipExtraTests>true</skipExtraTests> <skipIntegrationTests>true</skipIntegrationTests> + <skipSmokeTests>true</skipSmokeTests> <skipJoramTests>true</skipJoramTests> <skipTimingTests>true</skipTimingTests> <skipStressTests>true</skipStressTests> @@ -150,7 +151,7 @@ <activemq-surefire-argline>-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dlogging.configuration="file:${activemq.basedir}/tests/config/logging.properties" -Djava.library.path="${activemq.basedir}/artemis-native/bin" -Djgroups.bind_addr=localhost -Dorg.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory.localBindAddress=localhost - -Djava.net.preferIPv4Stack=true + -Djava.net.preferIPv4Stack=true -Dbasedir=${basedir} </activemq-surefire-argline> <activemq.basedir>${project.basedir}</activemq.basedir> <skipLicenseCheck>true</skipLicenseCheck> @@ -831,6 +832,7 @@ <skipJmsTests>false</skipJmsTests> <skipJoramTests>false</skipJoramTests> <skipIntegrationTests>false</skipIntegrationTests> + <skipSmokeTests>false</skipSmokeTests> <skipTimingTests>true</skipTimingTests> <skipConcurrentTests>false</skipConcurrentTests> <skipRestTests>false</skipRestTests> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/pom.xml b/tests/pom.xml index b1b0107..177ac16 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -130,5 +130,6 @@ <module>stress-tests</module> <module>performance-tests</module> <module>artemis-test-support</module> + <module>smoke-tests</module> </modules> </project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/smoke-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml new file mode 100644 index 0000000..89ea128 --- /dev/null +++ b/tests/smoke-tests/pom.xml @@ -0,0 +1,48 @@ +<?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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.activemq.tests</groupId> + <artifactId>artemis-tests-pom</artifactId> + <version>2.1.0-SNAPSHOT</version> + </parent> + + <artifactId>smoke-tests</artifactId> + <packaging>pom</packaging> + <name>ActiveMQ Artemis Smoke Tests</name> + + <!-- Properties --> + <properties> + <!-- + Explicitly declaring the source encoding eliminates the following + message: [WARNING] Using platform encoding (UTF-8 actually) to copy + filtered resources, i.e. build is platform dependent! + --> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <activemq.basedir>${project.basedir}/../..</activemq.basedir> + </properties> + + <modules> + <module>replicated-flowcontrol</module> + </modules> +</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/smoke-tests/readme.md ---------------------------------------------------------------------- diff --git a/tests/smoke-tests/readme.md b/tests/smoke-tests/readme.md new file mode 100644 index 0000000..9a11bc6 --- /dev/null +++ b/tests/smoke-tests/readme.md @@ -0,0 +1,6 @@ +# Smoke tests + + +These tests are based on real servers. + +Each directory here represents a real server created with the maven plugin. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/smoke-tests/replicated-flowcontrol/pom.xml ---------------------------------------------------------------------- diff --git a/tests/smoke-tests/replicated-flowcontrol/pom.xml b/tests/smoke-tests/replicated-flowcontrol/pom.xml new file mode 100644 index 0000000..fd22c59 --- /dev/null +++ b/tests/smoke-tests/replicated-flowcontrol/pom.xml @@ -0,0 +1,203 @@ +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.activemq.tests</groupId> + <artifactId>smoke-tests</artifactId> + <version>2.1.0-SNAPSHOT</version> + </parent> + + <artifactId>replicated-flowcontrol</artifactId> + <packaging>jar</packaging> + <name>Smoke Test Replicated</name> + + <properties> + <activemq.basedir>${project.basedir}/../../../</activemq.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-core-client</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-server</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>org.apache.activemq.tests</groupId> + <artifactId>unit-tests</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>apache-artemis</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + <type>pom</type> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-jms-client</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-commons</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-commons</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-jms-server</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-ra</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-cli</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-ejb_3.0_spec</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.geronimo.components</groupId> + <artifactId>geronimo-jaspi</artifactId> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-jms_2.0_spec</artifactId> + </dependency> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging-processor</artifactId> + <scope>provided</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.apache.qpid</groupId> + <artifactId>qpid-jms-client</artifactId> + <version>${qpid.jms.version}</version> + </dependency> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + </dependency> + <dependency> + <groupId>org.jboss.logmanager</groupId> + <artifactId>jboss-logmanager</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-maven-plugin</artifactId> + <executions> + <execution> + <phase>install</phase> + <id>create0</id> + <goals> + <goal>create</goal> + </goals> + <configuration> + <!-- this makes it easier in certain envs --> + <javaOptions>-Djava.net.preferIPv4Stack=true</javaOptions> + <instance>${basedir}/target/server0</instance> + <configuration>${basedir}/target/classes/activemq/server0</configuration> + </configuration> + </execution> + <execution> + <phase>install</phase> + <id>create1</id> + <goals> + <goal>create</goal> + </goals> + <configuration> + <!-- this makes it easier in certain envs --> + <javaOptions>-Djava.net.preferIPv4Stack=true</javaOptions> + <instance>${basedir}/target/server1</instance> + <configuration>${basedir}/target/classes/activemq/server1</configuration> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.apache.activemq.examples.smoke.ha</groupId> + <artifactId>replicated-flowcontrol</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <phase>test</phase> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skipTests>${skipSmokeTests}</skipTests> + <argLine>${activemq-surefire-argline}</argLine> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml b/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml new file mode 100644 index 0000000..0e58838 --- /dev/null +++ b/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server0/broker.xml @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- +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" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> + + + + <core xmlns="urn:activemq:core"> + + <bindings-directory>./data/bindings</bindings-directory> + + <journal-directory>./data/journal</journal-directory> + + <large-messages-directory>./data/largemessages</large-messages-directory> + + <paging-directory>./data/paging</paging-directory> + + <cluster-user>exampleUser</cluster-user> + + <cluster-password>secret</cluster-password> + + <ha-policy> + <replication> + <master> + <!--we need this for auto failback--> + <check-for-live-server>true</check-for-live-server> + </master> + </replication> + </ha-policy> + + <connectors> + <connector name="netty-connector">tcp://localhost:61616</connector> + <connector name="netty-backup-connector">tcp://localhost:61617</connector> + </connectors> + + <!-- Acceptors --> + <acceptors> + <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> + </acceptors> + + <cluster-connections> + <cluster-connection name="my-cluster"> + <connector-ref>netty-connector</connector-ref> + <static-connectors> + <connector-ref>netty-backup-connector</connector-ref> + </static-connectors> + </cluster-connection> + </cluster-connections> + <!-- Other config --> + + <security-settings> + <!--security for example queue--> + <security-setting match="exampleQueue"> + <permission roles="guest" type="createDurableQueue"/> + <permission roles="guest" type="deleteDurableQueue"/> + <permission roles="guest" type="createNonDurableQueue"/> + <permission roles="guest" type="deleteNonDurableQueue"/> + <permission roles="guest" type="consume"/> + <permission roles="guest" type="send"/> + </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>true</auto-create-queues> + <auto-create-addresses>true</auto-create-addresses> + <auto-create-jms-queues>true</auto-create-jms-queues> + <auto-create-jms-topics>true</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>200MB</max-size-bytes> + <page-size-bytes>100MB</page-size-bytes> + + <message-counter-history-day-limit>10</message-counter-history-day-limit> + <address-full-policy>PAGE</address-full-policy> + <auto-create-queues>true</auto-create-queues> + <auto-create-addresses>true</auto-create-addresses> + <auto-create-jms-queues>true</auto-create-jms-queues> + <auto-create-jms-topics>true</auto-create-jms-topics> + </address-setting> + </address-settings> + + <addresses> + <address name="exampleQueue"> + <anycast> + <queue name="exampleQueue"/> + </anycast> + </address> + </addresses> + </core> +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml b/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml new file mode 100644 index 0000000..e67613d --- /dev/null +++ b/tests/smoke-tests/replicated-flowcontrol/src/main/resources/activemq/server1/broker.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- +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" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> + + + + <core xmlns="urn:activemq:core"> + + <bindings-directory>./data/bindings</bindings-directory> + + <journal-directory>./data/journal</journal-directory> + + <large-messages-directory>./data/largemessages</large-messages-directory> + + <paging-directory>./data/paging</paging-directory> + + <cluster-user>exampleUser</cluster-user> + + <cluster-password>secret</cluster-password> + + <ha-policy> + <replication> + <slave> + <allow-failback>true</allow-failback> + <!-- not needed but tells the backup not to restart after failback as there will be > 0 backups saved --> + <max-saved-replicated-journals-size>0</max-saved-replicated-journals-size> + </slave> + </replication> + </ha-policy> + + <!-- Connectors --> + <connectors> + <connector name="netty-live-connector">tcp://localhost:61616</connector> + <connector name="netty-connector">tcp://localhost:61617</connector> + </connectors> + + <!-- Acceptors --> + <acceptors> + <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> + </acceptors> + + <cluster-connections> + <cluster-connection name="my-cluster"> + <connector-ref>netty-connector</connector-ref> + <static-connectors> + <connector-ref>netty-live-connector</connector-ref> + </static-connectors> + </cluster-connection> + </cluster-connections> + <!-- Other config --> + + <security-settings> + <!--security for example queue--> + <security-setting match="exampleQueue"> + <permission roles="guest" type="createDurableQueue"/> + <permission roles="guest" type="deleteDurableQueue"/> + <permission roles="guest" type="createNonDurableQueue"/> + <permission roles="guest" type="deleteNonDurableQueue"/> + <permission roles="guest" type="consume"/> + <permission roles="guest" type="send"/> + </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>true</auto-create-queues> + <auto-create-addresses>true</auto-create-addresses> + <auto-create-jms-queues>true</auto-create-jms-queues> + <auto-create-jms-topics>true</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>200MB</max-size-bytes> + <page-size-bytes>100MB</page-size-bytes> + + <message-counter-history-day-limit>10</message-counter-history-day-limit> + <address-full-policy>PAGE</address-full-policy> + <auto-create-queues>true</auto-create-queues> + <auto-create-addresses>true</auto-create-addresses> + <auto-create-jms-queues>true</auto-create-jms-queues> + <auto-create-jms-topics>true</auto-create-jms-topics> + </address-setting> + </address-settings> + + <addresses> + <address name="exampleQueue"> + <anycast> + <queue name="exampleQueue"/> + </anycast> + </address> + </addresses> + </core> +</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dd27fb58/tests/smoke-tests/replicated-flowcontrol/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/ReplicatedFailbackSmokeTest.java ---------------------------------------------------------------------- diff --git a/tests/smoke-tests/replicated-flowcontrol/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/ReplicatedFailbackSmokeTest.java b/tests/smoke-tests/replicated-flowcontrol/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/ReplicatedFailbackSmokeTest.java new file mode 100644 index 0000000..9e81851 --- /dev/null +++ b/tests/smoke-tests/replicated-flowcontrol/src/test/java/org/apache/activemq/artemis/tests/smoke/replicationflow/ReplicatedFailbackSmokeTest.java @@ -0,0 +1,268 @@ +/* + * 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.smoke.replicationflow; + +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.io.File; +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.util.ServerUtil; +import org.apache.activemq.artemis.utils.ReusableLatch; +import org.apache.qpid.jms.JmsConnectionFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +public class ReplicatedFailbackSmokeTest extends ActiveMQTestBase { + + ArrayList<Consumer> consumers = new ArrayList<>(); + + String server0Location = System.getProperty("basedir") + "/target/server0"; + String server1Location = System.getProperty("basedir") + "/target/server1"; + + private static Process server0; + + private static Process server1; + + static final int NUM_MESSAGES = 300_000; + static final int START_CONSUMERS = 100_000; + static final int START_SERVER = 101_000; + static final int NUMBER_OF_CONSUMERS = 10; + static final ReusableLatch latch = new ReusableLatch(NUM_MESSAGES); + + static AtomicBoolean running = new AtomicBoolean(true); + static AtomicInteger totalConsumed = new AtomicInteger(0); + + + @Before + public void cleanupTests() throws Exception { + deleteDirectory(new File(server0Location, "data")); + deleteDirectory(new File(server1Location, "data")); + disableCheckThread(); + } + + @After + public void after() throws Exception { + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); + } + + @Test + public void testPageWhileSynchronizingReplica() throws Exception { + internalTest(false); + } + + @Ignore // need to fix this before I can let it running + @Test + public void testPageWhileSyncFailover() throws Exception { + internalTest(true); + } + + private void internalTest(boolean failover) throws Exception { + + int KILL_SERVER = failover ? 150_000 : -1; + + Connection connection = null; + + try { + server0 = ServerUtil.startServer(server0Location, ReplicatedFailbackSmokeTest.class.getSimpleName() + "0", 0, 30000); + + ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); + + connection = connectionFactory.createConnection(); + + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + + Queue queue = session.createQueue("exampleQueue"); + + MessageProducer producer = session.createProducer(queue); + + BytesMessage bytesMessage = session.createBytesMessage(); + bytesMessage.writeBytes(new byte[20 * 1024]); + + for (int i = 0; i < NUM_MESSAGES; i++) { + + producer.send(bytesMessage); + if (i % 1000 == 0) { + System.out.println("Sent " + i + " messages, consumed=" + totalConsumed.get()); + session.commit(); + } + + if (i == START_CONSUMERS) { + System.out.println("Starting consumers"); + startConsumers(!failover); // if failover, no AMQP + } + + if (KILL_SERVER >= 0 && i == KILL_SERVER) { + session.commit(); + System.out.println("Killing server"); + ServerUtil.killServer(server0); + Thread.sleep(2000); + connection.close(); + connection = connectionFactory.createConnection(); + + session = connection.createSession(true, Session.SESSION_TRANSACTED); + + queue = session.createQueue("exampleQueue"); + + producer = session.createProducer(queue); + + } + + if (i == START_SERVER) { + System.out.println("Starting extra server"); + server1 = ServerUtil.startServer(server1Location, ReplicatedFailbackSmokeTest.class.getSimpleName() + "1", 1, 10000); + } + + } + + session.commit(); + + System.out.println("Awaiting all consumers to finish"); + while (!latch.await(5, TimeUnit.SECONDS)) { + System.out.println("Missing " + latch.getCount() + ", totalConsumed = " + totalConsumed); + } + + } finally { + + running.set(false); + + if (connection != null) { + connection.close(); + } + + for (Consumer consumer : consumers) { + consumer.interrupt(); + consumer.join(); + } + } + } + + void startConsumers(boolean useAMQP) { + for (int i = 0; i < NUMBER_OF_CONSUMERS; i++) { + Consumer consumer = new Consumer(useAMQP && i % 2 == 0, i); + consumer.start(); + consumers.add(consumer); + } + } + + static class Consumer extends Thread { + + ConnectionFactory factory; + Connection connection; + Session session; + Queue queue; + MessageConsumer consumer; + int count = 0; + int totalCount = 0; + + final int consumerID; + + final boolean amqp; + + Consumer(boolean amqp, int id) { + super("amqp=" + amqp + ", id=" + id); + this.amqp = amqp; + this.consumerID = id; + } + + @Override + public String toString() { + return "Consumer " + consumerID + ", amqp::" + amqp; + } + + void connect() throws Exception { + if (connection != null) { + connection.close(); + } + count = 0; + if (amqp) { + factory = new JmsConnectionFactory("amqp://localhost:61616"); + } else { + factory = new ActiveMQConnectionFactory(); // using default is fine here + } + + connection = factory.createConnection(); + session = connection.createSession(true, Session.SESSION_TRANSACTED); + queue = session.createQueue("exampleQueue"); + consumer = session.createConsumer(queue); + connection.start(); + } + + @Override + public void run() { + try { + while (running.get()) { + try { + if (connection == null) { + connect(); + } + + totalCount++; + if (totalCount % 1000 == 0) { + System.out.println(this + " received " + totalCount + " messages"); + } + + BytesMessage message = (BytesMessage) consumer.receive(5000); + if (message == null) { + System.out.println("Consumer " + this + " couldn't get a message"); + if (count > 0) { + session.commit(); + latch.countDown(count); + totalConsumed.addAndGet(count); + count = 0; + } + } else { + count++; + + if (count == 100) { + session.commit(); + latch.countDown(count); + totalConsumed.addAndGet(count); + count = 0; + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + } finally { + try { + connection.close(); + } catch (Throwable ignored) { + } + } + + System.out.println("Giving up the loop " + this); + + } + + } +}
