mirror of https://github.com/apache/activemq.git
[AMQ-9376] karaf-itest for testing bundle and service lifecycle with multiple brokers
This commit is contained in:
parent
5dbe5f1c41
commit
a665ef1020
|
@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory;
|
|||
@ExamReactorStrategy(PerClass.class)
|
||||
public abstract class AbstractFeatureTest {
|
||||
|
||||
private static final String KARAF_MAJOR_VERSION = "4.2.10";
|
||||
private static final String KARAF_MAJOR_VERSION = "4.3.7";
|
||||
public static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureTest.class);
|
||||
public static final long ASSERTION_TIMEOUT = 30000L;
|
||||
public static final String RESOURCE_BASE = "src/test/resources/org/apache/activemq/karaf/itest/";
|
||||
|
@ -120,23 +120,31 @@ public abstract class AbstractFeatureTest {
|
|||
}
|
||||
|
||||
protected void assertBrokerStarted() throws Exception {
|
||||
Thread.sleep(4000);
|
||||
withinReason(new Runnable() {
|
||||
public void run() {
|
||||
assertEquals("brokerName = amq-broker", executeCommand("activemq:list").trim());
|
||||
assertTrue(executeCommand("activemq:bstat").trim().contains("BrokerName = amq-broker"));
|
||||
}
|
||||
});
|
||||
assertBrokerStarted("amq-broker");
|
||||
}
|
||||
|
||||
public static Option configureBrokerStart(String xmlConfig) {
|
||||
protected void assertBrokerStarted(String brokerName) throws Exception {
|
||||
Thread.sleep(4000);
|
||||
withinReason(new Runnable() {
|
||||
public void run() {
|
||||
assertEquals("brokerName = " + brokerName, executeCommand("activemq:list").trim());
|
||||
assertTrue(executeCommand("activemq:bstat").trim().contains("BrokerName = " + brokerName));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Option configureBrokerStart(String xmlConfig, String cfgFileame) {
|
||||
return composite(
|
||||
replaceConfigurationFile("etc/activemq.xml", new File(RESOURCE_BASE + xmlConfig + ".xml")),
|
||||
replaceConfigurationFile("etc/org.apache.activemq.server-default.cfg",
|
||||
new File(RESOURCE_BASE + "org.apache.activemq.server-default.cfg"))
|
||||
replaceConfigurationFile("etc/" + cfgFileame,
|
||||
new File(RESOURCE_BASE + cfgFileame))
|
||||
);
|
||||
}
|
||||
|
||||
public static Option configureBrokerStart(String xmlConfig) {
|
||||
return configureBrokerStart(xmlConfig, "org.apache.activemq.server-default.cfg");
|
||||
}
|
||||
|
||||
public static Option configureBrokerStart() {
|
||||
return configureBrokerStart("activemq");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* 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.karaf.itest;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
|
||||
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.ops4j.pax.exam.Configuration;
|
||||
import org.ops4j.pax.exam.Option;
|
||||
import org.ops4j.pax.exam.junit.PaxExam;
|
||||
|
||||
@RunWith(PaxExam.class)
|
||||
public class ActiveMQBrokerMultiServerTest extends AbstractFeatureTest {
|
||||
|
||||
@Configuration
|
||||
public static Option[] configure() {
|
||||
return new Option[] //
|
||||
{ //
|
||||
configure("activemq"), //
|
||||
editConfigurationFilePut("etc/org.apache.activemq.server-multibroker1.cfg", "config.check", "false"),
|
||||
editConfigurationFilePut("etc/org.apache.activemq.server-multibroker2.cfg", "config.check", "false"),
|
||||
editConfigurationFilePut("etc/org.apache.activemq.server-multibroker3.cfg", "config.check", "false"),
|
||||
configureBrokerStart("activemq-multi-broker") };
|
||||
}
|
||||
|
||||
@Test(timeout = 2 * 60 * 1000)
|
||||
public void test() throws Throwable {
|
||||
assertBrokerStarted("multibroker1");
|
||||
assertBrokerStarted("multibroker2");
|
||||
assertBrokerStarted("multibroker3");
|
||||
|
||||
// ensure update will be reflected in OS fs modified window
|
||||
TimeUnit.SECONDS.sleep(4);
|
||||
|
||||
// TODO: Perform a _bundle_ shutdown to go through ActiveMQServiceFactory.destroy()
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:amq="http://activemq.apache.org/schema/core"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
|
||||
|
||||
|
||||
<broker xmlns="http://activemq.apache.org/schema/core"
|
||||
brokerName="${broker-name}"
|
||||
dataDirectory="${data}"
|
||||
start="false">
|
||||
|
||||
<destinationPolicy>
|
||||
<policyMap>
|
||||
<policyEntries>
|
||||
<policyEntry topic=">" producerFlowControl="true" memoryLimit="3mb" >
|
||||
<pendingMessageLimitStrategy>
|
||||
<constantPendingMessageLimitStrategy limit="1000"/>
|
||||
</pendingMessageLimitStrategy>
|
||||
</policyEntry>
|
||||
<policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
|
||||
</policyEntry>
|
||||
</policyEntries>
|
||||
</policyMap>
|
||||
</destinationPolicy>
|
||||
|
||||
<managementContext>
|
||||
<managementContext createConnector="false"/>
|
||||
</managementContext>
|
||||
|
||||
<persistenceAdapter>
|
||||
<kahaDB directory="${data}/kahadb"/>
|
||||
</persistenceAdapter>
|
||||
|
||||
<plugins>
|
||||
<jaasAuthenticationPlugin configuration="karaf" />
|
||||
<authorizationPlugin>
|
||||
<map>
|
||||
<authorizationMap groupClass="org.apache.karaf.jaas.boot.principal.RolePrincipal">
|
||||
<authorizationEntries>
|
||||
<authorizationEntry queue=">" read="admin" write="admin" admin="admin"/>
|
||||
<authorizationEntry topic=">" read="admin" write="admin" admin="admin"/>
|
||||
<authorizationEntry topic="ActiveMQ.Advisory.>" read="admin" write="admin" admin="admin"/>
|
||||
</authorizationEntries>
|
||||
</authorizationMap>
|
||||
</map>
|
||||
</authorizationPlugin>
|
||||
</plugins>
|
||||
|
||||
<systemUsage>
|
||||
<systemUsage>
|
||||
<memoryUsage>
|
||||
<memoryUsage percentOfJvmHeap="20"/>
|
||||
</memoryUsage>
|
||||
<storeUsage>
|
||||
<storeUsage limit="128 mb"/>
|
||||
</storeUsage>
|
||||
<tempUsage>
|
||||
<tempUsage limit="50 mb"/>
|
||||
</tempUsage>
|
||||
</systemUsage>
|
||||
</systemUsage>
|
||||
|
||||
<transportConnectors>
|
||||
<transportConnector name="openwire" uri="tcp://0.0.0.0:${port}?maximumConnections=1000"/>
|
||||
</transportConnectors>
|
||||
</broker>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,21 @@
|
|||
## ---------------------------------------------------------------------------
|
||||
## Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
## contributor license agreements. See the NOTICE file distributed with
|
||||
## this work for additional information regarding copyright ownership.
|
||||
## The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
## (the "License"); you may not use this file except in compliance with
|
||||
## the License. You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
## ---------------------------------------------------------------------------
|
||||
|
||||
broker-name=multibroker1
|
||||
data=${karaf.data}/${broker-name}
|
||||
config=${karaf.base}/etc/activemq.xml
|
||||
port=11111
|
|
@ -0,0 +1,21 @@
|
|||
## ---------------------------------------------------------------------------
|
||||
## Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
## contributor license agreements. See the NOTICE file distributed with
|
||||
## this work for additional information regarding copyright ownership.
|
||||
## The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
## (the "License"); you may not use this file except in compliance with
|
||||
## the License. You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
## ---------------------------------------------------------------------------
|
||||
|
||||
broker-name=multibroker2
|
||||
data=${karaf.data}/${broker-name}
|
||||
config=${karaf.base}/etc/activemq.xml
|
||||
port=22222
|
|
@ -0,0 +1,21 @@
|
|||
## ---------------------------------------------------------------------------
|
||||
## Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
## contributor license agreements. See the NOTICE file distributed with
|
||||
## this work for additional information regarding copyright ownership.
|
||||
## The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
## (the "License"); you may not use this file except in compliance with
|
||||
## the License. You may obtain a copy of the License at
|
||||
##
|
||||
## http://www.apache.org/licenses/LICENSE-2.0
|
||||
##
|
||||
## Unless required by applicable law or agreed to in writing, software
|
||||
## distributed under the License is distributed on an "AS IS" BASIS,
|
||||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
## See the License for the specific language governing permissions and
|
||||
## limitations under the License.
|
||||
## ---------------------------------------------------------------------------
|
||||
|
||||
broker-name=multibroker3
|
||||
data=${karaf.data}/${broker-name}
|
||||
config=${karaf.base}/etc/activemq.xml
|
||||
port=33333
|
Loading…
Reference in New Issue