NO-JIRA Tweak RedeployTest

1) Remove use of deprecated EmbeddedJMS.
2) Change test config to use static clustering as discovery may not work
in some CI environments.
This commit is contained in:
Justin Bertram 2018-08-17 14:06:47 -05:00 committed by Clebert Suconic
parent 581ee5bc46
commit e6dddf8231
5 changed files with 71 additions and 128 deletions

View File

@ -39,7 +39,6 @@ import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; 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.junit.Wait;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ReusableLatch; import org.apache.activemq.artemis.utils.ReusableLatch;
@ -104,8 +103,8 @@ public class RedeployTest extends ActiveMQTestBase {
@Test @Test
public void testRedeployWithFailover() throws Exception { public void testRedeployWithFailover() throws Exception {
EmbeddedJMS live = new EmbeddedJMS(); EmbeddedActiveMQ live = new EmbeddedActiveMQ();
EmbeddedJMS backup = new EmbeddedJMS(); EmbeddedActiveMQ backup = new EmbeddedActiveMQ();
try { try {
// set these system properties to use in the relevant broker.xml files // set these system properties to use in the relevant broker.xml files
@ -129,7 +128,7 @@ public class RedeployTest extends ActiveMQTestBase {
backup.setConfigResourcePath(backupBrokerXML.toUri().toString()); backup.setConfigResourcePath(backupBrokerXML.toUri().toString());
backup.start(); backup.start();
Wait.waitFor(() -> backup.getActiveMQServer().isReplicaSync(), 10000, 200); assertTrue(Wait.waitFor(() -> backup.getActiveMQServer().isReplicaSync(), 15000, 200));
final ReusableLatch liveReloadLatch = new ReusableLatch(1); final ReusableLatch liveReloadLatch = new ReusableLatch(1);
Runnable liveTick = () -> liveReloadLatch.countDown(); Runnable liveTick = () -> liveReloadLatch.countDown();
@ -163,7 +162,7 @@ public class RedeployTest extends ActiveMQTestBase {
live.stop(); live.stop();
Wait.waitFor(() -> (backup.getActiveMQServer().isActive()), 5000, 100); assertTrue(Wait.waitFor(() -> (backup.getActiveMQServer().isActive()), 5000, 100));
factory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61617"); factory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61617");
try (Connection connection = factory.createConnection()) { try (Connection connection = factory.createConnection()) {
@ -281,91 +280,91 @@ public class RedeployTest extends ActiveMQTestBase {
URL url2 = RedeployTest.class.getClassLoader().getResource("reload-changed.xml"); URL url2 = RedeployTest.class.getClassLoader().getResource("reload-changed.xml");
Files.copy(url1.openStream(), brokerXML); Files.copy(url1.openStream(), brokerXML);
EmbeddedJMS embeddedJMS = new EmbeddedJMS(); EmbeddedActiveMQ embeddedActiveMQ = new EmbeddedActiveMQ();
embeddedJMS.setConfigResourcePath(brokerXML.toUri().toString()); embeddedActiveMQ.setConfigResourcePath(brokerXML.toUri().toString());
embeddedJMS.start(); embeddedActiveMQ.start();
final ReusableLatch latch = new ReusableLatch(1); final ReusableLatch latch = new ReusableLatch(1);
Runnable tick = latch::countDown; Runnable tick = latch::countDown;
embeddedJMS.getActiveMQServer().getReloadManager().setTick(tick); embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
try { try {
latch.await(10, TimeUnit.SECONDS); latch.await(10, TimeUnit.SECONDS);
Assert.assertEquals(getSecurityRoles(embeddedJMS, "security_address").size(), 1); Assert.assertEquals(getSecurityRoles(embeddedActiveMQ, "security_address").size(), 1);
Assert.assertEquals(getSecurityRoles(embeddedJMS, "security_address").iterator().next().getName(), "b"); Assert.assertEquals(getSecurityRoles(embeddedActiveMQ, "security_address").iterator().next().getName(), "b");
Assert.assertEquals(getAddressSettings(embeddedJMS, "address_settings_address").getDeadLetterAddress(), SimpleString.toSimpleString("OriginalDLQ")); Assert.assertEquals(getAddressSettings(embeddedActiveMQ, "address_settings_address").getDeadLetterAddress(), SimpleString.toSimpleString("OriginalDLQ"));
Assert.assertEquals(getAddressSettings(embeddedJMS, "address_settings_address").getExpiryAddress(), SimpleString.toSimpleString("OriginalExpiryQueue")); Assert.assertEquals(getAddressSettings(embeddedActiveMQ, "address_settings_address").getExpiryAddress(), SimpleString.toSimpleString("OriginalExpiryQueue"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_address_removal_no_queue")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal_no_queue"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_address_removal")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_removal")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_removal"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_1")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_2")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_change"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_change").contains("config_test_queue_change_queue"));
Assert.assertEquals(10, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers()); Assert.assertEquals(10, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").getMaxConsumers());
Assert.assertEquals(false, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers()); Assert.assertEquals(false, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").isPurgeOnNoConsumers());
Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING); Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING);
brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000); brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
latch.setCount(1); latch.setCount(1);
embeddedJMS.getActiveMQServer().getReloadManager().setTick(tick); embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick);
latch.await(10, TimeUnit.SECONDS); latch.await(10, TimeUnit.SECONDS);
//Assert that the security settings change applied //Assert that the security settings change applied
Assert.assertEquals(getSecurityRoles(embeddedJMS, "security_address").size(), 1); Assert.assertEquals(getSecurityRoles(embeddedActiveMQ, "security_address").size(), 1);
Assert.assertEquals(getSecurityRoles(embeddedJMS, "security_address").iterator().next().getName(), "c"); Assert.assertEquals(getSecurityRoles(embeddedActiveMQ, "security_address").iterator().next().getName(), "c");
//Assert that the address settings change applied //Assert that the address settings change applied
Assert.assertEquals(getAddressSettings(embeddedJMS, "address_settings_address").getDeadLetterAddress(), SimpleString.toSimpleString("NewDLQ")); Assert.assertEquals(getAddressSettings(embeddedActiveMQ, "address_settings_address").getDeadLetterAddress(), SimpleString.toSimpleString("NewDLQ"));
Assert.assertEquals(getAddressSettings(embeddedJMS, "address_settings_address").getExpiryAddress(), SimpleString.toSimpleString("NewExpiryQueue")); Assert.assertEquals(getAddressSettings(embeddedActiveMQ, "address_settings_address").getExpiryAddress(), SimpleString.toSimpleString("NewExpiryQueue"));
//Assert the address and queue changes applied //Assert the address and queue changes applied
Assert.assertNull(getAddressInfo(embeddedJMS, "config_test_address_removal_no_queue")); Assert.assertNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal_no_queue"));
Assert.assertNull(getAddressInfo(embeddedJMS, "config_test_address_removal")); Assert.assertNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_removal")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_removal"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_1")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
Assert.assertFalse(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_2")); Assert.assertFalse(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_change"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_change").contains("config_test_queue_change_queue"));
Assert.assertEquals(1, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers()); Assert.assertEquals(1, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").getMaxConsumers());
Assert.assertEquals(true, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers()); Assert.assertEquals(true, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").isPurgeOnNoConsumers());
} finally { } finally {
embeddedJMS.stop(); embeddedActiveMQ.stop();
} }
try { try {
embeddedJMS.start(); embeddedActiveMQ.start();
//Assert that the security settings changes persist a stop and start server (e.g. like what occurs if network health check stops the node), but JVM remains up. //Assert that the security settings changes persist a stop and start server (e.g. like what occurs if network health check stops the node), but JVM remains up.
Assert.assertEquals(getSecurityRoles(embeddedJMS, "security_address").size(), 1); Assert.assertEquals(getSecurityRoles(embeddedActiveMQ, "security_address").size(), 1);
Assert.assertEquals(getSecurityRoles(embeddedJMS, "security_address").iterator().next().getName(), "c"); Assert.assertEquals(getSecurityRoles(embeddedActiveMQ, "security_address").iterator().next().getName(), "c");
//Assert that the address settings changes persist a stop and start server (e.g. like what occurs if network health check stops the node), but JVM remains up. //Assert that the address settings changes persist a stop and start server (e.g. like what occurs if network health check stops the node), but JVM remains up.
Assert.assertEquals(getAddressSettings(embeddedJMS, "address_settings_address").getDeadLetterAddress(), SimpleString.toSimpleString("NewDLQ")); Assert.assertEquals(getAddressSettings(embeddedActiveMQ, "address_settings_address").getDeadLetterAddress(), SimpleString.toSimpleString("NewDLQ"));
Assert.assertEquals(getAddressSettings(embeddedJMS, "address_settings_address").getExpiryAddress(), SimpleString.toSimpleString("NewExpiryQueue")); Assert.assertEquals(getAddressSettings(embeddedActiveMQ, "address_settings_address").getExpiryAddress(), SimpleString.toSimpleString("NewExpiryQueue"));
//Assert that the address and queue changes persist a stop and start server (e.g. like what occurs if network health check stops the node), but JVM remains up. //Assert that the address and queue changes persist a stop and start server (e.g. like what occurs if network health check stops the node), but JVM remains up.
Assert.assertNull(getAddressInfo(embeddedJMS, "config_test_address_removal_no_queue")); Assert.assertNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal_no_queue"));
Assert.assertNull(getAddressInfo(embeddedJMS, "config_test_address_removal")); Assert.assertNull(getAddressInfo(embeddedActiveMQ, "config_test_address_removal"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_removal")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_removal"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_1")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_1"));
Assert.assertFalse(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_removal").contains("config_test_queue_removal_queue_2")); Assert.assertFalse(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_removal").contains("config_test_queue_removal_queue_2"));
Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change")); Assert.assertNotNull(getAddressInfo(embeddedActiveMQ, "config_test_queue_change"));
Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue")); Assert.assertTrue(listQueuesNamesForAddress(embeddedActiveMQ, "config_test_queue_change").contains("config_test_queue_change_queue"));
Assert.assertEquals(1, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers()); Assert.assertEquals(1, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").getMaxConsumers());
Assert.assertEquals(true, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers()); Assert.assertEquals(true, getQueue(embeddedActiveMQ, "config_test_queue_change_queue").isPurgeOnNoConsumers());
} finally { } finally {
embeddedJMS.stop(); embeddedActiveMQ.stop();
} }
} }

View File

@ -39,11 +39,12 @@ under the License.
<large-messages-directory>${backup-data-dir}/large-messages</large-messages-directory> <large-messages-directory>${backup-data-dir}/large-messages</large-messages-directory>
<acceptors> <acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61617</acceptor> <acceptor name="artemis">tcp://127.0.0.1:61617</acceptor>
</acceptors> </acceptors>
<connectors> <connectors>
<connector name="artemis">tcp://127.0.0.1:61617</connector> <connector name="artemis">tcp://127.0.0.1:61617</connector>
<connector name="other">tcp://127.0.0.1:61616</connector>
</connectors> </connectors>
<ha-policy> <ha-policy>
@ -54,29 +55,14 @@ under the License.
</replication> </replication>
</ha-policy> </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-connections>
<cluster-connection name="my-cluster"> <cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref> <connector-ref>artemis</connector-ref>
<message-load-balancing>STRICT</message-load-balancing> <message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops> <max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/> <static-connectors>
<connector-ref>other</connector-ref>
</static-connectors>
</cluster-connection> </cluster-connection>
</cluster-connections> </cluster-connections>

View File

@ -39,11 +39,12 @@ under the License.
<large-messages-directory>${backup-data-dir}/large-messages</large-messages-directory> <large-messages-directory>${backup-data-dir}/large-messages</large-messages-directory>
<acceptors> <acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61617</acceptor> <acceptor name="artemis">tcp://127.0.0.1:61617</acceptor>
</acceptors> </acceptors>
<connectors> <connectors>
<connector name="artemis">tcp://127.0.0.1:61617</connector> <connector name="artemis">tcp://127.0.0.1:61617</connector>
<connector name="other">tcp://127.0.0.1:61616</connector>
</connectors> </connectors>
<ha-policy> <ha-policy>
@ -54,29 +55,14 @@ under the License.
</replication> </replication>
</ha-policy> </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-connections>
<cluster-connection name="my-cluster"> <cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref> <connector-ref>artemis</connector-ref>
<message-load-balancing>STRICT</message-load-balancing> <message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops> <max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/> <static-connectors>
<connector-ref>other</connector-ref>
</static-connectors>
</cluster-connection> </cluster-connection>
</cluster-connections> </cluster-connections>

View File

@ -39,11 +39,12 @@ under the License.
<large-messages-directory>${live-data-dir}/large-messages</large-messages-directory> <large-messages-directory>${live-data-dir}/large-messages</large-messages-directory>
<acceptors> <acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61616</acceptor> <acceptor name="artemis">tcp://127.0.0.1:61616</acceptor>
</acceptors> </acceptors>
<connectors> <connectors>
<connector name="artemis">tcp://127.0.0.1:61616</connector> <connector name="artemis">tcp://127.0.0.1:61616</connector>
<connector name="other">tcp://127.0.0.1:61617</connector>
</connectors> </connectors>
<ha-policy> <ha-policy>
@ -54,29 +55,14 @@ under the License.
</replication> </replication>
</ha-policy> </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-connections>
<cluster-connection name="my-cluster"> <cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref> <connector-ref>artemis</connector-ref>
<message-load-balancing>STRICT</message-load-balancing> <message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops> <max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/> <static-connectors>
<connector-ref>other</connector-ref>
</static-connectors>
</cluster-connection> </cluster-connection>
</cluster-connections> </cluster-connections>

View File

@ -39,11 +39,12 @@ under the License.
<large-messages-directory>${live-data-dir}/large-messages</large-messages-directory> <large-messages-directory>${live-data-dir}/large-messages</large-messages-directory>
<acceptors> <acceptors>
<acceptor name="artemis">tcp://0.0.0.0:61616</acceptor> <acceptor name="artemis">tcp://127.0.0.1:61616</acceptor>
</acceptors> </acceptors>
<connectors> <connectors>
<connector name="artemis">tcp://127.0.0.1:61616</connector> <connector name="artemis">tcp://127.0.0.1:61616</connector>
<connector name="other">tcp://127.0.0.1:61617</connector>
</connectors> </connectors>
<ha-policy> <ha-policy>
@ -54,29 +55,14 @@ under the License.
</replication> </replication>
</ha-policy> </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-connections>
<cluster-connection name="my-cluster"> <cluster-connection name="my-cluster">
<connector-ref>artemis</connector-ref> <connector-ref>artemis</connector-ref>
<message-load-balancing>STRICT</message-load-balancing> <message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops> <max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/> <static-connectors>
<connector-ref>other</connector-ref>
</static-connectors>
</cluster-connection> </cluster-connection>
</cluster-connections> </cluster-connections>