activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1659 add test for reload on inactive slave
Date Thu, 03 May 2018 16:22:35 GMT
ARTEMIS-1659 add test for reload on inactive slave


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ed623e0a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ed623e0a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ed623e0a

Branch: refs/heads/master
Commit: ed623e0afc7ee49da5504c5d3037b730b168e773
Parents: 85b8af6
Author: Justin Bertram <jbertram@apache.org>
Authored: Tue May 1 15:03:52 2018 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu May 3 12:12:51 2018 -0400

----------------------------------------------------------------------
 .../tests/integration/jms/RedeployTest.java     | 83 +++++++++++++++++
 .../test/resources/reload-backup-changed.xml    | 96 ++++++++++++++++++++
 .../test/resources/reload-backup-original.xml   | 91 +++++++++++++++++++
 .../src/test/resources/reload-live-changed.xml  | 96 ++++++++++++++++++++
 .../src/test/resources/reload-live-original.xml | 91 +++++++++++++++++++
 5 files changed, 457 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ed623e0a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
index f216c2a..2ba7f3d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
@@ -39,6 +39,7 @@ import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.artemis.junit.Wait;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.utils.ReusableLatch;
 import org.junit.Assert;
@@ -100,6 +101,88 @@ public class RedeployTest extends ActiveMQTestBase {
       }
    }
 
