activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/3] activemq-artemis git commit: ARTEMIS-1781 Connector parameters not backward compatible (Adding test)
Date Tue, 17 Apr 2018 15:42:55 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master e94e5b003 -> 9247eaadc


ARTEMIS-1781 Connector parameters not backward compatible (Adding test)


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

Branch: refs/heads/master
Commit: 284c620f55d36d711c3757589e86699be8ed3a96
Parents: e94e5b0
Author: Tomas Hofman <thofman@redhat.com>
Authored: Tue Apr 17 11:27:11 2018 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Apr 17 11:37:38 2018 -0400

----------------------------------------------------------------------
 .../hqclienttopologytest/artemisClient.groovy   | 52 +++++++++++++++
 .../hqclienttopologytest/artemisServer.groovy   | 47 +++++++++++++
 .../hqclienttopologytest/hornetqClient.groovy   | 55 +++++++++++++++
 .../verifyTopologyChangeMessage.groovy          | 69 +++++++++++++++++++
 .../compatibility/HQClientTopologyTest.java     | 70 ++++++++++++++++++++
 5 files changed, 293 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/284c620f/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisClient.groovy
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisClient.groovy
b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisClient.groovy
new file mode 100644
index 0000000..3777197
--- /dev/null
+++ b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisClient.groovy
@@ -0,0 +1,52 @@
+/*
+ * 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 hqclienttopologytest
+
+import org.apache.activemq.artemis.api.core.TransportConfiguration
+import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener
+import org.apache.activemq.artemis.api.core.client.TopologyMember
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory
+import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
+
+import java.util.concurrent.CountDownLatch
+
+/*
+ * Creates Artemis connection factory
+ */
+
+Map<String, Object> params = new HashMap<String, Object>();
+params.put(TransportConstants.HOST_PROP_NAME, "localhost");
+params.put(TransportConstants.PORT_PROP_NAME, 61616);
+TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName(),
params);
+
+cf = new ActiveMQConnectionFactory(true, tc);
+latch = new CountDownLatch(1);
+transportParams = new HashMap<String, Object>();
+
+cf.getServerLocator().addClusterTopologyListener(new ClusterTopologyListener() {
+    @Override
+    void nodeUP(TopologyMember topologyMember, boolean last) {
+        println("Node up: " + topologyMember.getNodeId() + " " + topologyMember.getLive().getParams().toString());
+        transportParams.putAll(topologyMember.getLive().getParams());
+        latch.countDown();
+    }
+
+    @Override
+    void nodeDown(long eventUID, String nodeID) {
+    }
+})

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/284c620f/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisServer.groovy
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisServer.groovy
b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisServer.groovy
new file mode 100644
index 0000000..e00e21d
--- /dev/null
+++ b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/artemisServer.groovy
@@ -0,0 +1,47 @@
+/*
+ * 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 hqclienttopologytest
+
+import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl
+import org.apache.activemq.artemis.core.server.JournalType
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS
+
+String folder = arg[0];
+
+configuration = new ConfigurationImpl();
+configuration.setJournalType(JournalType.NIO);
+println("folder:: " + folder);
+configuration.setBrokerInstance(new File(folder));
+configuration.addAcceptorConfiguration("artemis", "tcp://0.0.0.0:61616?anycastPrefix=jms.queue.&multicastPrefix=jms.topic.");
+configuration.addConnectorConfiguration("live", "tcp://127.0.0.1:61616?useNio=true;sslEnabled=false")
+configuration.setSecurityEnabled(false);
+configuration.setPersistenceEnabled(false);
+
+
+def cluster = new ClusterConnectionConfiguration();
+cluster.setName("my-cluster");
+cluster.setConnectorName("live");
+configuration.addClusterConfiguration(cluster);
+
+jmsConfiguration = new JMSConfigurationImpl();
+
+server = new EmbeddedJMS();
+server.setConfiguration(configuration);
+server.setJmsConfiguration(jmsConfiguration);
+server.start();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/284c620f/tests/compatibility-tests/src/main/resources/hqclienttopologytest/hornetqClient.groovy
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/main/resources/hqclienttopologytest/hornetqClient.groovy
b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/hornetqClient.groovy
new file mode 100644
index 0000000..a3b08a3
--- /dev/null
+++ b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/hornetqClient.groovy
@@ -0,0 +1,55 @@
+/*
+ * 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 hqclienttopologytest
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.client.ClusterTopologyListener;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
+import org.hornetq.api.core.client.TopologyMember;
+import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
+import org.hornetq.core.remoting.impl.netty.TransportConstants;
+import org.hornetq.jms.client.HornetQJMSConnectionFactory;
+
+import java.util.concurrent.CountDownLatch
+
+/*
+ * Creates HornetQ connection factory
+ */
+
+
+Map<String, Object> params = new HashMap<String, Object>();
+params.put(TransportConstants.HOST_PROP_NAME, "localhost");
+params.put(TransportConstants.PORT_PROP_NAME, 61616);
+def tc = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
+
+latch = new CountDownLatch(1);
+transportParams = new HashMap<String, Object>();
+
+ServerLocator locator = HornetQClient.createServerLocatorWithHA(tc);
+locator.addClusterTopologyListener(new ClusterTopologyListener() {
+    public void nodeUP(TopologyMember topologyMember, boolean b) {
+        println("Node up: " + topologyMember.getNodeId() + " " + topologyMember.getLive().getParams().toString());
+        transportParams.putAll(topologyMember.getLive().getParams());
+        latch.countDown();
+    }
+
+    public void nodeDown(long l, String s) {
+    }
+});
+
+cf = new HornetQJMSConnectionFactory(locator);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/284c620f/tests/compatibility-tests/src/main/resources/hqclienttopologytest/verifyTopologyChangeMessage.groovy
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/main/resources/hqclienttopologytest/verifyTopologyChangeMessage.groovy
b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/verifyTopologyChangeMessage.groovy
new file mode 100644
index 0000000..78da87d
--- /dev/null
+++ b/tests/compatibility-tests/src/main/resources/hqclienttopologytest/verifyTopologyChangeMessage.groovy
@@ -0,0 +1,69 @@
+/*
+ * 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 hqclienttopologytest
+
+import org.apache.activemq.artemis.tests.compatibility.GroovyRun
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import java.util.concurrent.TimeUnit;
+
+/*
+ * Opens JMS connection and verifies that transport config with correct parameters is received
from the server.
+ */
+
+
+// starts an artemis server
+String serverType = arg[0];
+String clientType = arg[1];
+
+if (clientType.startsWith("ARTEMIS")) {
+    // Can't depend directly on artemis, otherwise it wouldn't compile in hornetq
+    GroovyRun.evaluate("hqclienttopologytest/artemisClient.groovy", "serverArg", serverType);
+} else {
+    // Can't depend directly on hornetq, otherwise it wouldn't compile in artemis
+    GroovyRun.evaluate("hqclienttopologytest/hornetqClient.groovy");
+}
+
+
+Connection connection = cf.createConnection();
+Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+
+try {
+    latch.await(5, TimeUnit.SECONDS);
+    System.out.println("Count is " + latch.getCount());
+    System.out.println("Retrieved transport params: " + transportParams);
+
+    // cluster topology message should arrive immediately after connecting
+    GroovyRun.assertEquals(0, (int) latch.getCount());
+
+    if (clientType.startsWith("ARTEMIS")) {
+        // Artemis client - obtained params should be camelCase
+        GroovyRun.assertFalse(transportParams.containsKey("ssl-enabled"));
+        GroovyRun.assertTrue(transportParams.containsKey("sslEnabled"));
+    } else {
+        // HornetQ client - obtained params should be dash-delimited
+        GroovyRun.assertTrue(transportParams.containsKey("ssl-enabled"));
+        GroovyRun.assertFalse(transportParams.containsKey("sslEnabled"));
+    }
+
+    // parameter activemq.passwordcodec should not be present
+    GroovyRun.assertFalse(transportParams.containsKey("activemq.passwordcodec"));
+} finally {
+    session.close();
+    connection.close();
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/284c620f/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java
b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java
new file mode 100644
index 0000000..7a9ab9d
--- /dev/null
+++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.compatibility;
+
+import org.apache.activemq.artemis.utils.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.HORNETQ_235;
+import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE;
+import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT;
+
+/**
+ * Runs Artemis server with HornetQ client and verifies that the client receives
+ * correct connector parameters (keys must be dash-delimited instead of camelCase).
+ */
+@RunWith(Parameterized.class)
+public class HQClientTopologyTest extends VersionedBaseTest {
+
+   @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}")
+   public static Collection getParameters() {
+      List<Object[]> combinations = new ArrayList<>();
+
+      combinations.add(new Object[]{SNAPSHOT, HORNETQ_235, HORNETQ_235});
+      combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, ONE_FIVE});
+      return combinations;
+   }
+
+   public HQClientTopologyTest(String server, String sender, String receiver) throws Exception
{
+      super(server, sender, receiver);
+   }
+
+   @Before
+   public void setUp() throws Throwable {
+      FileUtil.deleteDirectory(serverFolder.getRoot());
+      evaluate(serverClassloader, "hqclienttopologytest/artemisServer.groovy", serverFolder.getRoot().getAbsolutePath());
+   }
+
+   @After
+   public void tearDown() throws Throwable {
+      execute(serverClassloader, "server.stop();");
+   }
+
+   @Test
+   public void topologyChangeMessageTest() throws Throwable {
+      evaluate(senderClassloader, "hqclienttopologytest/verifyTopologyChangeMessage.groovy",
server, sender);
+   }
+}


Mime
View raw message