+   @Test
+   public void testRedeployWithFailover() throws Exception {
+      EmbeddedJMS live = new EmbeddedJMS();
+      EmbeddedJMS backup = new EmbeddedJMS();
+
+      try {
+         // set these system properties to use in the relevant broker.xml files
+         System.setProperty("live-data-dir", getTestDirfile().toPath() + "/redeploy-live-data");
+         System.setProperty("backup-data-dir", getTestDirfile().toPath() + "/redeploy-backup-data");
+
+         Path liveBrokerXML = getTestDirfile().toPath().resolve("live.xml");
+         Path backupBrokerXML = getTestDirfile().toPath().resolve("backup.xml");
+         URL url1 = RedeployTest.class.getClassLoader().getResource("reload-live-original.xml");
+         URL url2 = RedeployTest.class.getClassLoader().getResource("reload-live-changed.xml");
+         URL url3 = RedeployTest.class.getClassLoader().getResource("reload-backup-original.xml");
+         URL url4 = RedeployTest.class.getClassLoader().getResource("reload-backup-changed.xml");
+         Files.copy(url1.openStream(), liveBrokerXML);
+         Files.copy(url3.openStream(), backupBrokerXML);
+
+         live.setConfigResourcePath(liveBrokerXML.toUri().toString());
+         live.start();
+
+         waitForServerToStart(live.getActiveMQServer());
+
+         backup.setConfigResourcePath(backupBrokerXML.toUri().toString());
+         backup.start();
+
+         Wait.waitFor(() -> backup.getActiveMQServer().isReplicaSync(), 10000, 200);
+
+         final ReusableLatch liveReloadLatch = new ReusableLatch(1);
+         Runnable liveTick = () -> liveReloadLatch.countDown();
+         live.getActiveMQServer().getReloadManager().setTick(liveTick);
+
+         final ReusableLatch backupReloadTickLatch = new ReusableLatch(1);
+         Runnable backupTick = () -> backupReloadTickLatch.countDown();
+         backup.getActiveMQServer().getReloadManager().setTick(backupTick);
+
+         liveReloadLatch.await(10, TimeUnit.SECONDS);
+         Files.copy(url2.openStream(), liveBrokerXML, StandardCopyOption.REPLACE_EXISTING);
+         liveBrokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
+         liveReloadLatch.countUp();
+         live.getActiveMQServer().getReloadManager().setTick(liveTick);
+         liveReloadLatch.await(10, TimeUnit.SECONDS);
+
+         backupReloadTickLatch.await(10, TimeUnit.SECONDS);
+         Files.copy(url4.openStream(), backupBrokerXML, StandardCopyOption.REPLACE_EXISTING);
+         backupBrokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
+         backupReloadTickLatch.countUp();
+         backup.getActiveMQServer().getReloadManager().setTick(backupTick);
+         backupReloadTickLatch.await(10, TimeUnit.SECONDS);
+
+         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
+         try (Connection connection = factory.createConnection()) {
+            Session session = connection.createSession();
+            Queue queue = session.createQueue("myQueue2");
+            MessageProducer producer = session.createProducer(queue);
+            producer.send(session.createTextMessage("text"));
+         }
+
+         live.stop();
+
+         Wait.waitFor(() -> (backup.getActiveMQServer().isActive()), 5000, 100);
+
+         factory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61617");
+         try (Connection connection = factory.createConnection()) {
+            Session session = connection.createSession();
+            Queue queue = session.createQueue("myQueue2");
+            MessageProducer producer = session.createProducer(queue);
+            producer.send(session.createTextMessage("text"));
+            connection.start();
+            MessageConsumer consumer = session.createConsumer(session.createQueue("myQueue2"));
+            Assert.assertNotNull("Queue wasn't deployed accordingly", consumer.receive(5000));
+            Assert.assertNotNull(consumer.receive(5000));
+         }
+      } finally {
+         live.stop();
+         backup.stop();
+         System.clearProperty("live-data-dir");
+         System.clearProperty("backup-data-dir");
+      }
+   }
+
    private boolean tryConsume() throws JMSException {
       try (ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
            Connection connection = factory.createConnection();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ed623e0a/tests/integration-tests/src/test/resources/reload-backup-changed.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-backup-changed.xml b/tests/integration-tests/src/test/resources/reload-backup-changed.xml
new file mode 100644
index 0000000..101871b
--- /dev/null
+++ b/tests/integration-tests/src/test/resources/reload-backup-changed.xml
@@ -0,0 +1,96 @@
+<?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"
+               xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+
+   <core xmlns="urn:activemq:core">
+
+      <name>0.0.0.0</name>
+
+      <configuration-file-refresh-period>100</configuration-file-refresh-period>
+
+      <security-enabled>false</security-enabled>
+
+      <paging-directory>${backup-data-dir}/paging</paging-directory>
+
+      <bindings-directory>${backup-data-dir}/bindings</bindings-directory>
+
+      <journal-directory>${backup-data-dir}/journal</journal-directory>
+
+      <large-messages-directory>${backup-data-dir}/large-messages</large-messages-directory>
+
+      <acceptors>
+         <acceptor name="artemis">tcp://0.0.0.0:61617</acceptor>
+      </acceptors>
+
+      <connectors>
+         <connector name="artemis">tcp://127.0.0.1:61617</connector>
+      </connectors>
+
+      <ha-policy>
+         <replication>
+            <slave>
+               <allow-failback>true</allow-failback>
+            </slave>
+         </replication>
+      </ha-policy>
+
+      <broadcast-groups>
+         <broadcast-group name="bg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <broadcast-period>5000</broadcast-period>
+            <connector-ref>artemis</connector-ref>
+         </broadcast-group>
+      </broadcast-groups>
+
+      <discovery-groups>
+         <discovery-group name="dg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <refresh-timeout>10000</refresh-timeout>
+         </discovery-group>
+      </discovery-groups>
+
+      <cluster-connections>
+         <cluster-connection name="my-cluster">
+            <connector-ref>artemis</connector-ref>
+            <message-load-balancing>STRICT</message-load-balancing>
+            <max-hops>1</max-hops>
+            <discovery-group-ref discovery-group-name="dg-group1"/>
+         </cluster-connection>
+      </cluster-connections>
+
+      <addresses>
+         <address name="myQueue">
+            <anycast>
+               <queue name="myQueue"/>
+            </anycast>
+         </address>
+         <address name="myQueue2">
+            <anycast>
+               <queue name="myQueue2"/>
+            </anycast>
+         </address>
+      </addresses>
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ed623e0a/tests/integration-tests/src/test/resources/reload-backup-original.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-backup-original.xml b/tests/integration-tests/src/test/resources/reload-backup-original.xml
new file mode 100644
index 0000000..0061be0
--- /dev/null
+++ b/tests/integration-tests/src/test/resources/reload-backup-original.xml
@@ -0,0 +1,91 @@
+<?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"
+               xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+
+   <core xmlns="urn:activemq:core">
+
+      <name>0.0.0.0</name>
+
+      <configuration-file-refresh-period>100</configuration-file-refresh-period>
+
+      <security-enabled>false</security-enabled>
+
+      <paging-directory>${backup-data-dir}/paging</paging-directory>
+
+      <bindings-directory>${backup-data-dir}/bindings</bindings-directory>
+
+      <journal-directory>${backup-data-dir}/journal</journal-directory>
+
+      <large-messages-directory>${backup-data-dir}/large-messages</large-messages-directory>
+
+      <acceptors>
+         <acceptor name="artemis">tcp://0.0.0.0:61617</acceptor>
+      </acceptors>
+
+      <connectors>
+         <connector name="artemis">tcp://127.0.0.1:61617</connector>
+      </connectors>
+
+      <ha-policy>
+         <replication>
+            <slave>
+               <allow-failback>true</allow-failback>
+            </slave>
+         </replication>
+      </ha-policy>
+
+      <broadcast-groups>
+         <broadcast-group name="bg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <broadcast-period>5000</broadcast-period>
+            <connector-ref>artemis</connector-ref>
+         </broadcast-group>
+      </broadcast-groups>
+
+      <discovery-groups>
+         <discovery-group name="dg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <refresh-timeout>10000</refresh-timeout>
+         </discovery-group>
+      </discovery-groups>
+
+      <cluster-connections>
+         <cluster-connection name="my-cluster">
+            <connector-ref>artemis</connector-ref>
+            <message-load-balancing>STRICT</message-load-balancing>
+            <max-hops>1</max-hops>
+            <discovery-group-ref discovery-group-name="dg-group1"/>
+         </cluster-connection>
+      </cluster-connections>
+
+      <addresses>
+         <address name="myQueue">
+            <anycast>
+               <queue name="myQueue"/>
+            </anycast>
+         </address>
+      </addresses>
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ed623e0a/tests/integration-tests/src/test/resources/reload-live-changed.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-live-changed.xml b/tests/integration-tests/src/test/resources/reload-live-changed.xml
new file mode 100644
index 0000000..74a2ef2
--- /dev/null
+++ b/tests/integration-tests/src/test/resources/reload-live-changed.xml
@@ -0,0 +1,96 @@
+<?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"
+               xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+
+   <core xmlns="urn:activemq:core">
+
+      <name>0.0.0.0</name>
+
+      <configuration-file-refresh-period>100</configuration-file-refresh-period>
+
+      <security-enabled>false</security-enabled>
+
+      <paging-directory>${live-data-dir}/paging</paging-directory>
+
+      <bindings-directory>${live-data-dir}/bindings</bindings-directory>
+
+      <journal-directory>${live-data-dir}/journal</journal-directory>
+
+      <large-messages-directory>${live-data-dir}/large-messages</large-messages-directory>
+
+      <acceptors>
+         <acceptor name="artemis">tcp://0.0.0.0:61616</acceptor>
+      </acceptors>
+
+      <connectors>
+         <connector name="artemis">tcp://127.0.0.1:61616</connector>
+      </connectors>
+
+      <ha-policy>
+         <replication>
+            <master>
+               <check-for-live-server>true</check-for-live-server>
+            </master>
+         </replication>
+      </ha-policy>
+
+      <broadcast-groups>
+         <broadcast-group name="bg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <broadcast-period>5000</broadcast-period>
+            <connector-ref>artemis</connector-ref>
+         </broadcast-group>
+      </broadcast-groups>
+
+      <discovery-groups>
+         <discovery-group name="dg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <refresh-timeout>10000</refresh-timeout>
+         </discovery-group>
+      </discovery-groups>
+
+      <cluster-connections>
+         <cluster-connection name="my-cluster">
+            <connector-ref>artemis</connector-ref>
+            <message-load-balancing>STRICT</message-load-balancing>
+            <max-hops>1</max-hops>
+            <discovery-group-ref discovery-group-name="dg-group1"/>
+         </cluster-connection>
+      </cluster-connections>
+
+      <addresses>
+         <address name="myQueue">
+            <anycast>
+               <queue name="myQueue"/>
+            </anycast>
+         </address>
+         <address name="myQueue2">
+            <anycast>
+               <queue name="myQueue2"/>
+            </anycast>
+         </address>
+      </addresses>
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ed623e0a/tests/integration-tests/src/test/resources/reload-live-original.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-live-original.xml b/tests/integration-tests/src/test/resources/reload-live-original.xml
new file mode 100644
index 0000000..1cbfe75
--- /dev/null
+++ b/tests/integration-tests/src/test/resources/reload-live-original.xml
@@ -0,0 +1,91 @@
+<?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"
+               xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+
+   <core xmlns="urn:activemq:core">
+
+      <name>0.0.0.0</name>
+
+      <configuration-file-refresh-period>100</configuration-file-refresh-period>
+
+      <security-enabled>false</security-enabled>
+
+      <paging-directory>${live-data-dir}/paging</paging-directory>
+
+      <bindings-directory>${live-data-dir}/bindings</bindings-directory>
+
+      <journal-directory>${live-data-dir}/journal</journal-directory>
+
+      <large-messages-directory>${live-data-dir}/large-messages</large-messages-directory>
+
+      <acceptors>
+         <acceptor name="artemis">tcp://0.0.0.0:61616</acceptor>
+      </acceptors>
+
+      <connectors>
+         <connector name="artemis">tcp://127.0.0.1:61616</connector>
+      </connectors>
+
+      <ha-policy>
+         <replication>
+            <master>
+               <check-for-live-server>true</check-for-live-server>
+            </master>
+         </replication>
+      </ha-policy>
+
+      <broadcast-groups>
+         <broadcast-group name="bg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <broadcast-period>5000</broadcast-period>
+            <connector-ref>artemis</connector-ref>
+         </broadcast-group>
+      </broadcast-groups>
+
+      <discovery-groups>
+         <discovery-group name="dg-group1">
+            <group-address>231.7.7.7</group-address>
+            <group-port>9876</group-port>
+            <refresh-timeout>10000</refresh-timeout>
+         </discovery-group>
+      </discovery-groups>
+
+      <cluster-connections>
+         <cluster-connection name="my-cluster">
+            <connector-ref>artemis</connector-ref>
+            <message-load-balancing>STRICT</message-load-balancing>
+            <max-hops>1</max-hops>
+            <discovery-group-ref discovery-group-name="dg-group1"/>
+         </cluster-connection>
+      </cluster-connections>
+
+      <addresses>
+         <address name="myQueue">
+            <anycast>
+               <queue name="myQueue"/>
+            </anycast>
+         </address>
+      </addresses>
+   </core>
+</configuration>


Mime
View raw message