From 80037617aeadef0a693a51b5ee784f299fb9008c Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Wed, 12 Mar 2014 17:23:22 +0000 Subject: QPID-5625 : [Java Broker] ensure common configured object values are saved to the store git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1576826 13f79535-47bb-0310-9956-ffa450edef68 --- .../store/berkeleydb/AbstractBDBMessageStore.java | 5 -- .../berkeleydb/tuple/ConfiguredObjectBinding.java | 34 +++++++++++- .../qpid/server/exchange/AbstractExchange.java | 22 ++++++-- .../model/adapter/AbstractConfiguredObject.java | 43 ++++++++++++--- .../qpid/server/model/adapter/KeyStoreAdapter.java | 5 -- .../apache/qpid/server/queue/AbstractQueue.java | 3 +- .../qpid/server/security/SecurityManager.java | 25 +++++++++ .../server/store/AbstractJDBCMessageStore.java | 47 ++++++++++++---- .../server/store/DurableConfigurationStore.java | 1 - .../store/DurableConfigurationStoreHelper.java | 62 ++++++++-------------- .../qpid/server/store/JsonFileConfigStore.java | 6 --- .../apache/qpid/server/store/NullMessageStore.java | 5 -- .../AbstractDurableConfigurationStoreTestCase.java | 40 +++++++++++++- .../DurableConfigurationRecovererTest.java | 9 ++-- .../apache/qpid/server/store/SlowMessageStore.java | 8 --- 15 files changed, 219 insertions(+), 96 deletions(-) diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java index 37fb77f547..7d7ebd32fe 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java @@ -888,11 +888,6 @@ public abstract class AbstractBDBMessageStore implements MessageStore, DurableCo update(false, id, type, attributes, null); } - public void update(ConfiguredObjectRecord... records) throws StoreException - { - update(false, records); - } - public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException { com.sleepycat.je.Transaction txn = _environment.beginTransaction(null, null); diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java index a408732e2f..bc3beeb78b 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java @@ -24,6 +24,8 @@ import java.io.IOException; import java.io.StringWriter; import java.util.Map; import java.util.UUID; + +import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.store.ConfiguredObjectRecord; import com.sleepycat.bind.tuple.TupleBinding; @@ -31,14 +33,42 @@ import com.sleepycat.bind.tuple.TupleInput; import com.sleepycat.bind.tuple.TupleOutput; import org.apache.qpid.server.store.StoreException; import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.Version; import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.Module; import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializerProvider; +import org.codehaus.jackson.map.module.SimpleModule; public class ConfiguredObjectBinding extends TupleBinding { private static final ConfiguredObjectBinding INSTANCE = new ConfiguredObjectBinding(null); + private final UUID _uuid; + private static final Module _module; + static + { + SimpleModule module= new SimpleModule("ConfiguredObjectSerializer", new Version(1,0,0,null)); + + final JsonSerializer serializer = new JsonSerializer() + { + @Override + public void serialize(final ConfiguredObject value, + final JsonGenerator jgen, + final SerializerProvider provider) + throws IOException, JsonProcessingException + { + jgen.writeString(value.getId().toString()); + } + }; + module.addSerializer(ConfiguredObject.class, serializer); + + _module = module; + } public static ConfiguredObjectBinding getInstance() { @@ -74,7 +104,9 @@ public class ConfiguredObjectBinding extends TupleBinding> final AMQQueue queue, final Map arguments) { - return makeBinding(getBinding(bindingKey,queue).getId(), bindingKey, queue, arguments, false, true); + final BindingImpl existingBinding = getBinding(bindingKey, queue); + return makeBinding(existingBinding == null ? null : existingBinding.getId(), + bindingKey, + queue, + arguments, + false, + true); } @Override @@ -642,8 +649,6 @@ public abstract class AbstractExchange> boolean restore, boolean force) { - assert queue != null; - if (bindingKey == null) { bindingKey = ""; @@ -660,7 +665,16 @@ public abstract class AbstractExchange> bindingKey, _virtualHost.getName()); } - BindingImpl b = new BindingImpl(id, bindingKey, queue, this, arguments); + + Map attributes = new HashMap(); + attributes.put(org.apache.qpid.server.model.Binding.NAME,bindingKey); + if(arguments != null) + { + attributes.put(org.apache.qpid.server.model.Binding.ARGUMENTS, arguments); + } + + BindingImpl b = new BindingImpl(id, attributes, queue, this); + BindingImpl existingMapping = _bindingsMap.putIfAbsent(new BindingIdentifier(bindingKey,queue), b); if (existingMapping == null || force) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java index eda61f92b0..ec48aa7936 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractConfiguredObject.java @@ -84,8 +84,18 @@ public abstract class AbstractConfiguredObject> im private final Map _defaultAttributes = new HashMap(); private final TaskExecutor _taskExecutor; - private final long _createdTime; - private final String _createdBy; + + @ManagedAttributeField + private long _createdTime; + + @ManagedAttributeField + private String _createdBy; + + @ManagedAttributeField + private long _lastUpdatedTime; + + @ManagedAttributeField + private String _lastUpdatedBy; @ManagedAttributeField private String _name; @@ -197,8 +207,18 @@ public abstract class AbstractConfiguredObject> im } } } - _createdTime = MapValueConverter.getLongAttribute(CREATED_TIME, attributes, System.currentTimeMillis()); - _createdBy = MapValueConverter.getStringAttribute(CREATED_BY, attributes, getCurrentUserName()); + if(!_attributes.containsKey(CREATED_BY)) + { + final AuthenticatedPrincipal currentUser = SecurityManager.getCurrentUser(); + if(currentUser != null) + { + _attributes.put(CREATED_BY, currentUser); + } + } + if(!_attributes.containsKey(CREATED_TIME)) + { + _attributes.put(CREATED_TIME, System.currentTimeMillis()); + } for(Attribute attr : _attributeTypes.values()) { if(attr.getAnnotation().mandatory() && !(attributes.containsKey(attr.getName())|| defaults.containsKey(attr.getName()))) @@ -334,6 +354,17 @@ public abstract class AbstractConfiguredObject> im protected void attributeSet(String attributeName, Object oldAttributeValue, Object newAttributeValue) { + + final AuthenticatedPrincipal currentUser = SecurityManager.getCurrentUser(); + if(currentUser != null) + { + _attributes.put(LAST_UPDATED_BY, currentUser.getName()); + _lastUpdatedBy = currentUser.getName(); + } + final long currentTime = System.currentTimeMillis(); + _attributes.put(LAST_UPDATED_TIME, currentTime); + _lastUpdatedTime = currentTime; + synchronized (_changeListeners) { List copy = new ArrayList(_changeListeners); @@ -659,13 +690,13 @@ public abstract class AbstractConfiguredObject> im @Override public String getLastUpdatedBy() { - return null; + return _lastUpdatedBy; } @Override public long getLastUpdatedTime() { - return 0; + return _lastUpdatedTime; } @Override diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java index 06ca0d2a24..12de8142da 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java @@ -91,11 +91,6 @@ public class KeyStoreAdapter extends AbstractKeyStoreAdapter im _certificateAlias, _keyManagerFactoryAlgorithm); } - @Override - public String getDescription() - { - return null; - } @Override public Collection getAttributeNames() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java index ab3da6224e..e5f587ea94 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java @@ -2871,7 +2871,8 @@ public abstract class AbstractQueue if(childClass == Binding.class && otherParents.length == 1 && otherParents[0] instanceof Exchange) { final String bindingKey = (String) attributes.get("name"); - ((ExchangeImpl)otherParents[0]).addBinding(bindingKey, this, attributes); + ((ExchangeImpl)otherParents[0]).addBinding(bindingKey, this, + (Map) attributes.get(Binding.ARGUMENTS)); for(Binding binding : _bindings) { if(binding.getExchange() == otherParents[0] && binding.getName().equals(bindingKey)) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java index dca3576827..77886e9030 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java @@ -34,6 +34,7 @@ import org.apache.qpid.server.security.access.ObjectProperties; import org.apache.qpid.server.security.access.ObjectType; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.security.access.OperationLoggingDetails; +import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.security.auth.TaskPrincipal; import javax.security.auth.Subject; @@ -64,6 +65,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public class SecurityManager implements ConfigurationChangeListener @@ -183,6 +185,29 @@ public class SecurityManager implements ConfigurationChangeListener return !(subject == null || subject.getPrincipals(SystemPrincipal.class).isEmpty()); } + public static AuthenticatedPrincipal getCurrentUser() + { + Subject subject = Subject.getSubject(AccessController.getContext()); + final AuthenticatedPrincipal user; + if(subject != null) + { + Set principals = subject.getPrincipals(AuthenticatedPrincipal.class); + if(principals != null && !principals.isEmpty()) + { + user = principals.iterator().next(); + } + else + { + user = null; + } + } + else + { + user = null; + } + return user; + } + private static final class SystemPrincipal implements Principal { private SystemPrincipal() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java index 740d57f603..81c74fe8f5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java @@ -44,13 +44,21 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import org.apache.log4j.Logger; import org.apache.qpid.server.message.EnqueueableMessage; +import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.plugin.MessageMetaDataType; import org.apache.qpid.server.queue.AMQQueue; import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.Version; import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.Module; import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializerProvider; +import org.codehaus.jackson.map.module.SimpleModule; abstract public class AbstractJDBCMessageStore implements MessageStore, DurableConfigurationStore { @@ -160,6 +168,28 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC protected static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); + + private static final Module _module; + static + { + SimpleModule module= new SimpleModule("ConfiguredObjectSerializer", new Version(1,0,0,null)); + + final JsonSerializer serializer = new JsonSerializer() + { + @Override + public void serialize(final ConfiguredObject value, + final JsonGenerator jgen, + final SerializerProvider provider) + throws IOException, JsonProcessingException + { + jgen.writeString(value.getId().toString()); + } + }; + module.addSerializer(ConfiguredObject.class, serializer); + + _module = module; + } + protected final EventManager _eventManager = new EventManager(); protected final StateManager _stateManager; @@ -1994,7 +2024,10 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC else { final Map attributes = configuredObject.getAttributes(); - byte[] attributesAsBytes = new ObjectMapper().writeValueAsBytes(attributes); + final ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(_module); + byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes); + ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes); insertStmt.setBinaryStream(3, bis, attributesAsBytes.length); } @@ -2129,12 +2162,6 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC } } - @Override - public void update(ConfiguredObjectRecord... records) throws StoreException - { - update(false, records); - } - public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException { if (_stateManager.isInState(State.ACTIVE) || _stateManager.isInState(State.ACTIVATING)) @@ -2176,6 +2203,8 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC ResultSet rs = stmt.executeQuery(); try { + final ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(_module); if (rs.next()) { PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS); @@ -2184,7 +2213,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC stmt2.setString(1, configuredObject.getType()); if (configuredObject.getAttributes() != null) { - byte[] attributesAsBytes = (new ObjectMapper()).writeValueAsBytes( + byte[] attributesAsBytes = objectMapper.writeValueAsBytes( configuredObject.getAttributes()); ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes); stmt2.setBinaryStream(2, bis, attributesAsBytes.length); @@ -2215,7 +2244,7 @@ abstract public class AbstractJDBCMessageStore implements MessageStore, DurableC else { final Map attributes = configuredObject.getAttributes(); - byte[] attributesAsBytes = new ObjectMapper().writeValueAsBytes(attributes); + byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes); ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes); insertStmt.setBinaryStream(3, bis, attributesAsBytes.length); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java index e552b3e073..589eca1600 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java @@ -84,7 +84,6 @@ public interface DurableConfigurationStore void update(UUID id, String type, Map attributes) throws StoreException; - public void update(ConfiguredObjectRecord... records) throws StoreException; public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java index 77af1f92fd..8cecbc4d0b 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java @@ -20,6 +20,7 @@ */ package org.apache.qpid.server.store; +import java.security.PrivilegedAction; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -32,10 +33,14 @@ import java.util.Set; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.model.Binding; +import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.Exchange; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.queue.AMQQueue; +import org.apache.qpid.server.security.*; + +import javax.security.auth.Subject; public class DurableConfigurationStoreHelper { @@ -47,41 +52,18 @@ public class DurableConfigurationStoreHelper public static void updateQueue(DurableConfigurationStore store, AMQQueue queue) { - Map attributesMap = new LinkedHashMap(); - - if (queue.getAlternateExchange() != null) - { - attributesMap.put(Queue.ALTERNATE_EXCHANGE, queue.getAlternateExchange().getId()); - } - - Collection availableAttrs = queue.getAvailableAttributes(); - - for(String attrName : availableAttrs) - { - if(!QUEUE_ARGUMENTS_EXCLUDES.contains(attrName)) - { - attributesMap.put(attrName, queue.getAttribute(attrName)); - } - } + Map attributesMap = queue.getActualAttributes(); + attributesMap.remove(ConfiguredObject.ID); store.update(queue.getId(), QUEUE, attributesMap); } public static void createQueue(DurableConfigurationStore store, AMQQueue queue) { - Map attributesMap = new HashMap(); - if (queue.getAlternateExchange() != null) - { - attributesMap.put(Queue.ALTERNATE_EXCHANGE, queue.getAlternateExchange().getId()); - } - for(String attrName : queue.getAvailableAttributes()) - { - if(!QUEUE_ARGUMENTS_EXCLUDES.contains(attrName)) - { - attributesMap.put(attrName, queue.getAttribute(attrName)); - } - } + Map attributesMap = queue.getActualAttributes(); + attributesMap.remove(ConfiguredObject.ID); + store.create(queue.getId(), QUEUE, attributesMap); } @@ -92,11 +74,8 @@ public class DurableConfigurationStoreHelper public static void createExchange(DurableConfigurationStore store, ExchangeImpl exchange) { - Map attributesMap = new HashMap(); - attributesMap.put(Exchange.NAME, exchange.getName()); - attributesMap.put(Exchange.TYPE, exchange.getTypeName()); - attributesMap.put(Exchange.LIFETIME_POLICY, exchange.isAutoDelete() ? LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS.name() - : LifetimePolicy.PERMANENT.name()); + Map attributesMap = exchange.getActualAttributes(); + attributesMap.remove(ConfiguredObject.ID); store.create(exchange.getId(), EXCHANGE, attributesMap); @@ -108,16 +87,17 @@ public class DurableConfigurationStoreHelper store.remove(exchange.getId(), EXCHANGE); } - public static void createBinding(DurableConfigurationStore store, BindingImpl binding) + public static void createBinding(DurableConfigurationStore store, final BindingImpl binding) { - Map attributesMap = new HashMap(); - attributesMap.put(Binding.NAME, binding.getBindingKey()); - attributesMap.put(Binding.EXCHANGE, binding.getExchange().getId()); - attributesMap.put(Binding.QUEUE, binding.getAMQQueue().getId()); - Map arguments = binding.getArguments(); - if (arguments != null) + Map attributesMap = binding.getActualAttributes(); + attributesMap.remove(ConfiguredObject.ID); + if(!attributesMap.containsKey(Binding.EXCHANGE)) + { + attributesMap.put(Binding.EXCHANGE, binding.getExchange()); + } + if(!attributesMap.containsKey(Binding.QUEUE)) { - attributesMap.put(Binding.ARGUMENTS, arguments); + attributesMap.put(Binding.QUEUE, binding.getQueue()); } store.create(binding.getId(), BINDING, attributesMap); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java index ac9bfdcaae..3de601d741 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java @@ -460,12 +460,6 @@ public class JsonFileConfigStore implements DurableConfigurationStore update(false, new ConfiguredObjectRecord(id, type, attributes)); } - @Override - public void update(final ConfiguredObjectRecord... records) throws StoreException - { - update(false, records); - } - @Override public void update(final boolean createIfNecessary, final ConfiguredObjectRecord... records) throws StoreException diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java index 9100d623cd..c579a27731 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java @@ -36,11 +36,6 @@ public abstract class NullMessageStore implements MessageStore, DurableConfigura { } - @Override - public void update(ConfiguredObjectRecord... records) - { - } - @Override public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) { diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index 11c2451118..650b22ff51 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -23,6 +23,7 @@ package org.apache.qpid.server.store; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyMap; import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -55,6 +56,7 @@ import org.apache.qpid.server.store.Transaction.Record; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.util.FileUtils; import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatcher; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -201,7 +203,31 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest map.put(org.apache.qpid.server.model.Binding.ARGUMENTS,_bindingArgs); verify(_recoveryHandler).configuredObject(eq(binding.getId()), eq(BINDING), - eq(map)); + argThat(new IgnoreCreatedByMatcher(map))); + } + + private static class IgnoreCreatedByMatcher extends ArgumentMatcher> + { + private final Map _matchingMap; + + private IgnoreCreatedByMatcher(final Map matchingMap) + { + _matchingMap = matchingMap; + } + + @Override + public boolean matches(final Object argument) + { + if(argument instanceof Map) + { + Map arg = new HashMap((Map) argument); + arg.remove("createdBy"); + arg.remove("createdTime"); + return arg.equals(_matchingMap); + + } + return false; + } } public void testUnbindQueue() throws Exception @@ -373,6 +399,10 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(queue.getVirtualHost()).thenReturn(vh); final Map attributes = arguments == null ? new LinkedHashMap() : new LinkedHashMap(arguments); attributes.put(Queue.NAME, queueName); + if(alternateExchange != null) + { + attributes.put(Queue.ALTERNATE_EXCHANGE, alternateExchange); + } if(exclusive) { when(queue.getOwner()).thenReturn(queueOwner); @@ -394,16 +424,24 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest } }); + when(queue.getActualAttributes()).thenReturn(attributes); return queue; } private ExchangeImpl createTestExchange() { ExchangeImpl exchange = mock(ExchangeImpl.class); + Map actualAttributes = new HashMap(); + actualAttributes.put("id", _exchangeId); + actualAttributes.put("name", getName()); + actualAttributes.put("type", getName() + "Type"); + actualAttributes.put("lifetimePolicy", LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS); + when(exchange.getActualAttributes()).thenReturn(actualAttributes); when(exchange.getName()).thenReturn(getName()); when(exchange.getTypeName()).thenReturn(getName() + "Type"); when(exchange.isAutoDelete()).thenReturn(true); when(exchange.getId()).thenReturn(_exchangeId); + return exchange; } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java index 928ed6be74..9f1f6f48c0 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java @@ -53,6 +53,7 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doThrow; @@ -338,7 +339,8 @@ public class DurableConfigurationRecovererTest extends QpidTestCase "x-filter-jms-selector", "wibble")); - doThrow(new RuntimeException("Update Should not be called")).when(_store).update(any(ConfiguredObjectRecord[].class)); + doThrow(new RuntimeException("Update Should not be called")) + .when(_store).update(anyBoolean(), any(ConfiguredObjectRecord[].class)); _durableConfigurationRecoverer.completeConfigurationRecovery(); } @@ -442,12 +444,13 @@ public class DurableConfigurationRecovererTest extends QpidTestCase public Object answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); + final HashSet actual = new HashSet(Arrays.asList(args[1])); assertEquals("Updated records are not as expected", new HashSet(Arrays.asList( - expected)), new HashSet(Arrays.asList(args))); + expected)), actual); return null; } - }).when(_store).update(any(ConfiguredObjectRecord[].class)); + }).when(_store).update(anyBoolean(), any(ConfiguredObjectRecord[].class)); } private Map createBinding(String bindingKey, UUID exchangeId, UUID queueId, String... args) diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java index db1d5d9327..9407ef2d6c 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java @@ -218,14 +218,6 @@ public class SlowMessageStore implements MessageStore, DurableConfigurationStore doPostDelay("update"); } - @Override - public void update(ConfiguredObjectRecord... records) throws StoreException - { - doPreDelay("update"); - _durableConfigurationStore.update(records); - doPostDelay("update"); - } - @Override public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException { -- cgit v1.2.1 From 20a5b4fada357aae2365e9155f3e23d787b0d00c Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Thu, 13 Mar 2014 17:26:25 +0000 Subject: QPID-5625 : [Java Broker] ensure common configured object values are saved to the store git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577256 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/store/DurableConfigurationStoreHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java index 8cecbc4d0b..f914389b0e 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java @@ -54,7 +54,10 @@ public class DurableConfigurationStoreHelper { Map attributesMap = queue.getActualAttributes(); attributesMap.remove(ConfiguredObject.ID); - + if(queue.getAlternateExchange() != null) + { + attributesMap.put(Queue.ALTERNATE_EXCHANGE, queue.getAlternateExchange().getId()); + } store.update(queue.getId(), QUEUE, attributesMap); } @@ -63,6 +66,10 @@ public class DurableConfigurationStoreHelper Map attributesMap = queue.getActualAttributes(); attributesMap.remove(ConfiguredObject.ID); + if(queue.getAlternateExchange() != null) + { + attributesMap.put(Queue.ALTERNATE_EXCHANGE, queue.getAlternateExchange().getId()); + } store.create(queue.getId(), QUEUE, attributesMap); } -- cgit v1.2.1 From 8c2b2e9fa453b2daa81efd7a1b353332c9bf7971 Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Thu, 13 Mar 2014 21:12:32 +0000 Subject: QPID-5623: [C++ Messaging Client - amqp1.0] throws qpid::Exception instead of qpid::types::Exception Intercept the trap and rethrow in proper format. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577322 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp index c1ab108a61..90227fa29b 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp @@ -31,7 +31,13 @@ namespace amqp { namespace { ConnectionImpl* create(const std::string& u, const qpid::types::Variant::Map& o) { - return new ConnectionHandle(u, o); + try { + return new ConnectionHandle(u, o); + } catch (const types::Exception& ) { + throw; + } catch (const qpid::Exception& e) { + throw messaging::ConnectionError( e.what() ); + } } struct StaticInit -- cgit v1.2.1 From 13bd7b66f5c05d40917dda31adb5dab27d100a0e Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 14 Mar 2014 16:10:48 +0000 Subject: QPID-5048: surefire, site, coverage and jxr config Patch supplied by Andrew MacBean git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577595 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/pom.xml | 15 +++++++++++++++ qpid/java/qpid-systests-parent/pom.xml | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index 7f2e2d8fda..d5b8921fc4 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -38,6 +38,13 @@ http://svn.apache.org/viewvc/qpid/trunk/qpid/java + + + ${project.artifactId}-site + ${project.baseUri} + + + 1.6 @@ -359,6 +366,14 @@ + + false + + + + + org.apache.maven.plugins + maven-jxr-plugin diff --git a/qpid/java/qpid-systests-parent/pom.xml b/qpid/java/qpid-systests-parent/pom.xml index f550aff884..15fc567a77 100644 --- a/qpid/java/qpid-systests-parent/pom.xml +++ b/qpid/java/qpid-systests-parent/pom.xml @@ -39,6 +39,8 @@ ${basedir}/.. ${basedir}/.. ${basedir} + + @@ -204,7 +206,27 @@ + + + org.jacoco + jacoco-maven-plugin + + true + + + + + + org.jacoco + jacoco-maven-plugin + + true + + + + + -- cgit v1.2.1 From bf75e56731bfd5a45fc18f41d46514648802da87 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 14 Mar 2014 16:16:31 +0000 Subject: QPID-5048: add missing version for jxr plugin usage in the reporting section, which doesnt respect/adhere to the pluginManagement versions git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577600 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index d5b8921fc4..3f3577d93a 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -374,6 +374,7 @@ org.apache.maven.plugins maven-jxr-plugin + ${maven-jxr-plugin-version} -- cgit v1.2.1 From 38563ea3945b6973e35bab7b9537188c5271bdc5 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 14 Mar 2014 22:14:50 +0000 Subject: QPID-5630: Windows C++ broker never loads modules using --module-dir - Need to use full path to load modules instead of just the filename. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577742 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/sys/windows/FileSysDir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qpid/cpp/src/qpid/sys/windows/FileSysDir.cpp b/qpid/cpp/src/qpid/sys/windows/FileSysDir.cpp index e090747715..5128f0f8d6 100644 --- a/qpid/cpp/src/qpid/sys/windows/FileSysDir.cpp +++ b/qpid/cpp/src/qpid/sys/windows/FileSysDir.cpp @@ -79,7 +79,9 @@ void FileSysDir::forEachFile(Callback cb) const { // process everything that isn't a directory do { if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - std::string fileName(findFileData.cFileName); + std::string fileName(dirPath); + fileName += "\\"; + fileName += findFileData.cFileName; cb(fileName); } } while (FindNextFile(hFind, &findFileData) != 0); -- cgit v1.2.1 From a2d25c48d3be684640c22b7ca786aec90d091db6 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Sun, 16 Mar 2014 04:15:02 +0000 Subject: QPID-5632: Added cmake config files to the install area For use by other projects using cmake that want to simply detect qpid libraries git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577981 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/CMakeLists.txt | 22 +++++++++++++++++++++- qpid/cpp/src/QpidConfig.cmake.in | 30 ++++++++++++++++++++++++++++++ qpid/cpp/src/QpidConfigVersion.cmake.in | 30 ++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 qpid/cpp/src/QpidConfig.cmake.in create mode 100644 qpid/cpp/src/QpidConfigVersion.cmake.in diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt index d8b823fc8e..bf16c95919 100644 --- a/qpid/cpp/src/CMakeLists.txt +++ b/qpid/cpp/src/CMakeLists.txt @@ -1373,7 +1373,7 @@ set (prefix ${CMAKE_INSTALL_PREFIX}) set (exec_prefix ${CMAKE_INSTALL_PREFIX}) set_absolute_install_path (libdir ${QPID_INSTALL_LIBDIR}) set_absolute_install_path (includedir ${QPID_INSTALL_INCLUDEDIR}) -set (VERSION ${QPID_VERSION}) +set (VERSION ${QPID_VERSION_FULL}) #add_custom_target(pkgconfig ALL echo DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qpid.pc) #add_dependencies(pkgconfig ${CMAKE_CURRENT_BINARY_DIR}/qmf2.pc) @@ -1382,3 +1382,23 @@ configure_file(qmf2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/qmf2.pc @ONLY) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/qpid.pc ${CMAKE_CURRENT_BINARY_DIR}/qmf2.pc DESTINATION ${QPID_INSTALL_LIBDIR}/pkgconfig COMPONENT ${QPID_COMPONENT_COMMON}) + +if (DEFINED CMAKE_IMPORT_LIBRARY_PREFIX) +set(QPIDMSGLIB ${CMAKE_IMPORT_LIBRARY_PREFIX}qpidmessaging${CMAKE_IMPORT_LIBRARY_SUFFIX}) +set(QPIDMSGLIBDEBUG ${CMAKE_IMPORT_LIBRARY_PREFIX}qpidmessaging${CMAKE_DEBUG_POSTFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) +set(QPIDTYPESLIB ${CMAKE_IMPORT_LIBRARY_PREFIX}qpidtypes${CMAKE_IMPORT_LIBRARY_SUFFIX}) +set(QPIDTYPESLIBDEBUG ${CMAKE_IMPORT_LIBRARY_PREFIX}qpidtypes${CMAKE_DEBUG_POSTFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX}) +else () +set(QPIDMSGLIB ${CMAKE_SHARED_LIBRARY_PREFIX}qpidmessaging${CMAKE_SHARED_LIBRARY_SUFFIX}) +set(QPIDMSGLIBDEBUG ${CMAKE_SHARED_LIBRARY_PREFIX}qpidmessaging${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) +set(QPIDTYPESLIB ${CMAKE_SHARED_LIBRARY_PREFIX}qpidtypes${CMAKE_SHARED_LIBRARY_SUFFIX}) +set(QPIDTYPESLIBDEBUG ${CMAKE_SHARED_LIBRARY_PREFIX}qpidtypes${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) +endif () + +configure_file(QpidConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/QpidConfig.cmake @ONLY) +configure_file(QpidConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/QpidConfigVersion.cmake @ONLY) +install (FILES + ${CMAKE_CURRENT_BINARY_DIR}/QpidConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/QpidConfigVersion.cmake + DESTINATION ${QPID_INSTALL_LIBDIR}/cmake/Qpid + COMPONENT ${QPID_COMPONENT_COMMON}) diff --git a/qpid/cpp/src/QpidConfig.cmake.in b/qpid/cpp/src/QpidConfig.cmake.in new file mode 100644 index 0000000000..3f84e3b6b0 --- /dev/null +++ b/qpid/cpp/src/QpidConfig.cmake.in @@ -0,0 +1,30 @@ +# +# 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. +# + +# Name: Qpid +# Description: Qpid Client C library +# Version: @VERSION@ +# URL: http://qpid.apache.org/ + +set (Qpid_VERSION @VERSION@) + +set (Qpid_INCLUDE_DIRS @includedir@) +set (Qpid_LIBRARIES optimized @libdir@/@QPIDMSGLIB@ @libdir@/@QPIDTYPESLIB@ debug @libdir@/@QPIDMSGLIBDEBUG@ @libdir@/@QPIDTYPESLIBDEBUG@) + +set (Qpid_FOUND True) diff --git a/qpid/cpp/src/QpidConfigVersion.cmake.in b/qpid/cpp/src/QpidConfigVersion.cmake.in new file mode 100644 index 0000000000..d85924ab7e --- /dev/null +++ b/qpid/cpp/src/QpidConfigVersion.cmake.in @@ -0,0 +1,30 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version. + +set(PACKAGE_VERSION "@VERSION@") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") + return() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() -- cgit v1.2.1 From 5b35067e10c6521b9d8866b9a01e6ace3f68a3bd Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Sun, 16 Mar 2014 04:15:05 +0000 Subject: QPID-5631: Adjust for changes in Proton detection files exported by proton. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1577982 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/CMakeLists.txt | 2 +- qpid/cpp/src/amqp.cmake | 78 ++++++++++----------------------------------- 2 files changed, 18 insertions(+), 62 deletions(-) diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt index bf16c95919..73b3e675c7 100644 --- a/qpid/cpp/src/CMakeLists.txt +++ b/qpid/cpp/src/CMakeLists.txt @@ -1084,7 +1084,7 @@ set (qpidmessaging_SOURCES add_msvc_version (qpidmessaging library dll) add_library (qpidmessaging SHARED ${qpidmessaging_SOURCES}) -target_link_libraries (qpidmessaging qpidtypes qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}" ${PROTON_LIBRARIES}) +target_link_libraries (qpidmessaging qpidtypes qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}" ${Proton_LIBRARIES}) set_target_properties (qpidmessaging PROPERTIES LINK_FLAGS "${HIDE_SYMBOL_FLAGS} ${LINK_VERSION_SCRIPT_FLAG}" COMPILE_FLAGS "${HIDE_SYMBOL_FLAGS}" diff --git a/qpid/cpp/src/amqp.cmake b/qpid/cpp/src/amqp.cmake index 39f45954f3..d1ff184a64 100644 --- a/qpid/cpp/src/amqp.cmake +++ b/qpid/cpp/src/amqp.cmake @@ -19,61 +19,30 @@ # Optional AMQP1.0 support. Requires proton toolkit. -include(FindPkgConfig) - -pkg_check_modules(PROTON libqpid-proton) - -if (NOT PROTON_FOUND) - # if pkg-config is absent or fails to find proton then use - # PROTON_ROOT command line option or environment variable to locate - # local installed proton build. - if (NOT PROTON_ROOT) - set (PROTON_ROOT "$ENV{PROTON_ROOT}") - endif() - if (PROTON_ROOT) - find_package(proton PATHS ${PROTON_ROOT} NO_DEFAULT_PATH) - - if (proton_FOUND EQUAL 1) - set(iFile "${PROTON_ROOT}/lib/proton.cmake/libqpid-proton.cmake") - if(EXISTS ${iFile}) - include("${iFile}") - else() - message(FATAL_ERROR "PROTON_ROOT defined but file ${iFile} is missing") - endif() - else() - message(FATAL_ERROR "Proton package files not found in ${PROTON_ROOT}") - endif() - endif() -endif() +find_package(Proton 0.5) set (amqp_default ${amqp_force}) -set (minimum_version 0.5) set (maximum_version 0.6) -if (PROTON_FOUND) - if (PROTON_VERSION LESS ${minimum_version}) - message(STATUS "Qpid proton ${PROTON_VERSION} is too old, require ${minimum_version} - ${maximum_version}; amqp 1.0 support not enabled") - else (PROTON_VERSION LESS ${minimum_version}) - if (PROTON_VERSION GREATER ${maximum_version}) - message(STATUS "Qpid proton ${PROTON_VERSION} is too new, require ${minimum_version} - ${maximum_version}; amqp 1.0 support not enabled") - else (PROTON_VERSION GREATER ${maximum_version}) - message(STATUS "Qpid proton found, amqp 1.0 support enabled") - set (amqp_default ON) - #remove when 0.5 no longer supported - if (NOT PROTON_VERSION EQUAL 0.5) - set (HAVE_PROTON_TRACER 1) - endif (NOT PROTON_VERSION EQUAL 0.5) - endif (PROTON_VERSION GREATER ${maximum_version}) - endif (PROTON_VERSION LESS ${minimum_version}) -else (PROTON_FOUND) +if (Proton_FOUND) + if (Proton_VERSION GREATER ${maximum_version}) + message(WARNING "Qpid proton ${Proton_VERSION} is not a tested version and might not be compatible, ${maximum_version} is highest tested; build may not work") + endif (Proton_VERSION GREATER ${maximum_version}) + message(STATUS "Qpid proton found, amqp 1.0 support enabled") + set (amqp_default ON) + #remove when 0.5 no longer supported + if (NOT Proton_VERSION EQUAL 0.5) + set (HAVE_PROTON_TRACER 1) + endif (NOT Proton_VERSION EQUAL 0.5) +else () message(STATUS "Qpid proton not found, amqp 1.0 support not enabled") -endif (PROTON_FOUND) +endif () option(BUILD_AMQP "Build with support for AMQP 1.0" ${amqp_default}) if (BUILD_AMQP) - if (NOT PROTON_FOUND) + if (NOT Proton_FOUND) message(FATAL_ERROR "Qpid proton not found, required for amqp 1.0 support") - endif (NOT PROTON_FOUND) + endif () set (amqp_SOURCES qpid/broker/amqp/Authorise.h @@ -129,11 +98,10 @@ if (BUILD_AMQP) qpid/broker/amqp/Translation.cpp ) - include_directories(${PROTON_INCLUDE_DIRS}) - link_directories(${PROTON_LIBRARY_DIRS}) + include_directories(${Proton_INCLUDE_DIRS}) add_library (amqp MODULE ${amqp_SOURCES}) - target_link_libraries (amqp qpidtypes qpidbroker qpidcommon ${PROTON_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + target_link_libraries (amqp qpidtypes qpidbroker qpidcommon ${Proton_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}) set_target_properties (amqp PROPERTIES PREFIX "" LINK_FLAGS "${CATCH_UNDEFINED}" @@ -173,18 +141,6 @@ if (BUILD_AMQP) if (WIN32) list (APPEND amqp_SOURCES qpid/messaging/amqp/windows/SslTransport.cpp) list (APPEND amqpc_SOURCES qpid/messaging/amqp/windows/SslTransport.cpp) - - set(proton_dll "${PROTON_LIBRARY_DIRS}/${PROTON_LIBRARIES}.dll") - set(proton_dlld "${PROTON_LIBRARY_DIRS}/${PROTON_LIBRARIES}d.dll") - - install (PROGRAMS ${proton_dll} - DESTINATION ${QPID_INSTALL_BINDIR} - COMPONENT ${QPID_COMPONENT_COMMON} - CONFIGURATIONS Release|MinSizeRel|RelWithDebInfo) - install (PROGRAMS ${proton_dlld} - DESTINATION ${QPID_INSTALL_BINDIR} - COMPONENT ${QPID_COMPONENT_COMMON} - CONFIGURATIONS Debug) endif (WIN32) else (BUILD_AMQP) # ensure that qpid build ignores proton -- cgit v1.2.1 From e79af8bf370cefde46fbaf89ed158047c7ca2947 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sun, 16 Mar 2014 19:43:56 +0000 Subject: QPID-5048: split out systests from perftests and add rat plugin config Patch supplied by Andrew MacBean git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1578145 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/bdbstore/systests/pom.xml | 4 - qpid/java/build.xml | 2 +- qpid/java/perftests/pom.xml | 27 +- .../apache/qpid/disttest/PerfTestConstants.java | 28 ++ .../qpid/disttest/controller/ControllerTest.java | 4 +- .../disttest/DistributedTestSystemTestBase.java | 72 ----- .../systest/disttest/QpidQueueCreatorTest.java | 100 ------- .../qpid/systest/disttest/SystemTestConstants.java | 28 -- .../clientonly/BasicDistributedClientTest.java | 186 ------------ .../clientonly/ConsumerParticipantTest.java | 156 ---------- .../disttest/clientonly/ControllerQueue.java | 110 ------- .../disttest/clientonly/DistributedClientTest.java | 325 --------------------- .../disttest/clientonly/MessageProviderTest.java | 119 -------- .../clientonly/ProducerParticipantTest.java | 132 --------- .../ControllerAndClientTest.java | 263 ----------------- .../controllerandclient/iteratingFeature.json | 63 ---- .../controllerandclient/produceClient.json | 41 --- .../producerAndConsumerInSeparateClients.json | 56 ---- ...producerAndThreeConsumersInSeparateClients.json | 77 ----- .../controllerandclient/testWithTwoTests.json | 107 ------- .../controlleronly/DistributedControllerTest.java | 157 ---------- .../controlleronly/distributedControllerTest.json | 17 -- .../systest/disttest/endtoend/EndToEndTest.java | 100 ------- .../qpid/systest/disttest/endtoend/endtoend.json | 65 ----- .../systest/disttest/perftests.systests.properties | 29 -- qpid/java/pom.xml | 19 ++ qpid/java/qpid-perftests-systests/build.xml | 67 +++++ qpid/java/qpid-perftests-systests/pom.xml | 116 ++++++++ .../systest/disttest/ConfigFileTestHelper.java | 48 +++ .../disttest/DistributedTestSystemTestBase.java | 72 +++++ .../systest/disttest/QpidQueueCreatorTest.java | 100 +++++++ .../qpid/systest/disttest/SystemTestConstants.java | 28 ++ .../clientonly/BasicDistributedClientTest.java | 186 ++++++++++++ .../clientonly/ConsumerParticipantTest.java | 156 ++++++++++ .../disttest/clientonly/ControllerQueue.java | 110 +++++++ .../disttest/clientonly/DistributedClientTest.java | 325 +++++++++++++++++++++ .../disttest/clientonly/MessageProviderTest.java | 119 ++++++++ .../clientonly/ProducerParticipantTest.java | 132 +++++++++ .../ControllerAndClientTest.java | 263 +++++++++++++++++ .../controllerandclient/iteratingFeature.json | 63 ++++ .../controllerandclient/produceClient.json | 41 +++ .../producerAndConsumerInSeparateClients.json | 56 ++++ ...producerAndThreeConsumersInSeparateClients.json | 77 +++++ .../controllerandclient/testWithTwoTests.json | 107 +++++++ .../controlleronly/DistributedControllerTest.java | 157 ++++++++++ .../controlleronly/distributedControllerTest.json | 17 ++ .../systest/disttest/endtoend/EndToEndTest.java | 100 +++++++ .../qpid/systest/disttest/endtoend/endtoend.json | 65 +++++ .../systest/disttest/perftests.systests.properties | 29 ++ qpid/java/qpid-systests-parent/pom.xml | 2 + qpid/java/systests/pom.xml | 4 - 51 files changed, 2500 insertions(+), 2227 deletions(-) create mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/disttest/PerfTestConstants.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/DistributedTestSystemTestBase.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json delete mode 100644 qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties create mode 100644 qpid/java/qpid-perftests-systests/build.xml create mode 100644 qpid/java/qpid-perftests-systests/pom.xml create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/ConfigFileTestHelper.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/DistributedTestSystemTestBase.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/SystemTestConstants.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json create mode 100644 qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/perftests.systests.properties diff --git a/qpid/java/bdbstore/systests/pom.xml b/qpid/java/bdbstore/systests/pom.xml index 7d4913ebcd..e8620d3426 100644 --- a/qpid/java/bdbstore/systests/pom.xml +++ b/qpid/java/bdbstore/systests/pom.xml @@ -67,8 +67,4 @@ - - src/main/java - - diff --git a/qpid/java/build.xml b/qpid/java/build.xml index 219029b908..75652d868a 100644 --- a/qpid/java/build.xml +++ b/qpid/java/build.xml @@ -36,7 +36,7 @@ - + EMPTY_ATTRIBUTES = Collections.emptyMap(); - - private static final boolean QUEUE_DURABILITY = true; - - private Connection _connection; - private QpidQueueCreator _creator; - private Session _session; - private List _configs; - private String _queueName; - - @Override - public void setUp() throws Exception - { - super.setUp(); - _connection = getConnection(); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _creator = new QpidQueueCreator(); - _configs = new ArrayList(); - _queueName = "direct://amq.direct//" + getTestQueueName() + "?durable='" + QUEUE_DURABILITY + "'"; - } - - public void testCreateQueueWithoutAttributes() throws Exception - { - _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES)); - - assertQueueBound(_queueName, false); - - _creator.createQueues(_connection, _session, _configs); - - assertQueueBound(_queueName, true); - } - - public void testCreateWithAttributes() throws Exception - { - Map attributes = new HashMap(); - attributes.put("x-qpid-priorities", Integer.valueOf(5)); - _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, attributes)); - - assertQueueBound(_queueName, false); - - _creator.createQueues(_connection, _session, _configs); - - assertQueueBound(_queueName, true); - } - - public void testDeleteQueues() throws Exception - { - _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES)); - - assertQueueBound(_queueName, false); - - _creator.createQueues(_connection, _session, _configs); - assertQueueBound(_queueName, true); - - _creator.deleteQueues(_connection, _session, _configs); - assertQueueBound(_queueName, false); - } - - private void assertQueueBound(String queueName, boolean isBound) throws Exception - { - AMQDestination destination = (AMQDestination)_session.createQueue(queueName); - assertEquals("Queue is not in expected bound state", isBound, ((AMQSession)_session).isQueueBound(destination)); - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java deleted file mode 100644 index b06ab0c735..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java +++ /dev/null @@ -1,28 +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.qpid.systest.disttest; - -public abstract class SystemTestConstants -{ - public static final long REGISTRATION_TIMEOUT = 20000; - public static final long COMMAND_RESPONSE_TIMEOUT = 30000; - public static final long TEST_RESULT_TIMEOUT = 20000; - -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java deleted file mode 100644 index d599bdc5c4..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java +++ /dev/null @@ -1,186 +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.qpid.systest.disttest.clientonly; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; - -import org.apache.qpid.disttest.client.Client; -import org.apache.qpid.disttest.client.ClientState; -import org.apache.qpid.disttest.jms.ClientJmsDelegate; -import org.apache.qpid.disttest.jms.JmsMessageAdaptor; -import org.apache.qpid.disttest.message.Command; -import org.apache.qpid.disttest.message.CommandType; -import org.apache.qpid.disttest.message.CreateConnectionCommand; -import org.apache.qpid.disttest.message.CreateSessionCommand; -import org.apache.qpid.disttest.message.NoOpCommand; -import org.apache.qpid.disttest.message.RegisterClientCommand; -import org.apache.qpid.disttest.message.Response; -import org.apache.qpid.disttest.message.StopClientCommand; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; - -public class BasicDistributedClientTest extends DistributedTestSystemTestBase -{ - private Session _session = null; - private MessageProducer _clientQueueProducer; - private Client _client; - private ControllerQueue _controllerQueue; - private ClientJmsDelegate _clientJmsDelegate = null; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - _controllerQueue = new ControllerQueue(_connection, _context); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - _clientJmsDelegate = new ClientJmsDelegate(_context); - _client = new Client(_clientJmsDelegate); - _client.start(); - } - - @Override - protected void tearDown() throws Exception - { - try - { - _controllerQueue.close(); - if (_session != null) - { - _session.close(); - } - } - finally - { - super.tearDown(); - } - } - - public void testClientSendsRegistrationMessage() throws Exception - { - final RegisterClientCommand regClientCommand = _controllerQueue.getNext(); - - assertNotNull("Client must have a non-null name", regClientCommand.getClientName()); - assertEquals("Unexpected client name", _clientJmsDelegate.getClientName(), regClientCommand.getClientName()); - assertNotNull("Client queue name should not be null", regClientCommand.getClientQueueName()); - } - - public void testClientSendsCommandResponses() throws Exception - { - final RegisterClientCommand registrationCommand = _controllerQueue.getNext(); - createClientQueueProducer(registrationCommand); - - sendCommandToClient(new NoOpCommand()); - - final Response responseCommand = _controllerQueue.getNext(); - assertEquals("Incorrect client message type", CommandType.RESPONSE, responseCommand.getType()); - } - - public void testClientCanBeStoppedViaCommand() throws Exception - { - assertEquals("Expected client to be in STARTED state", ClientState.READY, _client.getState()); - - final RegisterClientCommand registrationCommand = _controllerQueue.getNext(); - createClientQueueProducer(registrationCommand); - - final Command stopClientCommand = new StopClientCommand(); - sendCommandToClient(stopClientCommand); - - _client.waitUntilStopped(1000); - - Response response = _controllerQueue.getNext(); - assertNotNull(response); - assertFalse("response shouldn't contain error", response.hasError()); - - assertEquals("Expected client to be in STOPPED state", ClientState.STOPPED, _client.getState()); - } - - public void testClientCanCreateTestConnection() throws Exception - { - assertEquals("Unexpected number of test connections", 0, _clientJmsDelegate.getNoOfTestConnections()); - - final RegisterClientCommand registration = _controllerQueue.getNext(); - createClientQueueProducer(registration); - - final CreateConnectionCommand createConnectionCommand = new CreateConnectionCommand(); - createConnectionCommand.setConnectionName("newTestConnection"); - createConnectionCommand.setConnectionFactoryName("connectionfactory"); - - sendCommandToClient(createConnectionCommand); - Response response = _controllerQueue.getNext(); - - assertFalse("Response message should not have indicated an error", response.hasError()); - assertEquals("Unexpected number of test connections", 1, _clientJmsDelegate.getNoOfTestConnections()); - } - - public void testClientCanCreateTestSession() throws Exception - { - assertEquals("Unexpected number of test sessions", 0, _clientJmsDelegate.getNoOfTestSessions()); - - final RegisterClientCommand registration = _controllerQueue.getNext(); - createClientQueueProducer(registration); - - final CreateConnectionCommand createConnectionCommand = new CreateConnectionCommand(); - createConnectionCommand.setConnectionName("newTestConnection"); - createConnectionCommand.setConnectionFactoryName("connectionfactory"); - - sendCommandToClient(createConnectionCommand); - Response response = _controllerQueue.getNext(); - assertFalse("Response message should not have indicated an error", response.hasError()); - - final CreateSessionCommand createSessionCommand = new CreateSessionCommand(); - createSessionCommand.setConnectionName("newTestConnection"); - createSessionCommand.setSessionName("newTestSession"); - createSessionCommand.setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); - - sendCommandToClient(createSessionCommand); - response = _controllerQueue.getNext(); - - assertFalse("Response message should not have indicated an error", response.hasError()); - assertEquals("Unexpected number of test sessions", 1, _clientJmsDelegate.getNoOfTestSessions()); - } - - private void sendCommandToClient(final Command command) throws JMSException - { - final Message message = JmsMessageAdaptor.commandToMessage(_session, command); - _clientQueueProducer.send(message); - } - - private void createClientQueueProducer( - final RegisterClientCommand registration) throws JMSException - { - final Destination clientCommandQueue = createDestinationFromRegistration(registration); - _clientQueueProducer = _session.createProducer(clientCommandQueue); - } - - private Queue createDestinationFromRegistration( - final RegisterClientCommand registrationCommand) - throws JMSException - { - String clientQueueName = registrationCommand.getClientQueueName(); - assertNotNull("Null client queue in register message", clientQueueName); - return _session.createQueue(clientQueueName); - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java deleted file mode 100644 index a3c0430865..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java +++ /dev/null @@ -1,156 +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.qpid.systest.disttest.clientonly; - -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; - -import org.apache.qpid.disttest.client.Client; -import org.apache.qpid.disttest.client.ConsumerParticipant; -import org.apache.qpid.disttest.client.ParticipantExecutor; -import org.apache.qpid.disttest.message.CreateConsumerCommand; -import org.apache.qpid.disttest.message.ParticipantResult; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; -import org.apache.qpid.systest.disttest.clientonly.ProducerParticipantTest.TestClientJmsDelegate; - -public class ConsumerParticipantTest extends DistributedTestSystemTestBase -{ - private MessageProducer _producer; - private Session _session; - private TestClientJmsDelegate _delegate; - private Client _client; - private ControllerQueue _controllerQueue; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - _controllerQueue = new ControllerQueue(_connection, _context); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _producer = _session.createProducer(getTestQueue()); - - _delegate = new TestClientJmsDelegate(getContext()); - _client = new Client(_delegate); - } - - - @Override - protected void tearDown() throws Exception - { - _controllerQueue.close(); - super.tearDown(); - } - - public void testConsumeNumberOfMessagesSynchronously() throws Exception - { - runTest(Session.AUTO_ACKNOWLEDGE, 10, 0, true); - } - - public void testConsumeNumberOfMessagesAsynchronously() throws Exception - { - runTest(Session.AUTO_ACKNOWLEDGE, 10, 0, false); - } - - public void testSelectors() throws Exception - { - final CreateConsumerCommand command = new CreateConsumerCommand(); - command.setNumberOfMessages(10); - command.setSessionName("testSession"); - command.setDestinationName(getTestQueueName()); - command.setSelector("id=1"); - Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - _delegate.addConnection("name-does-not-matter", _connection); - _delegate.addSession(command.getSessionName(), session); - - ConsumerParticipant consumerParticipant = new ConsumerParticipant(_delegate, command); - _delegate.createConsumer(command); - - for (int i = 0; i < 20; i++) - { - Message message = _session.createMessage(); - if (i % 2 == 0) - { - message.setIntProperty("id", 0); - } - else - { - message.setIntProperty("id", 1); - } - _producer.send(message); - } - - new ParticipantExecutor(consumerParticipant).start(_client); - - ParticipantResult results = _controllerQueue.getNext(); - assertNotNull("No results message recieved", results); - assertEquals("Unexpected number of messages received", 10, results.getNumberOfMessagesProcessed()); - - Session testQueueConsumerSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - final MessageConsumer testQueueConsumer = testQueueConsumerSession.createConsumer(getTestQueue()); - for (int i = 0; i < 10; i++) - { - Message message = testQueueConsumer.receive(2000); - assertNotNull("Message is not received: " + message, message); - assertEquals("Unexpected id value", 0, message.getIntProperty("id")); - } - Message message = testQueueConsumer.receive(2000); - assertNull("Unexpected message remaining on test queue: " + message, message); - - _connection.stop(); - } - - protected void runTest(int acknowledgeMode, int numberOfMessages, int batchSize, boolean synchronous) throws Exception - { - final CreateConsumerCommand command = new CreateConsumerCommand(); - command.setNumberOfMessages(numberOfMessages); - command.setBatchSize(batchSize); - command.setSessionName("testSession"); - command.setDestinationName(getTestQueueName()); - command.setSynchronous(synchronous); - - Session session = _connection.createSession(Session.SESSION_TRANSACTED == acknowledgeMode, acknowledgeMode); - - _delegate.addConnection("name-does-not-matter", _connection); - _delegate.addSession(command.getSessionName(), session); - - ConsumerParticipant consumerParticipant = new ConsumerParticipant(_delegate, command); - _delegate.createConsumer(command); - - for (int i = 0; i < numberOfMessages; i++) - { - _producer.send(_session.createMessage()); - } - - new ParticipantExecutor(consumerParticipant).start(_client); - - ParticipantResult results = _controllerQueue.getNext(); - assertNotNull("No results message recieved", results); - - Session testQueueConsumerSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - final MessageConsumer testQueueConsumer = testQueueConsumerSession.createConsumer(getTestQueue()); - Message message = testQueueConsumer.receive(2000); - assertNull("Unexpected message remaining on test queue: " + message, message); - - _connection.stop(); - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java deleted file mode 100644 index 75783eef4b..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java +++ /dev/null @@ -1,110 +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.qpid.systest.disttest.clientonly; - -import java.util.Map; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Session; -import javax.naming.Context; - -import junit.framework.Assert; - -import org.apache.qpid.disttest.DistributedTestConstants; -import org.apache.qpid.disttest.jms.JmsMessageAdaptor; -import org.apache.qpid.disttest.message.Command; -import org.apache.qpid.disttest.message.CommandType; - -/** - * Helper for unit tests to simplify access to the Controller Queue. - * - * Implicitly creates the queue, so you must create a {@link ControllerQueue} object before - * trying to use the underlying queue. - */ -public class ControllerQueue -{ - private MessageConsumer _controllerQueueMessageConsumer; - private Session _controllerQueueSession; - - /** - * Implicitly creates the queue, so you must create a {@link ControllerQueue} object before - * trying to use the underlying queue. - * - * @param context used for looking up the controller queue {@link Destination} - */ - public ControllerQueue(Connection connection, Context context) throws Exception - { - _controllerQueueSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination controllerQueue = (Destination) context.lookup(DistributedTestConstants.CONTROLLER_QUEUE_JNDI_NAME); - _controllerQueueMessageConsumer = _controllerQueueSession.createConsumer(controllerQueue); - } - - public T getNext(long timeout) throws JMSException - { - final Message message = _controllerQueueMessageConsumer.receive(timeout); - if(message == null) - { - return null; - } - - return (T) JmsMessageAdaptor.messageToCommand(message); - } - - public void addNextResponse(Map responses) throws JMSException - { - Command nextResponse = getNext(); - responses.put(nextResponse.getType(), nextResponse); - } - - @SuppressWarnings("unchecked") - public T getNext() throws JMSException - { - return (T)getNext(true); - } - - public T getNext(boolean assertMessageExists) throws JMSException - { - final Message message = _controllerQueueMessageConsumer.receive(2000); - if(assertMessageExists) - { - Assert.assertNotNull("No message received from control queue", message); - } - - if(message == null) - { - return null; - } - - T command = (T) JmsMessageAdaptor.messageToCommand(message); - - return command; - } - - public void close() throws Exception - { - _controllerQueueMessageConsumer.close(); - _controllerQueueSession.close(); - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java deleted file mode 100644 index 5b5a60ac43..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java +++ /dev/null @@ -1,325 +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.qpid.systest.disttest.clientonly; - -import static org.apache.qpid.disttest.client.ClientState.READY; -import static org.apache.qpid.disttest.client.ClientState.RUNNING_TEST; - -import java.util.HashMap; -import java.util.Map; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; - -import org.apache.qpid.client.AMQSession; -import org.apache.qpid.disttest.client.Client; -import org.apache.qpid.disttest.client.ClientState; -import org.apache.qpid.disttest.jms.ClientJmsDelegate; -import org.apache.qpid.disttest.jms.JmsMessageAdaptor; -import org.apache.qpid.disttest.message.Command; -import org.apache.qpid.disttest.message.CommandType; -import org.apache.qpid.disttest.message.CreateConnectionCommand; -import org.apache.qpid.disttest.message.CreateConsumerCommand; -import org.apache.qpid.disttest.message.CreateProducerCommand; -import org.apache.qpid.disttest.message.CreateSessionCommand; -import org.apache.qpid.disttest.message.ParticipantResult; -import org.apache.qpid.disttest.message.RegisterClientCommand; -import org.apache.qpid.disttest.message.Response; -import org.apache.qpid.disttest.message.StartTestCommand; -import org.apache.qpid.disttest.message.TearDownTestCommand; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; - -public class DistributedClientTest extends DistributedTestSystemTestBase -{ - private static final String TEST_CONSUMER = "newTestConsumer"; - private static final String TEST_DESTINATION = "newDestination"; - private static final String TEST_PRODUCER_NAME = "newTestProducer"; - private static final String TEST_SESSION_NAME = "newTestSession"; - private static final String TEST_CONNECTION_NAME = "newTestConnection"; - - private Session _session = null; - private MessageProducer _clientQueueProducer; - private Client _client; - private ControllerQueue _controllerQueue; - protected ClientJmsDelegate _clientJmsDelegate; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _controllerQueue = new ControllerQueue(_connection, _context); - - _clientJmsDelegate = new ClientJmsDelegate(_context); - _client = new Client(_clientJmsDelegate); - _client.start(); - - final RegisterClientCommand registrationCommand = _controllerQueue.getNext(); - createClientQueueProducer(registrationCommand); - - createTestConnection(TEST_CONNECTION_NAME); - createTestSession(TEST_CONNECTION_NAME, TEST_SESSION_NAME); - - assertEquals("Expected no test producers at start of test", 0, _clientJmsDelegate.getNoOfTestProducers()); - assertEquals("Expected no test consumers at start of test", 0, _clientJmsDelegate.getNoOfTestConsumers()); - } - - @Override - protected void tearDown() throws Exception - { - try - { - _controllerQueue.close(); - if (_session != null) - { - _session.close(); - } - } - finally - { - super.tearDown(); - } - } - - public void testClientCanCreateTestProducer() throws Exception - { - assertEquals("Should initially have zero producers", 0, _clientJmsDelegate.getNoOfTestProducers()); - - createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION); - - assertEquals("Should now have one test producer", 1, _clientJmsDelegate.getNoOfTestProducers()); - } - - public void testClientCanCreateTestConsumer() throws Exception - { - assertEquals("Should initially have no test consumers", 0, _clientJmsDelegate.getNoOfTestConsumers()); - - createTestConsumer(TEST_SESSION_NAME, TEST_CONSUMER, TEST_DESTINATION); - - assertEquals("Should now have one test consumer", 1, _clientJmsDelegate.getNoOfTestConsumers()); - } - - public void testClientFailsToCreateSessionUsingInvalidConnection() throws Exception - { - int initialNoOfTestSessions = _clientJmsDelegate.getNoOfTestSessions(); - - createTestSession("nonExistentConnection", TEST_SESSION_NAME, false /* shouldSucceed */); - - assertEquals("Number of test sessions should not have changed", initialNoOfTestSessions, _clientJmsDelegate.getNoOfTestSessions()); - } - - public void testClientFailsToCreateProducerUsingInvalidSession() throws Exception - { - int initialNoOfTestProducers = _clientJmsDelegate.getNoOfTestProducers(); - - createTestProducer("invalidSessionName", TEST_PRODUCER_NAME, TEST_DESTINATION, false /* shouldSucceed */); - - assertEquals("Number of test producers should not have changed", initialNoOfTestProducers, _clientJmsDelegate.getNoOfTestProducers()); - } - - public void testClientFailsToCreateConsumerUsingInvalidSession() throws Exception - { - int initialNoOfTestConsumers = _clientJmsDelegate.getNoOfTestConsumers(); - - createTestConsumer("invalidSessionName", TEST_CONSUMER, TEST_DESTINATION, false /* shouldSucceed */); - - assertEquals("Number of test consumers should not have changed", initialNoOfTestConsumers, _clientJmsDelegate.getNoOfTestConsumers()); - } - - public void testClientCanStartPerformingTests() throws Exception - { - createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION); - - sendCommandToClient(new StartTestCommand()); - - validateStartTestResponseAndParticipantResults(CommandType.PRODUCER_PARTICIPANT_RESULT); - - assertState(_client, RUNNING_TEST); - } - - public void testParticipantsSendResults() throws Exception - { - createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION); - - sendCommandToClient(new StartTestCommand()); - - validateStartTestResponseAndParticipantResults(CommandType.PRODUCER_PARTICIPANT_RESULT); - } - - /** - * Need to validate both of these responses together because their order is non-deterministic - * @param expectedParticipantResultCommandType TODO - */ - private void validateStartTestResponseAndParticipantResults(CommandType expectedParticipantResultCommandType) throws JMSException - { - Map responses = new HashMap(); - _controllerQueue.addNextResponse(responses); - _controllerQueue.addNextResponse(responses); - - ParticipantResult results = (ParticipantResult) responses.get(expectedParticipantResultCommandType); - validateResponse(null, results, true); - - Response startTestResponse = (Response) responses.get(CommandType.RESPONSE); - validateResponse(CommandType.START_TEST, startTestResponse, true); - } - - public void testClientCannotStartPerformingTestsInNonReadyState() throws Exception - { - assertState(_client, READY); - sendCommandAndValidateResponse(new StartTestCommand(), true); - assertState(_client, RUNNING_TEST); - - // Send another start test command - sendCommandAndValidateResponse(new StartTestCommand(), false /*should reject duplicate start command*/); - assertState(_client, RUNNING_TEST); - } - - public void testNonRunningClientIsUnaffectedByStopTestCommand() throws Exception - { - assertState(_client, READY); - - sendCommandAndValidateResponse(new TearDownTestCommand(), false); - - assertState(_client, READY); - } - - private void sendCommandToClient(final Command command) throws Exception - { - final Message message = JmsMessageAdaptor.commandToMessage(_session, command); - _clientQueueProducer.send(message); - ((AMQSession)_session).sync(); - } - - private void sendCommandAndValidateResponse(final Command command, boolean shouldSucceed) throws Exception - { - sendCommandToClient(command); - Response response = _controllerQueue.getNext(); - validateResponse(command.getType(), response, shouldSucceed); - } - - private void sendCommandAndValidateResponse(final Command command) throws Exception - { - sendCommandAndValidateResponse(command, true); - } - - private void createTestConnection(String connectionName) throws Exception - { - int initialNumberOfConnections = _clientJmsDelegate.getNoOfTestConnections(); - - final CreateConnectionCommand createConnectionCommand = new CreateConnectionCommand(); - createConnectionCommand.setConnectionName(connectionName); - createConnectionCommand.setConnectionFactoryName("connectionfactory"); - - sendCommandAndValidateResponse(createConnectionCommand); - - int expectedNumberOfConnections = initialNumberOfConnections + 1; - - assertEquals("unexpected number of test connections", expectedNumberOfConnections, _clientJmsDelegate.getNoOfTestConnections()); - } - - private void createTestSession(String connectionName, String sessionName, boolean shouldSucceed) throws Exception - { - int initialNumberOfSessions = _clientJmsDelegate.getNoOfTestSessions(); - - final CreateSessionCommand createSessionCommand = new CreateSessionCommand(); - createSessionCommand.setConnectionName(connectionName); - createSessionCommand.setSessionName(sessionName); - createSessionCommand.setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); - - sendCommandAndValidateResponse(createSessionCommand, shouldSucceed); - - int expectedNumberOfSessions = initialNumberOfSessions + (shouldSucceed ? 1 : 0); - - assertEquals("unexpected number of test sessions", expectedNumberOfSessions, _clientJmsDelegate.getNoOfTestSessions()); - } - - private void createTestSession(String connectionName, String sessionName) throws Exception - { - createTestSession(connectionName, sessionName, true); - } - - private void createTestProducer(String sessionName, String producerName, String destinationName, boolean shouldSucceed) throws Exception - { - final CreateProducerCommand createProducerCommand = new CreateProducerCommand(); - createProducerCommand.setParticipantName(producerName); - createProducerCommand.setSessionName(sessionName); - createProducerCommand.setDestinationName(destinationName); - createProducerCommand.setNumberOfMessages(100); - - sendCommandAndValidateResponse(createProducerCommand, shouldSucceed); - } - - private void createTestProducer(String sessionName, String producerName, String destinationName) throws Exception - { - createTestProducer(sessionName, producerName, destinationName, true); - } - - private void createTestConsumer(String sessionName, String consumerName, String destinationName, boolean shouldSucceed) throws Exception - { - final CreateConsumerCommand createConsumerCommand = new CreateConsumerCommand(); - createConsumerCommand.setSessionName(sessionName); - createConsumerCommand.setDestinationName(destinationName); - createConsumerCommand.setParticipantName(consumerName); - createConsumerCommand.setNumberOfMessages(1); - - sendCommandAndValidateResponse(createConsumerCommand, shouldSucceed); - } - - private void createTestConsumer(String sessionName, String consumerName, String destinationName) throws Exception - { - createTestConsumer(sessionName, consumerName, destinationName, true); - } - - private void validateResponse(CommandType originatingCommandType, Response response, boolean shouldSucceed) throws JMSException - { - assertEquals("Response is a reply to the wrong command: " + response, - originatingCommandType, - response.getInReplyToCommandType()); - - boolean shouldHaveError = !shouldSucceed; - assertEquals("Response message " + response + " should have indicated hasError=" + shouldHaveError, - shouldHaveError, - response.hasError()); - } - - private void createClientQueueProducer(final RegisterClientCommand registration) throws JMSException - { - final Destination clientCommandQueue = createDestinationFromRegistration(registration); - _clientQueueProducer = _session.createProducer(clientCommandQueue); - } - - private Queue createDestinationFromRegistration(final RegisterClientCommand registrationCommand) throws JMSException - { - String clientQueueName = registrationCommand.getClientQueueName(); - assertNotNull("Null client queue in register message", clientQueueName); - return _session.createQueue(clientQueueName); - } - - private static void assertState(Client client, ClientState expectedState) - { - ClientState clientState = client.getState(); - assertEquals("Client should be in state: " + expectedState + " but is in state " + clientState, expectedState, clientState); - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java deleted file mode 100644 index dcbff6518b..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java +++ /dev/null @@ -1,119 +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.qpid.systest.disttest.clientonly; - -import java.util.HashMap; -import java.util.Map; - -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.qpid.disttest.client.MessageProvider; -import org.apache.qpid.disttest.client.property.PropertyValue; -import org.apache.qpid.disttest.client.property.SimplePropertyValue; -import org.apache.qpid.disttest.message.CreateMessageProviderCommand; -import org.apache.qpid.disttest.message.CreateProducerCommand; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; -import org.apache.qpid.systest.disttest.clientonly.ProducerParticipantTest.TestClientJmsDelegate; - -public class MessageProviderTest extends DistributedTestSystemTestBase -{ - private MessageConsumer _consumer; - private Session _session; - private TestClientJmsDelegate _delegate; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _consumer = _session.createConsumer(getTestQueue()); - _delegate = new TestClientJmsDelegate(getContext()); - } - - public void testMessageSize() throws Exception - { - runSizeTest(0); - runSizeTest(5); - runSizeTest(512); - } - - public void runSizeTest(int size) throws Exception - { - CreateProducerCommand command = new CreateProducerCommand(); - command.setMessageSize(size); - MessageProvider messageProvider = new MessageProvider(null); - Message message = messageProvider.nextMessage(_session, command); - assertNotNull("Message is not generated", message); - assertTrue("Wrong message type", message instanceof TextMessage); - TextMessage textMessage = (TextMessage)message; - String text = textMessage.getText(); - assertNotNull("Message payload is not generated", text); - assertEquals("Message payload size is incorrect", size, text.length()); - } - - public void testCreateMessageProviderAndSendMessage() throws Exception - { - final CreateMessageProviderCommand messageProviderCommand = new CreateMessageProviderCommand(); - messageProviderCommand.setProviderName("test1"); - Map messageProperties = new HashMap(); - messageProperties.put("test", new SimplePropertyValue("testValue")); - messageProperties.put("priority", new SimplePropertyValue(new Integer(9))); - messageProviderCommand.setMessageProperties(messageProperties); - _delegate.createMessageProvider(messageProviderCommand); - - final CreateProducerCommand producerCommand = new CreateProducerCommand(); - producerCommand.setNumberOfMessages(1); - producerCommand.setDeliveryMode(DeliveryMode.PERSISTENT); - producerCommand.setPriority(6); - producerCommand.setParticipantName("test"); - producerCommand.setMessageSize(10); - producerCommand.setSessionName("testSession"); - producerCommand.setDestinationName(getTestQueueName()); - producerCommand.setMessageProviderName(messageProviderCommand.getProviderName()); - - Session session = _connection.createSession(true, Session.SESSION_TRANSACTED); - _delegate.addConnection("name-does-not-matter", _connection); - _delegate.addSession(producerCommand.getSessionName(), session); - _delegate.createProducer(producerCommand); - - Message message = _delegate.sendNextMessage(producerCommand); - session.commit(); - assertMessage(message); - - _connection.start(); - Message receivedMessage = _consumer.receive(1000l); - assertMessage(receivedMessage); - } - - protected void assertMessage(Message message) throws JMSException - { - assertNotNull("Message should not be null", message); - assertEquals("Unexpected test property", "testValue", message.getStringProperty("test")); - assertEquals("Unexpected priority property", 9, message.getJMSPriority()); - assertTrue("Unexpected message type", message instanceof TextMessage); - String text = ((TextMessage)message).getText(); - assertNotNull("Message text should not be null", text); - assertNotNull("Unexpected message size ", text.length()); - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java deleted file mode 100644 index 54bb9efa98..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java +++ /dev/null @@ -1,132 +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.qpid.systest.disttest.clientonly; - -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.Context; - -import org.apache.qpid.disttest.client.Client; -import org.apache.qpid.disttest.client.ParticipantExecutor; -import org.apache.qpid.disttest.client.ProducerParticipant; -import org.apache.qpid.disttest.jms.ClientJmsDelegate; -import org.apache.qpid.disttest.message.CreateProducerCommand; -import org.apache.qpid.disttest.message.ParticipantResult; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; - -public class ProducerParticipantTest extends DistributedTestSystemTestBase -{ - private MessageConsumer _consumer; - private TestClientJmsDelegate _delegate; - private Client _client; - private ControllerQueue _controllerQueue; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - _controllerQueue = new ControllerQueue(_connection, _context); - Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _consumer = session.createConsumer(getTestQueue()); - - _delegate = new TestClientJmsDelegate(getContext()); - _client = new Client(_delegate); - } - - - - @Override - protected void tearDown() throws Exception - { - _controllerQueue.close(); - super.tearDown(); - } - - - - public void testProduceNumberOfMessages() throws Exception - { - runTest(Session.AUTO_ACKNOWLEDGE, 100, 10, 0, 0); - } - - protected void runTest(int acknowledgeMode, int messageSize, int numberOfMessages, int batchSize, long publishInterval) throws Exception - { - final CreateProducerCommand command = new CreateProducerCommand(); - command.setNumberOfMessages(numberOfMessages); - command.setDeliveryMode(DeliveryMode.PERSISTENT); - command.setParticipantName("test"); - command.setMessageSize(messageSize); - command.setBatchSize(batchSize); - command.setInterval(publishInterval); - command.setSessionName("testSession"); - command.setDestinationName(getTestQueueName()); - - Session session = _connection.createSession(Session.SESSION_TRANSACTED == acknowledgeMode, acknowledgeMode); - - _delegate.addConnection("name-does-not-matter", _connection); - _delegate.addSession(command.getSessionName(), session); - _delegate.createProducer(command); - - final ProducerParticipant producer = new ProducerParticipant(_delegate, command); - - new ParticipantExecutor(producer).start(_client); - - _connection.start(); - for (int i = 0; i < numberOfMessages; i++) - { - final Message m = _consumer.receive(1000l); - assertNotNull("Expected message [" + i + "] is not received", m); - assertTrue("Unexpected message", m instanceof TextMessage); - } - Message m = _consumer.receive(500l); - assertNull("Unexpected message", m); - - ParticipantResult results = _controllerQueue.getNext(); - - assertNotNull("no results", results); - assertFalse(results.getStartInMillis() == 0); - assertFalse(results.getEndInMillis() == 0); - } - - static class TestClientJmsDelegate extends ClientJmsDelegate - { - - public TestClientJmsDelegate(Context context) - { - super(context); - } - - @Override - public void addSession(final String sessionName, final Session newSession) - { - super.addSession(sessionName, newSession); - } - - @Override - public void addConnection(final String connectionName, final Connection newConnection) - { - super.addConnection(connectionName, newConnection); - } - } -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java deleted file mode 100644 index ddb4cb7e51..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java +++ /dev/null @@ -1,263 +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.qpid.systest.disttest.controllerandclient; - -import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPONSE_TIMEOUT; -import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT; -import static org.apache.qpid.systest.disttest.SystemTestConstants.TEST_RESULT_TIMEOUT; - -import java.util.Collection; -import java.util.List; - -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.naming.NamingException; - -import org.apache.qpid.disttest.ConfigFileTestHelper; -import org.apache.qpid.disttest.client.Client; -import org.apache.qpid.disttest.client.ClientState; -import org.apache.qpid.disttest.controller.Controller; -import org.apache.qpid.disttest.controller.ResultsForAllTests; -import org.apache.qpid.disttest.controller.TestResult; -import org.apache.qpid.disttest.controller.config.Config; -import org.apache.qpid.disttest.jms.ClientJmsDelegate; -import org.apache.qpid.disttest.jms.ControllerJmsDelegate; -import org.apache.qpid.disttest.message.ConsumerParticipantResult; -import org.apache.qpid.disttest.message.ParticipantResult; -import org.apache.qpid.disttest.message.ProducerParticipantResult; -import org.apache.qpid.disttest.results.aggregation.ITestResult; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ControllerAndClientTest extends DistributedTestSystemTestBase -{ - private static final Logger LOGGER = LoggerFactory.getLogger(ControllerAndClientTest.class); - private static final long CLIENT_BACKGROUND_THREAD_WAIT_TIME = 5000; - - private Controller _controller; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - _controller = new Controller(new ControllerJmsDelegate(_context), REGISTRATION_TIMEOUT, COMMAND_RESPONSE_TIMEOUT); - _controller.setTestResultTimeout(TEST_RESULT_TIMEOUT); - } - - public void testProducerAndConsumerInSeparateClients() throws Exception - { - List resultList = runTestsForTwoClients("producerAndConsumerInSeparateClients.json", 1); - - TestResult testResult1 = resultList.get(0); - assertEquals("Unexpected test name", "Test 1", testResult1.getName()); - List test1ParticipantResults = testResult1.getParticipantResults(); - assertEquals("Unexpected number of participant results for test 1", 2, test1ParticipantResults.size()); - assertParticipantNames(test1ParticipantResults, "participantConsumer1", "participantProducer1"); - ConsumerParticipantResult result = null; - for (ParticipantResult participantResult : test1ParticipantResults) - { - if (participantResult instanceof ConsumerParticipantResult) - { - result = (ConsumerParticipantResult)participantResult; - break; - } - } - assertNotNull("Consumer results not recived", result); - Collection latencies = result.getMessageLatencies(); - assertNotNull("Latency results are not collected", latencies); - assertEquals("Unexpected latency results", 1, latencies.size()); - } - - public void testProducerClient() throws Exception - { - Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = session.createQueue("producerClient"); - MessageConsumer consumer = session.createConsumer(queue); - - // queue is not declared in configuration - // controller is not able to clean it - // cleaning manually - while(consumer.receive(1000l) != null); - - final Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), "produceClient.json"); - _controller.setConfig(config); - final Client client1 = new Client(new ClientJmsDelegate(_context)); - final Thread client1Thread = createBackgroundClientThread(client1); - _controller.awaitClientRegistrations(); - - ResultsForAllTests results = _controller.runAllTests(); - _controller.stopAllRegisteredClients(); - - assertClientThreadsShutdown(client1Thread); - assertClientsStopped(ClientState.STOPPED, client1); - assertFalse("Test should have no errors", results.hasErrors()); - List allTestResults = results.getTestResults(); - assertEquals("Unexpected number of test results", 1, allTestResults.size()); - ITestResult testResult1 = allTestResults.get(0); - assertEquals("Unexpected test name", "Test 1", testResult1.getName()); - List test1ParticipantResults = testResult1.getParticipantResults(); - assertEquals("Unexpected number of participant results for test 1", 1, test1ParticipantResults.size()); - assertParticipantNames(test1ParticipantResults, "participantProducer1"); - - // check message properties - for (int i=0; i< 10; i++) - { - Message message = consumer.receive(1000l); - assertNotNull("Message " + i + " is not received", message); - assertEquals("Unexpected priority", i, message.getJMSPriority()); - assertEquals("Unexpected id", i, message.getIntProperty("id")); - assertEquals("Unexpected test", "test-value", message.getStringProperty("test")); - } - } - - public void testProducerAndThreeConsumersInSeparateClients() throws Exception - { - List resultList = runTestsForTwoClients("producerAndThreeConsumersInSeparateClients.json", 1); - - TestResult testResult1 = resultList.get(0); - List test1ParticipantResults = testResult1.getParticipantResults(); - assertEquals("Unexpected number of participant results for test", 4, test1ParticipantResults.size()); - - assertParticipantNames(test1ParticipantResults, "participantConsumer1", "participantConsumer2", "participantConsumer3", "participantProducer1"); - - ConsumerParticipantResult consumer1 = (ConsumerParticipantResult) test1ParticipantResults.get(0); - assertEquals(3, consumer1.getNumberOfMessagesProcessed()); - assertEquals(true, consumer1.isSynchronousConsumer()); - - ProducerParticipantResult producer1 = (ProducerParticipantResult) test1ParticipantResults.get(3); - assertEquals(9, producer1.getNumberOfMessagesProcessed()); - assertEquals(2, producer1.getBatchSize()); - assertEquals(50, producer1.getInterval()); - } - - public void testIteratingFeature() throws Exception - { - List resultList = runTestsForTwoClients("iteratingFeature.json", 2); - - assertTestResultMessageSize(resultList.get(0), 0, 100, 10); - assertTestResultMessageSize(resultList.get(1), 1, 200, 5); - - } - - private void assertTestResultMessageSize(TestResult testResult, int iterationNumber, int expectedMessageSize, int expectedNumberOfMessages) - { - List test1ParticipantResults = testResult.getParticipantResults(); - assertEquals("Unexpected number of participant results for test", 2, test1ParticipantResults.size()); - - ParticipantResult producer1 = test1ParticipantResults.get(1); - - assertEquals(expectedMessageSize, producer1.getPayloadSize()); - assertEquals(iterationNumber, producer1.getIterationNumber()); - } - - public void testTwoTests() throws Exception - { - List resultList = runTestsForTwoClients("testWithTwoTests.json", 2); - - assertEquals("Test 1", resultList.get(0).getName()); - assertEquals("Test 2", resultList.get(1).getName()); - } - - private List runTestsForTwoClients(String jsonConfigFile, int expectedNumberOfTests) throws NamingException, InterruptedException - { - final Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), jsonConfigFile); - _controller.setConfig(config); - - final Client client1 = new Client(new ClientJmsDelegate(_context)); - final Client client2 = new Client(new ClientJmsDelegate(_context)); - - final Thread client1Thread = createBackgroundClientThread(client1); - final Thread client2Thread = createBackgroundClientThread(client2); - - _controller.awaitClientRegistrations(); - - ResultsForAllTests results = _controller.runAllTests(); - _controller.stopAllRegisteredClients(); - - assertClientThreadsShutdown(client1Thread, client2Thread); - assertClientsStopped(ClientState.STOPPED, client1, client2); - - assertFalse("Test should have no errors", results.hasErrors()); - - List allTestResults = (List)results.getTestResults(); - assertEquals("Unexpected number of test results", expectedNumberOfTests, allTestResults.size()); - - return allTestResults; - } - - - private void assertParticipantNames(List participants, String... expectedOrderedParticipantNames) - { - assertEquals("Size of list of expected participant names is different from actual", expectedOrderedParticipantNames.length, participants.size()); - - for (int i = 0; i < expectedOrderedParticipantNames.length; i++) - { - String expectedParticipantName = expectedOrderedParticipantNames[i]; - ParticipantResult participant = participants.get(i); - assertEquals(expectedParticipantName, participant.getParticipantName()); - } - } - - private void assertClientsStopped(ClientState expectedState, final Client... clients) - { - for (Client client : clients) - { - assertEquals(client.getClientName() + " in unexpected state", expectedState, client.getState()); - } - } - - private void assertClientThreadsShutdown(final Thread... clientThreads) - throws InterruptedException - { - for (Thread clientThread : clientThreads) - { - clientThread.join(2000); - assertFalse(clientThread.getName() + " should have shutdown", clientThread.isAlive()); - } - } - - private Thread createBackgroundClientThread(final Client client) throws NamingException - { - final String clientThreadName = client.getClientName() + "-thread"; - final Thread clientThread = new Thread(new Runnable() - { - @Override - public void run() - { - try - { - client.start(); - client.waitUntilStopped(CLIENT_BACKGROUND_THREAD_WAIT_TIME); - } - finally - { - LOGGER.debug("Client thread {} finished", clientThreadName); - } - } - }, clientThreadName); - clientThread.start(); - return clientThread; - } - -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json deleted file mode 100644 index 89123302b7..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "_tests":[ - { - "_name": "Test iteration feature", - "_iterations":[ - { - "_messageSize": 100, - "_numberOfMessages": 10 - }, - { - "_messageSize": 200, - "_numberOfMessages": 5 - } - ], - "_queues":[ - { - "_name": "direct://amq.direct//testQueue" - } - ], - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer1", - "_destinationName": "direct://amq.direct//testQueue" - } - ] - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_consumers": [ - { - "_name": "participantConsumer1", - "_destinationName": "direct://amq.direct//testQueue" - } - ] - } - ] - } - ] - } - ] - }] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json deleted file mode 100644 index 605e5cb585..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "_tests":[ - { - "_name": "Test 1"; - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer1", - "_destinationName": "direct://amq.direct//producerClient", - "_numberOfMessages": 10; - "_messageProviderName": "testProvider1" - } - ] - } - ] - } - ]; - "_messageProviders":[ - { - "_name": "testProvider1"; - "_messageProperties": { - "priority": {"@def": "list"; "_items": [0,1,2,3,4,5,6,7,8,9]}; - "id": {"@def": "range"; "_upper": 10; "_type": "int"}; - "test": "test-value" - } - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json deleted file mode 100644 index a008dc40d8..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "_tests":[ - { - "_name": "Test 1"; - "_queues":[ - { - "_name": "direct://amq.direct//testQueue" - } - ]; - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 1 - } - ] - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_consumers": [ - { - "_name": "participantConsumer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 1, - "_evaluateLatency": true - } - ] - } - ] - } - ] - } - ] - }] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json deleted file mode 100644 index f94c4f0ae0..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "_tests":[ - { - "_name": "ProducerAndThreeConsumersInSeparateClients"; - "_queues":[ - { - "_name": "direct://amq.direct//testQueue" - } - ]; - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 9, - "_batchSize": 2, - "_interval": 50 - } - ] - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_consumers": [ - { - "_name": "participantConsumer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 3 - } - ] - }, - { - "_sessionName": "session2", - "_consumers": [ - { - "_name": "participantConsumer2", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 3 - } - ] - }, - { - "_sessionName": "session3", - "_consumers": [ - { - "_name": "participantConsumer3", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 3 - } - ] - } - ] - } - ] - } - ] - }] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json deleted file mode 100644 index 4abd7f4feb..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "_tests":[ - { - "_name": "Test 1"; - "_queues":[ - { - "_name": "direct://amq.direct//testQueue" - } - ]; - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 1 - } - ] - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_consumers": [ - { - "_name": "participantconsumer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 1 - } - ] - } - ] - } - ] - } - ] - }, - { - "_name": "Test 2"; - "_queues":[ - { - "_name": "direct://amq.direct//testQueue2" - } - ]; - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer2", - "_destinationName": "direct://amq.direct//testQueue2", - "_numberOfMessages": 1 - } - ] - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_consumers": [ - { - "_name": "participantConsumer2", - "_destinationName": "direct://amq.direct//testQueue2", - "_numberOfMessages": 1 - } - ] - } - ] - } - ] - } - ] - }] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java deleted file mode 100644 index 74c4724901..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java +++ /dev/null @@ -1,157 +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.qpid.systest.disttest.controlleronly; - -import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPONSE_TIMEOUT; -import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT; - -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TemporaryQueue; - -import org.apache.qpid.disttest.ConfigFileTestHelper; -import org.apache.qpid.disttest.controller.Controller; -import org.apache.qpid.disttest.controller.config.Config; -import org.apache.qpid.disttest.jms.ControllerJmsDelegate; -import org.apache.qpid.disttest.jms.JmsMessageAdaptor; -import org.apache.qpid.disttest.message.Command; -import org.apache.qpid.disttest.message.CommandType; -import org.apache.qpid.disttest.message.RegisterClientCommand; -import org.apache.qpid.disttest.message.Response; -import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DistributedControllerTest extends DistributedTestSystemTestBase -{ - private static final Logger LOGGER = LoggerFactory.getLogger(DistributedControllerTest.class); - - private static final String CLIENT1 = "client1"; - private Controller _controller = null; - private Session _session = null; - private Connection _connection = null; - private Destination _controllerQueue = null; - private TemporaryQueue _clientQueue = null; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - _controllerQueue = (Destination) _context.lookup("controllerqueue"); - - final ConnectionFactory connectionFactory = (ConnectionFactory) _context.lookup("connectionfactory"); - _connection = connectionFactory.createConnection(); - _connection.start(); - _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - _clientQueue = _session.createTemporaryQueue(); - - _controller = new Controller(new ControllerJmsDelegate(_context), REGISTRATION_TIMEOUT, COMMAND_RESPONSE_TIMEOUT); - } - - @Override - protected void tearDown() throws Exception - { - try - { - if (_connection != null) - { - _connection.close(); - } - } - finally - { - super.tearDown(); - } - } - - public void testControllerSendsOneCommandToSingleClient() throws Exception - { - Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), "distributedControllerTest.json"); - _controller.setConfig(config); - - sendRegistration(CLIENT1); - _controller.awaitClientRegistrations(); - - final ArrayBlockingQueue commandList = new ArrayBlockingQueue(4); - final MessageConsumer clientConsumer = _session.createConsumer(_clientQueue); - final AtomicReference listenerException = new AtomicReference(); - final MessageProducer producer = _session.createProducer(_controllerQueue); - clientConsumer.setMessageListener(new MessageListener() - { - @Override - public void onMessage(Message message) - { - try - { - Command command = JmsMessageAdaptor.messageToCommand(message); - LOGGER.debug("Test client received " + command); - commandList.add(command); - producer.send(JmsMessageAdaptor.commandToMessage(_session, new Response(CLIENT1, command.getType()))); - } - catch(Exception e) - { - listenerException.set(e); - } - } - }); - - _controller.runAllTests(); - assertCommandType(CommandType.CREATE_CONNECTION, commandList); - assertCommandType(CommandType.START_TEST, commandList); - assertCommandType(CommandType.TEAR_DOWN_TEST, commandList); - - _controller.stopAllRegisteredClients(); - assertCommandType(CommandType.STOP_CLIENT, commandList); - assertNull("Unexpected exception occured", listenerException.get()); - Command command = commandList.poll(1l, TimeUnit.SECONDS); - assertNull("Unexpected command is received", command); - } - - private void assertCommandType(CommandType expectedType, BlockingQueue commandList) throws InterruptedException - { - Command command = commandList.poll(1l, TimeUnit.SECONDS); - assertNotNull("Command of type " + expectedType + " is not received", command); - assertEquals("Unexpected command type", expectedType, command.getType()); - } - - private void sendRegistration(final String clientId) throws JMSException - { - final MessageProducer registrationProducer = _session.createProducer(_controllerQueue); - - final Command command = new RegisterClientCommand(clientId, _clientQueue.getQueueName()); - final Message registrationMessage = JmsMessageAdaptor.commandToMessage(_session, command); - registrationProducer.send(registrationMessage); - LOGGER.debug("sent registrationMessage: " + registrationMessage); - } - -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json deleted file mode 100644 index b49603ef23..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "_tests":[ - { - "_name": "Test 1"; - "_clients":[ - { - "_name": "client1", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory" - } - ] - } - ] - }] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java deleted file mode 100644 index a0c2a4b342..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java +++ /dev/null @@ -1,100 +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.qpid.systest.disttest.endtoend; - -import static org.apache.qpid.disttest.AbstractRunner.JNDI_CONFIG_PROP; -import static org.apache.qpid.disttest.ControllerRunner.OUTPUT_DIR_PROP; -import static org.apache.qpid.disttest.ControllerRunner.RUN_ID; -import static org.apache.qpid.disttest.ControllerRunner.TEST_CONFIG_PROP; -import static org.apache.qpid.disttest.ControllerRunner.WRITE_TO_DB; - -import java.io.File; -import java.io.IOException; - -import org.apache.qpid.disttest.ControllerRunner; -import org.apache.qpid.disttest.message.ParticipantAttribute; -import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; -import org.apache.qpid.test.utils.QpidBrokerTestCase; -import org.apache.qpid.util.FileUtils; - -public class EndToEndTest extends QpidBrokerTestCase -{ - private ControllerRunner _runner; - private static final String TEST_CONFIG = "perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json"; - private static final String JNDI_CONFIG_FILE = "perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties"; - private static final String RUN1 = "run1"; - - public void testRunner() throws Exception - { - File csvOutputDir = createTemporaryCsvDirectory(); - assertTrue("CSV output dir must not exist",csvOutputDir.isDirectory()); - - final String[] args = new String[] {TEST_CONFIG_PROP + "=" + TEST_CONFIG, - JNDI_CONFIG_PROP + "=" + JNDI_CONFIG_FILE, - WRITE_TO_DB + "=true", - RUN_ID + "=" + RUN1, - OUTPUT_DIR_PROP + "=" + csvOutputDir.getAbsolutePath()}; - _runner = new ControllerRunner(); - _runner.parseArgumentsIntoConfig(args); - _runner.runController(); - - File expectedCsvOutputFile = new File(csvOutputDir, "endtoend.csv"); - assertTrue("CSV output file must exist", expectedCsvOutputFile.exists()); - final String csvContents = FileUtils.readFileAsString(expectedCsvOutputFile); - final String[] csvLines = csvContents.split("\n"); - - int numberOfHeaders = 1; - int numberOfParticipants = 2; - int numberOfSummaries = 3; - - int numberOfExpectedRows = numberOfHeaders + numberOfParticipants + numberOfSummaries; - assertEquals("Unexpected number of lines in CSV", numberOfExpectedRows, csvLines.length); - - assertDataRowsHaveCorrectTestAndClientName("End To End 1", "producingClient", "participantProducer1", csvLines[1], 1); - assertDataRowsHaveCorrectTestAndClientName("End To End 1", "consumingClient", "participantConsumer1", csvLines[3], 1); - - assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PARTICIPANTS_NAME, csvLines[4], 1); - assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME, csvLines[2], 1); - assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PRODUCER_PARTICIPANTS_NAME, csvLines[5], 1); - - } - - private void assertDataRowsHaveCorrectTestAndClientName(String testName, String clientName, String participantName, String csvLine, int expectedNumberOfMessagesProcessed) - { - final int DONT_STRIP_EMPTY_LAST_FIELD_FLAG = -1; - String[] cells = csvLine.split(",", DONT_STRIP_EMPTY_LAST_FIELD_FLAG); - // All attributes become cells in the CSV, so this will be true - assertEquals("Unexpected number of cells in CSV line " + csvLine, ParticipantAttribute.values().length, cells.length); - assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[ParticipantAttribute.TEST_NAME.ordinal()]); - assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[ParticipantAttribute.CONFIGURED_CLIENT_NAME.ordinal()]); - assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[ParticipantAttribute.PARTICIPANT_NAME.ordinal()]); - assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED.ordinal()]); - - } - - private File createTemporaryCsvDirectory() throws IOException - { - String tmpDir = System.getProperty("java.io.tmpdir"); - File csvDir = new File(tmpDir, "csv"); - csvDir.mkdir(); - csvDir.deleteOnExit(); - return csvDir; - } - -} diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json deleted file mode 100644 index 1b7cc51265..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "_tests":[ - { - "_name": "End To End 1"; - "_queues":[ - { - "_name": "direct://amq.direct//testQueue" - } - ]; - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_producers": [ - { - "_name": "participantProducer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 1 - } - ] - } - ]; - "_messageProviders":[ - { - "_name": "testProvider1"; - "_messageProperties": { - "priority": {"@def": "list"; "_items": [1,2,3,4,4]}; - "id": {"@def": "random"; "_upper": 10}; - "test": "test-value" - } - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_consumers": [ - { - "_name": "participantConsumer1", - "_destinationName": "direct://amq.direct//testQueue", - "_numberOfMessages": 1 - } - ] - } - ] - } - ] - } - ] - }] -} \ No newline at end of file diff --git a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties b/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties deleted file mode 100644 index 149e632048..0000000000 --- a/qpid/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties +++ /dev/null @@ -1,29 +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. - -# this file is used for running system tests of the performance test framework, -# (i.e. not for running the performance tests themselves!) - -java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory - -# use QpidBrokerTestCase's default port -connectionfactory.connectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:15672' - -destination.controllerqueue = direct://amq.direct//controllerqueue - -jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver -jdbcUrl=jdbc:derby:/tmp/tempDbDirectory/perftestResultsDb;create=true diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index 3f3577d93a..b9b7eafac1 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -108,6 +108,7 @@ qpid-test-utils systests perftests + qpid-perftests-systests perftests/visualisation-jfc bdbstore @@ -330,6 +331,15 @@ org.apache.rat apache-rat-plugin + + + build/** + resources/** + test-profiles/** + release-docs/** + lib/** + + @@ -387,6 +397,15 @@ org.apache.rat apache-rat-plugin ${apache-rat-plugin-version} + + + build/** + resources/** + test-profiles/** + release-docs/** + lib/** + + diff --git a/qpid/java/qpid-perftests-systests/build.xml b/qpid/java/qpid-perftests-systests/build.xml new file mode 100644 index 0000000000..3d82ee5e7e --- /dev/null +++ b/qpid/java/qpid-perftests-systests/build.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qpid/java/qpid-perftests-systests/pom.xml b/qpid/java/qpid-perftests-systests/pom.xml new file mode 100644 index 0000000000..6856fd9d17 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/pom.xml @@ -0,0 +1,116 @@ + + + + 4.0.0 + + + org.apache.qpid + qpid-systests-parent + 0.28-SNAPSHOT + ../qpid-systests-parent/pom.xml + + + qpid-perftests-systests + Qpid Performance Test System Tests + System testing using the performance testing module + + + ${basedir}/../systests + + + + + org.apache.qpid + qpid-perftests + ${project.version} + + + + org.apache.qpid + qpid-systests + ${project.version} + + + + + org.apache.qpid + qpid-client + ${project.version} + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + provided + + + + + commons-lang + commons-lang + + + + commons-collections + commons-collections + + + + commons-beanutils + commons-beanutils-core + + + + com.google.code.gson + gson + + + + org.apache.derby + derby + runtime + + + + + + + + src/test/java + + **/*.java + + + + src/test/resources + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + true + + + + + + diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/ConfigFileTestHelper.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/ConfigFileTestHelper.java new file mode 100644 index 0000000000..a4f4cab018 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/ConfigFileTestHelper.java @@ -0,0 +1,48 @@ +/* + * 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.qpid.systest.disttest; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; + +import org.apache.qpid.disttest.controller.config.Config; +import org.apache.qpid.disttest.controller.config.ConfigReader; + +public class ConfigFileTestHelper +{ + public static Reader getConfigFileReader(Class testClass, String resourceName) + { + InputStream inputStream = testClass.getResourceAsStream(resourceName); + if(inputStream == null) + { + throw new RuntimeException("Can't find resource " + resourceName + " using classloader of class " + testClass); + } + Reader reader = new InputStreamReader(inputStream); + return reader; + } + + public static Config getConfigFromResource(Class testClass, String resourceName) + { + ConfigReader configReader = new ConfigReader(); + Config config = configReader.readConfig(getConfigFileReader(testClass, resourceName)); + return config; + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/DistributedTestSystemTestBase.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/DistributedTestSystemTestBase.java new file mode 100644 index 0000000000..96daf64526 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/DistributedTestSystemTestBase.java @@ -0,0 +1,72 @@ +/* + * 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.qpid.systest.disttest; + +import java.util.Properties; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.apache.qpid.test.utils.QpidBrokerTestCase; + +public class DistributedTestSystemTestBase extends QpidBrokerTestCase +{ + protected Context _context; + + protected Connection _connection; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + final Properties properties = new Properties(); + properties.load(DistributedTestSystemTestBase.class.getResourceAsStream("perftests.systests.properties")); + _context = new InitialContext(properties); + + _connection = getConnection(); + _connection.start(); + } + + @Override + protected void tearDown() throws Exception + { + // no need to close connections - this is done by superclass + + super.tearDown(); + } + + public Context getContext() + { + return _context; + } + + @Override + public Connection getConnection() throws JMSException, NamingException + { + final ConnectionFactory connectionFactory = (ConnectionFactory) _context.lookup("connectionfactory"); + final Connection connection = connectionFactory.createConnection(); + _connections.add(connection); + return connection; + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java new file mode 100644 index 0000000000..59396d46c0 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java @@ -0,0 +1,100 @@ +/* + * 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.qpid.systest.disttest; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jms.Connection; +import javax.jms.Session; + +import org.apache.qpid.client.AMQDestination; +import org.apache.qpid.client.AMQSession; +import org.apache.qpid.disttest.controller.config.QueueConfig; +import org.apache.qpid.disttest.jms.QpidQueueCreator; + +public class QpidQueueCreatorTest extends DistributedTestSystemTestBase +{ + private static final Map EMPTY_ATTRIBUTES = Collections.emptyMap(); + + private static final boolean QUEUE_DURABILITY = true; + + private Connection _connection; + private QpidQueueCreator _creator; + private Session _session; + private List _configs; + private String _queueName; + + @Override + public void setUp() throws Exception + { + super.setUp(); + _connection = getConnection(); + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _creator = new QpidQueueCreator(); + _configs = new ArrayList(); + _queueName = "direct://amq.direct//" + getTestQueueName() + "?durable='" + QUEUE_DURABILITY + "'"; + } + + public void testCreateQueueWithoutAttributes() throws Exception + { + _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES)); + + assertQueueBound(_queueName, false); + + _creator.createQueues(_connection, _session, _configs); + + assertQueueBound(_queueName, true); + } + + public void testCreateWithAttributes() throws Exception + { + Map attributes = new HashMap(); + attributes.put("x-qpid-priorities", Integer.valueOf(5)); + _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, attributes)); + + assertQueueBound(_queueName, false); + + _creator.createQueues(_connection, _session, _configs); + + assertQueueBound(_queueName, true); + } + + public void testDeleteQueues() throws Exception + { + _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES)); + + assertQueueBound(_queueName, false); + + _creator.createQueues(_connection, _session, _configs); + assertQueueBound(_queueName, true); + + _creator.deleteQueues(_connection, _session, _configs); + assertQueueBound(_queueName, false); + } + + private void assertQueueBound(String queueName, boolean isBound) throws Exception + { + AMQDestination destination = (AMQDestination)_session.createQueue(queueName); + assertEquals("Queue is not in expected bound state", isBound, ((AMQSession)_session).isQueueBound(destination)); + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/SystemTestConstants.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/SystemTestConstants.java new file mode 100644 index 0000000000..b06ab0c735 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/SystemTestConstants.java @@ -0,0 +1,28 @@ +/* + * 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.qpid.systest.disttest; + +public abstract class SystemTestConstants +{ + public static final long REGISTRATION_TIMEOUT = 20000; + public static final long COMMAND_RESPONSE_TIMEOUT = 30000; + public static final long TEST_RESULT_TIMEOUT = 20000; + +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java new file mode 100644 index 0000000000..d599bdc5c4 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/BasicDistributedClientTest.java @@ -0,0 +1,186 @@ +/* + * 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.qpid.systest.disttest.clientonly; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; + +import org.apache.qpid.disttest.client.Client; +import org.apache.qpid.disttest.client.ClientState; +import org.apache.qpid.disttest.jms.ClientJmsDelegate; +import org.apache.qpid.disttest.jms.JmsMessageAdaptor; +import org.apache.qpid.disttest.message.Command; +import org.apache.qpid.disttest.message.CommandType; +import org.apache.qpid.disttest.message.CreateConnectionCommand; +import org.apache.qpid.disttest.message.CreateSessionCommand; +import org.apache.qpid.disttest.message.NoOpCommand; +import org.apache.qpid.disttest.message.RegisterClientCommand; +import org.apache.qpid.disttest.message.Response; +import org.apache.qpid.disttest.message.StopClientCommand; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; + +public class BasicDistributedClientTest extends DistributedTestSystemTestBase +{ + private Session _session = null; + private MessageProducer _clientQueueProducer; + private Client _client; + private ControllerQueue _controllerQueue; + private ClientJmsDelegate _clientJmsDelegate = null; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _controllerQueue = new ControllerQueue(_connection, _context); + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + _clientJmsDelegate = new ClientJmsDelegate(_context); + _client = new Client(_clientJmsDelegate); + _client.start(); + } + + @Override + protected void tearDown() throws Exception + { + try + { + _controllerQueue.close(); + if (_session != null) + { + _session.close(); + } + } + finally + { + super.tearDown(); + } + } + + public void testClientSendsRegistrationMessage() throws Exception + { + final RegisterClientCommand regClientCommand = _controllerQueue.getNext(); + + assertNotNull("Client must have a non-null name", regClientCommand.getClientName()); + assertEquals("Unexpected client name", _clientJmsDelegate.getClientName(), regClientCommand.getClientName()); + assertNotNull("Client queue name should not be null", regClientCommand.getClientQueueName()); + } + + public void testClientSendsCommandResponses() throws Exception + { + final RegisterClientCommand registrationCommand = _controllerQueue.getNext(); + createClientQueueProducer(registrationCommand); + + sendCommandToClient(new NoOpCommand()); + + final Response responseCommand = _controllerQueue.getNext(); + assertEquals("Incorrect client message type", CommandType.RESPONSE, responseCommand.getType()); + } + + public void testClientCanBeStoppedViaCommand() throws Exception + { + assertEquals("Expected client to be in STARTED state", ClientState.READY, _client.getState()); + + final RegisterClientCommand registrationCommand = _controllerQueue.getNext(); + createClientQueueProducer(registrationCommand); + + final Command stopClientCommand = new StopClientCommand(); + sendCommandToClient(stopClientCommand); + + _client.waitUntilStopped(1000); + + Response response = _controllerQueue.getNext(); + assertNotNull(response); + assertFalse("response shouldn't contain error", response.hasError()); + + assertEquals("Expected client to be in STOPPED state", ClientState.STOPPED, _client.getState()); + } + + public void testClientCanCreateTestConnection() throws Exception + { + assertEquals("Unexpected number of test connections", 0, _clientJmsDelegate.getNoOfTestConnections()); + + final RegisterClientCommand registration = _controllerQueue.getNext(); + createClientQueueProducer(registration); + + final CreateConnectionCommand createConnectionCommand = new CreateConnectionCommand(); + createConnectionCommand.setConnectionName("newTestConnection"); + createConnectionCommand.setConnectionFactoryName("connectionfactory"); + + sendCommandToClient(createConnectionCommand); + Response response = _controllerQueue.getNext(); + + assertFalse("Response message should not have indicated an error", response.hasError()); + assertEquals("Unexpected number of test connections", 1, _clientJmsDelegate.getNoOfTestConnections()); + } + + public void testClientCanCreateTestSession() throws Exception + { + assertEquals("Unexpected number of test sessions", 0, _clientJmsDelegate.getNoOfTestSessions()); + + final RegisterClientCommand registration = _controllerQueue.getNext(); + createClientQueueProducer(registration); + + final CreateConnectionCommand createConnectionCommand = new CreateConnectionCommand(); + createConnectionCommand.setConnectionName("newTestConnection"); + createConnectionCommand.setConnectionFactoryName("connectionfactory"); + + sendCommandToClient(createConnectionCommand); + Response response = _controllerQueue.getNext(); + assertFalse("Response message should not have indicated an error", response.hasError()); + + final CreateSessionCommand createSessionCommand = new CreateSessionCommand(); + createSessionCommand.setConnectionName("newTestConnection"); + createSessionCommand.setSessionName("newTestSession"); + createSessionCommand.setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); + + sendCommandToClient(createSessionCommand); + response = _controllerQueue.getNext(); + + assertFalse("Response message should not have indicated an error", response.hasError()); + assertEquals("Unexpected number of test sessions", 1, _clientJmsDelegate.getNoOfTestSessions()); + } + + private void sendCommandToClient(final Command command) throws JMSException + { + final Message message = JmsMessageAdaptor.commandToMessage(_session, command); + _clientQueueProducer.send(message); + } + + private void createClientQueueProducer( + final RegisterClientCommand registration) throws JMSException + { + final Destination clientCommandQueue = createDestinationFromRegistration(registration); + _clientQueueProducer = _session.createProducer(clientCommandQueue); + } + + private Queue createDestinationFromRegistration( + final RegisterClientCommand registrationCommand) + throws JMSException + { + String clientQueueName = registrationCommand.getClientQueueName(); + assertNotNull("Null client queue in register message", clientQueueName); + return _session.createQueue(clientQueueName); + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java new file mode 100644 index 0000000000..a3c0430865 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ConsumerParticipantTest.java @@ -0,0 +1,156 @@ +/* + * 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.qpid.systest.disttest.clientonly; + +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; + +import org.apache.qpid.disttest.client.Client; +import org.apache.qpid.disttest.client.ConsumerParticipant; +import org.apache.qpid.disttest.client.ParticipantExecutor; +import org.apache.qpid.disttest.message.CreateConsumerCommand; +import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; +import org.apache.qpid.systest.disttest.clientonly.ProducerParticipantTest.TestClientJmsDelegate; + +public class ConsumerParticipantTest extends DistributedTestSystemTestBase +{ + private MessageProducer _producer; + private Session _session; + private TestClientJmsDelegate _delegate; + private Client _client; + private ControllerQueue _controllerQueue; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _controllerQueue = new ControllerQueue(_connection, _context); + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _producer = _session.createProducer(getTestQueue()); + + _delegate = new TestClientJmsDelegate(getContext()); + _client = new Client(_delegate); + } + + + @Override + protected void tearDown() throws Exception + { + _controllerQueue.close(); + super.tearDown(); + } + + public void testConsumeNumberOfMessagesSynchronously() throws Exception + { + runTest(Session.AUTO_ACKNOWLEDGE, 10, 0, true); + } + + public void testConsumeNumberOfMessagesAsynchronously() throws Exception + { + runTest(Session.AUTO_ACKNOWLEDGE, 10, 0, false); + } + + public void testSelectors() throws Exception + { + final CreateConsumerCommand command = new CreateConsumerCommand(); + command.setNumberOfMessages(10); + command.setSessionName("testSession"); + command.setDestinationName(getTestQueueName()); + command.setSelector("id=1"); + Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + _delegate.addConnection("name-does-not-matter", _connection); + _delegate.addSession(command.getSessionName(), session); + + ConsumerParticipant consumerParticipant = new ConsumerParticipant(_delegate, command); + _delegate.createConsumer(command); + + for (int i = 0; i < 20; i++) + { + Message message = _session.createMessage(); + if (i % 2 == 0) + { + message.setIntProperty("id", 0); + } + else + { + message.setIntProperty("id", 1); + } + _producer.send(message); + } + + new ParticipantExecutor(consumerParticipant).start(_client); + + ParticipantResult results = _controllerQueue.getNext(); + assertNotNull("No results message recieved", results); + assertEquals("Unexpected number of messages received", 10, results.getNumberOfMessagesProcessed()); + + Session testQueueConsumerSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final MessageConsumer testQueueConsumer = testQueueConsumerSession.createConsumer(getTestQueue()); + for (int i = 0; i < 10; i++) + { + Message message = testQueueConsumer.receive(2000); + assertNotNull("Message is not received: " + message, message); + assertEquals("Unexpected id value", 0, message.getIntProperty("id")); + } + Message message = testQueueConsumer.receive(2000); + assertNull("Unexpected message remaining on test queue: " + message, message); + + _connection.stop(); + } + + protected void runTest(int acknowledgeMode, int numberOfMessages, int batchSize, boolean synchronous) throws Exception + { + final CreateConsumerCommand command = new CreateConsumerCommand(); + command.setNumberOfMessages(numberOfMessages); + command.setBatchSize(batchSize); + command.setSessionName("testSession"); + command.setDestinationName(getTestQueueName()); + command.setSynchronous(synchronous); + + Session session = _connection.createSession(Session.SESSION_TRANSACTED == acknowledgeMode, acknowledgeMode); + + _delegate.addConnection("name-does-not-matter", _connection); + _delegate.addSession(command.getSessionName(), session); + + ConsumerParticipant consumerParticipant = new ConsumerParticipant(_delegate, command); + _delegate.createConsumer(command); + + for (int i = 0; i < numberOfMessages; i++) + { + _producer.send(_session.createMessage()); + } + + new ParticipantExecutor(consumerParticipant).start(_client); + + ParticipantResult results = _controllerQueue.getNext(); + assertNotNull("No results message recieved", results); + + Session testQueueConsumerSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + final MessageConsumer testQueueConsumer = testQueueConsumerSession.createConsumer(getTestQueue()); + Message message = testQueueConsumer.receive(2000); + assertNull("Unexpected message remaining on test queue: " + message, message); + + _connection.stop(); + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java new file mode 100644 index 0000000000..75783eef4b --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ControllerQueue.java @@ -0,0 +1,110 @@ +/* + * + * 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.qpid.systest.disttest.clientonly; + +import java.util.Map; + +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.naming.Context; + +import junit.framework.Assert; + +import org.apache.qpid.disttest.DistributedTestConstants; +import org.apache.qpid.disttest.jms.JmsMessageAdaptor; +import org.apache.qpid.disttest.message.Command; +import org.apache.qpid.disttest.message.CommandType; + +/** + * Helper for unit tests to simplify access to the Controller Queue. + * + * Implicitly creates the queue, so you must create a {@link ControllerQueue} object before + * trying to use the underlying queue. + */ +public class ControllerQueue +{ + private MessageConsumer _controllerQueueMessageConsumer; + private Session _controllerQueueSession; + + /** + * Implicitly creates the queue, so you must create a {@link ControllerQueue} object before + * trying to use the underlying queue. + * + * @param context used for looking up the controller queue {@link Destination} + */ + public ControllerQueue(Connection connection, Context context) throws Exception + { + _controllerQueueSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination controllerQueue = (Destination) context.lookup(DistributedTestConstants.CONTROLLER_QUEUE_JNDI_NAME); + _controllerQueueMessageConsumer = _controllerQueueSession.createConsumer(controllerQueue); + } + + public T getNext(long timeout) throws JMSException + { + final Message message = _controllerQueueMessageConsumer.receive(timeout); + if(message == null) + { + return null; + } + + return (T) JmsMessageAdaptor.messageToCommand(message); + } + + public void addNextResponse(Map responses) throws JMSException + { + Command nextResponse = getNext(); + responses.put(nextResponse.getType(), nextResponse); + } + + @SuppressWarnings("unchecked") + public T getNext() throws JMSException + { + return (T)getNext(true); + } + + public T getNext(boolean assertMessageExists) throws JMSException + { + final Message message = _controllerQueueMessageConsumer.receive(2000); + if(assertMessageExists) + { + Assert.assertNotNull("No message received from control queue", message); + } + + if(message == null) + { + return null; + } + + T command = (T) JmsMessageAdaptor.messageToCommand(message); + + return command; + } + + public void close() throws Exception + { + _controllerQueueMessageConsumer.close(); + _controllerQueueSession.close(); + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java new file mode 100644 index 0000000000..5b5a60ac43 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/DistributedClientTest.java @@ -0,0 +1,325 @@ +/* + * 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.qpid.systest.disttest.clientonly; + +import static org.apache.qpid.disttest.client.ClientState.READY; +import static org.apache.qpid.disttest.client.ClientState.RUNNING_TEST; + +import java.util.HashMap; +import java.util.Map; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.Queue; +import javax.jms.Session; + +import org.apache.qpid.client.AMQSession; +import org.apache.qpid.disttest.client.Client; +import org.apache.qpid.disttest.client.ClientState; +import org.apache.qpid.disttest.jms.ClientJmsDelegate; +import org.apache.qpid.disttest.jms.JmsMessageAdaptor; +import org.apache.qpid.disttest.message.Command; +import org.apache.qpid.disttest.message.CommandType; +import org.apache.qpid.disttest.message.CreateConnectionCommand; +import org.apache.qpid.disttest.message.CreateConsumerCommand; +import org.apache.qpid.disttest.message.CreateProducerCommand; +import org.apache.qpid.disttest.message.CreateSessionCommand; +import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.disttest.message.RegisterClientCommand; +import org.apache.qpid.disttest.message.Response; +import org.apache.qpid.disttest.message.StartTestCommand; +import org.apache.qpid.disttest.message.TearDownTestCommand; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; + +public class DistributedClientTest extends DistributedTestSystemTestBase +{ + private static final String TEST_CONSUMER = "newTestConsumer"; + private static final String TEST_DESTINATION = "newDestination"; + private static final String TEST_PRODUCER_NAME = "newTestProducer"; + private static final String TEST_SESSION_NAME = "newTestSession"; + private static final String TEST_CONNECTION_NAME = "newTestConnection"; + + private Session _session = null; + private MessageProducer _clientQueueProducer; + private Client _client; + private ControllerQueue _controllerQueue; + protected ClientJmsDelegate _clientJmsDelegate; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _controllerQueue = new ControllerQueue(_connection, _context); + + _clientJmsDelegate = new ClientJmsDelegate(_context); + _client = new Client(_clientJmsDelegate); + _client.start(); + + final RegisterClientCommand registrationCommand = _controllerQueue.getNext(); + createClientQueueProducer(registrationCommand); + + createTestConnection(TEST_CONNECTION_NAME); + createTestSession(TEST_CONNECTION_NAME, TEST_SESSION_NAME); + + assertEquals("Expected no test producers at start of test", 0, _clientJmsDelegate.getNoOfTestProducers()); + assertEquals("Expected no test consumers at start of test", 0, _clientJmsDelegate.getNoOfTestConsumers()); + } + + @Override + protected void tearDown() throws Exception + { + try + { + _controllerQueue.close(); + if (_session != null) + { + _session.close(); + } + } + finally + { + super.tearDown(); + } + } + + public void testClientCanCreateTestProducer() throws Exception + { + assertEquals("Should initially have zero producers", 0, _clientJmsDelegate.getNoOfTestProducers()); + + createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION); + + assertEquals("Should now have one test producer", 1, _clientJmsDelegate.getNoOfTestProducers()); + } + + public void testClientCanCreateTestConsumer() throws Exception + { + assertEquals("Should initially have no test consumers", 0, _clientJmsDelegate.getNoOfTestConsumers()); + + createTestConsumer(TEST_SESSION_NAME, TEST_CONSUMER, TEST_DESTINATION); + + assertEquals("Should now have one test consumer", 1, _clientJmsDelegate.getNoOfTestConsumers()); + } + + public void testClientFailsToCreateSessionUsingInvalidConnection() throws Exception + { + int initialNoOfTestSessions = _clientJmsDelegate.getNoOfTestSessions(); + + createTestSession("nonExistentConnection", TEST_SESSION_NAME, false /* shouldSucceed */); + + assertEquals("Number of test sessions should not have changed", initialNoOfTestSessions, _clientJmsDelegate.getNoOfTestSessions()); + } + + public void testClientFailsToCreateProducerUsingInvalidSession() throws Exception + { + int initialNoOfTestProducers = _clientJmsDelegate.getNoOfTestProducers(); + + createTestProducer("invalidSessionName", TEST_PRODUCER_NAME, TEST_DESTINATION, false /* shouldSucceed */); + + assertEquals("Number of test producers should not have changed", initialNoOfTestProducers, _clientJmsDelegate.getNoOfTestProducers()); + } + + public void testClientFailsToCreateConsumerUsingInvalidSession() throws Exception + { + int initialNoOfTestConsumers = _clientJmsDelegate.getNoOfTestConsumers(); + + createTestConsumer("invalidSessionName", TEST_CONSUMER, TEST_DESTINATION, false /* shouldSucceed */); + + assertEquals("Number of test consumers should not have changed", initialNoOfTestConsumers, _clientJmsDelegate.getNoOfTestConsumers()); + } + + public void testClientCanStartPerformingTests() throws Exception + { + createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION); + + sendCommandToClient(new StartTestCommand()); + + validateStartTestResponseAndParticipantResults(CommandType.PRODUCER_PARTICIPANT_RESULT); + + assertState(_client, RUNNING_TEST); + } + + public void testParticipantsSendResults() throws Exception + { + createTestProducer(TEST_SESSION_NAME, TEST_PRODUCER_NAME, TEST_DESTINATION); + + sendCommandToClient(new StartTestCommand()); + + validateStartTestResponseAndParticipantResults(CommandType.PRODUCER_PARTICIPANT_RESULT); + } + + /** + * Need to validate both of these responses together because their order is non-deterministic + * @param expectedParticipantResultCommandType TODO + */ + private void validateStartTestResponseAndParticipantResults(CommandType expectedParticipantResultCommandType) throws JMSException + { + Map responses = new HashMap(); + _controllerQueue.addNextResponse(responses); + _controllerQueue.addNextResponse(responses); + + ParticipantResult results = (ParticipantResult) responses.get(expectedParticipantResultCommandType); + validateResponse(null, results, true); + + Response startTestResponse = (Response) responses.get(CommandType.RESPONSE); + validateResponse(CommandType.START_TEST, startTestResponse, true); + } + + public void testClientCannotStartPerformingTestsInNonReadyState() throws Exception + { + assertState(_client, READY); + sendCommandAndValidateResponse(new StartTestCommand(), true); + assertState(_client, RUNNING_TEST); + + // Send another start test command + sendCommandAndValidateResponse(new StartTestCommand(), false /*should reject duplicate start command*/); + assertState(_client, RUNNING_TEST); + } + + public void testNonRunningClientIsUnaffectedByStopTestCommand() throws Exception + { + assertState(_client, READY); + + sendCommandAndValidateResponse(new TearDownTestCommand(), false); + + assertState(_client, READY); + } + + private void sendCommandToClient(final Command command) throws Exception + { + final Message message = JmsMessageAdaptor.commandToMessage(_session, command); + _clientQueueProducer.send(message); + ((AMQSession)_session).sync(); + } + + private void sendCommandAndValidateResponse(final Command command, boolean shouldSucceed) throws Exception + { + sendCommandToClient(command); + Response response = _controllerQueue.getNext(); + validateResponse(command.getType(), response, shouldSucceed); + } + + private void sendCommandAndValidateResponse(final Command command) throws Exception + { + sendCommandAndValidateResponse(command, true); + } + + private void createTestConnection(String connectionName) throws Exception + { + int initialNumberOfConnections = _clientJmsDelegate.getNoOfTestConnections(); + + final CreateConnectionCommand createConnectionCommand = new CreateConnectionCommand(); + createConnectionCommand.setConnectionName(connectionName); + createConnectionCommand.setConnectionFactoryName("connectionfactory"); + + sendCommandAndValidateResponse(createConnectionCommand); + + int expectedNumberOfConnections = initialNumberOfConnections + 1; + + assertEquals("unexpected number of test connections", expectedNumberOfConnections, _clientJmsDelegate.getNoOfTestConnections()); + } + + private void createTestSession(String connectionName, String sessionName, boolean shouldSucceed) throws Exception + { + int initialNumberOfSessions = _clientJmsDelegate.getNoOfTestSessions(); + + final CreateSessionCommand createSessionCommand = new CreateSessionCommand(); + createSessionCommand.setConnectionName(connectionName); + createSessionCommand.setSessionName(sessionName); + createSessionCommand.setAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); + + sendCommandAndValidateResponse(createSessionCommand, shouldSucceed); + + int expectedNumberOfSessions = initialNumberOfSessions + (shouldSucceed ? 1 : 0); + + assertEquals("unexpected number of test sessions", expectedNumberOfSessions, _clientJmsDelegate.getNoOfTestSessions()); + } + + private void createTestSession(String connectionName, String sessionName) throws Exception + { + createTestSession(connectionName, sessionName, true); + } + + private void createTestProducer(String sessionName, String producerName, String destinationName, boolean shouldSucceed) throws Exception + { + final CreateProducerCommand createProducerCommand = new CreateProducerCommand(); + createProducerCommand.setParticipantName(producerName); + createProducerCommand.setSessionName(sessionName); + createProducerCommand.setDestinationName(destinationName); + createProducerCommand.setNumberOfMessages(100); + + sendCommandAndValidateResponse(createProducerCommand, shouldSucceed); + } + + private void createTestProducer(String sessionName, String producerName, String destinationName) throws Exception + { + createTestProducer(sessionName, producerName, destinationName, true); + } + + private void createTestConsumer(String sessionName, String consumerName, String destinationName, boolean shouldSucceed) throws Exception + { + final CreateConsumerCommand createConsumerCommand = new CreateConsumerCommand(); + createConsumerCommand.setSessionName(sessionName); + createConsumerCommand.setDestinationName(destinationName); + createConsumerCommand.setParticipantName(consumerName); + createConsumerCommand.setNumberOfMessages(1); + + sendCommandAndValidateResponse(createConsumerCommand, shouldSucceed); + } + + private void createTestConsumer(String sessionName, String consumerName, String destinationName) throws Exception + { + createTestConsumer(sessionName, consumerName, destinationName, true); + } + + private void validateResponse(CommandType originatingCommandType, Response response, boolean shouldSucceed) throws JMSException + { + assertEquals("Response is a reply to the wrong command: " + response, + originatingCommandType, + response.getInReplyToCommandType()); + + boolean shouldHaveError = !shouldSucceed; + assertEquals("Response message " + response + " should have indicated hasError=" + shouldHaveError, + shouldHaveError, + response.hasError()); + } + + private void createClientQueueProducer(final RegisterClientCommand registration) throws JMSException + { + final Destination clientCommandQueue = createDestinationFromRegistration(registration); + _clientQueueProducer = _session.createProducer(clientCommandQueue); + } + + private Queue createDestinationFromRegistration(final RegisterClientCommand registrationCommand) throws JMSException + { + String clientQueueName = registrationCommand.getClientQueueName(); + assertNotNull("Null client queue in register message", clientQueueName); + return _session.createQueue(clientQueueName); + } + + private static void assertState(Client client, ClientState expectedState) + { + ClientState clientState = client.getState(); + assertEquals("Client should be in state: " + expectedState + " but is in state " + clientState, expectedState, clientState); + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java new file mode 100644 index 0000000000..dcbff6518b --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/MessageProviderTest.java @@ -0,0 +1,119 @@ +/* + * 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.qpid.systest.disttest.clientonly; + +import java.util.HashMap; +import java.util.Map; + +import javax.jms.DeliveryMode; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import org.apache.qpid.disttest.client.MessageProvider; +import org.apache.qpid.disttest.client.property.PropertyValue; +import org.apache.qpid.disttest.client.property.SimplePropertyValue; +import org.apache.qpid.disttest.message.CreateMessageProviderCommand; +import org.apache.qpid.disttest.message.CreateProducerCommand; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; +import org.apache.qpid.systest.disttest.clientonly.ProducerParticipantTest.TestClientJmsDelegate; + +public class MessageProviderTest extends DistributedTestSystemTestBase +{ + private MessageConsumer _consumer; + private Session _session; + private TestClientJmsDelegate _delegate; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _consumer = _session.createConsumer(getTestQueue()); + _delegate = new TestClientJmsDelegate(getContext()); + } + + public void testMessageSize() throws Exception + { + runSizeTest(0); + runSizeTest(5); + runSizeTest(512); + } + + public void runSizeTest(int size) throws Exception + { + CreateProducerCommand command = new CreateProducerCommand(); + command.setMessageSize(size); + MessageProvider messageProvider = new MessageProvider(null); + Message message = messageProvider.nextMessage(_session, command); + assertNotNull("Message is not generated", message); + assertTrue("Wrong message type", message instanceof TextMessage); + TextMessage textMessage = (TextMessage)message; + String text = textMessage.getText(); + assertNotNull("Message payload is not generated", text); + assertEquals("Message payload size is incorrect", size, text.length()); + } + + public void testCreateMessageProviderAndSendMessage() throws Exception + { + final CreateMessageProviderCommand messageProviderCommand = new CreateMessageProviderCommand(); + messageProviderCommand.setProviderName("test1"); + Map messageProperties = new HashMap(); + messageProperties.put("test", new SimplePropertyValue("testValue")); + messageProperties.put("priority", new SimplePropertyValue(new Integer(9))); + messageProviderCommand.setMessageProperties(messageProperties); + _delegate.createMessageProvider(messageProviderCommand); + + final CreateProducerCommand producerCommand = new CreateProducerCommand(); + producerCommand.setNumberOfMessages(1); + producerCommand.setDeliveryMode(DeliveryMode.PERSISTENT); + producerCommand.setPriority(6); + producerCommand.setParticipantName("test"); + producerCommand.setMessageSize(10); + producerCommand.setSessionName("testSession"); + producerCommand.setDestinationName(getTestQueueName()); + producerCommand.setMessageProviderName(messageProviderCommand.getProviderName()); + + Session session = _connection.createSession(true, Session.SESSION_TRANSACTED); + _delegate.addConnection("name-does-not-matter", _connection); + _delegate.addSession(producerCommand.getSessionName(), session); + _delegate.createProducer(producerCommand); + + Message message = _delegate.sendNextMessage(producerCommand); + session.commit(); + assertMessage(message); + + _connection.start(); + Message receivedMessage = _consumer.receive(1000l); + assertMessage(receivedMessage); + } + + protected void assertMessage(Message message) throws JMSException + { + assertNotNull("Message should not be null", message); + assertEquals("Unexpected test property", "testValue", message.getStringProperty("test")); + assertEquals("Unexpected priority property", 9, message.getJMSPriority()); + assertTrue("Unexpected message type", message instanceof TextMessage); + String text = ((TextMessage)message).getText(); + assertNotNull("Message text should not be null", text); + assertNotNull("Unexpected message size ", text.length()); + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java new file mode 100644 index 0000000000..54bb9efa98 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/clientonly/ProducerParticipantTest.java @@ -0,0 +1,132 @@ +/* + * 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.qpid.systest.disttest.clientonly; + +import javax.jms.Connection; +import javax.jms.DeliveryMode; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.naming.Context; + +import org.apache.qpid.disttest.client.Client; +import org.apache.qpid.disttest.client.ParticipantExecutor; +import org.apache.qpid.disttest.client.ProducerParticipant; +import org.apache.qpid.disttest.jms.ClientJmsDelegate; +import org.apache.qpid.disttest.message.CreateProducerCommand; +import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; + +public class ProducerParticipantTest extends DistributedTestSystemTestBase +{ + private MessageConsumer _consumer; + private TestClientJmsDelegate _delegate; + private Client _client; + private ControllerQueue _controllerQueue; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _controllerQueue = new ControllerQueue(_connection, _context); + Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _consumer = session.createConsumer(getTestQueue()); + + _delegate = new TestClientJmsDelegate(getContext()); + _client = new Client(_delegate); + } + + + + @Override + protected void tearDown() throws Exception + { + _controllerQueue.close(); + super.tearDown(); + } + + + + public void testProduceNumberOfMessages() throws Exception + { + runTest(Session.AUTO_ACKNOWLEDGE, 100, 10, 0, 0); + } + + protected void runTest(int acknowledgeMode, int messageSize, int numberOfMessages, int batchSize, long publishInterval) throws Exception + { + final CreateProducerCommand command = new CreateProducerCommand(); + command.setNumberOfMessages(numberOfMessages); + command.setDeliveryMode(DeliveryMode.PERSISTENT); + command.setParticipantName("test"); + command.setMessageSize(messageSize); + command.setBatchSize(batchSize); + command.setInterval(publishInterval); + command.setSessionName("testSession"); + command.setDestinationName(getTestQueueName()); + + Session session = _connection.createSession(Session.SESSION_TRANSACTED == acknowledgeMode, acknowledgeMode); + + _delegate.addConnection("name-does-not-matter", _connection); + _delegate.addSession(command.getSessionName(), session); + _delegate.createProducer(command); + + final ProducerParticipant producer = new ProducerParticipant(_delegate, command); + + new ParticipantExecutor(producer).start(_client); + + _connection.start(); + for (int i = 0; i < numberOfMessages; i++) + { + final Message m = _consumer.receive(1000l); + assertNotNull("Expected message [" + i + "] is not received", m); + assertTrue("Unexpected message", m instanceof TextMessage); + } + Message m = _consumer.receive(500l); + assertNull("Unexpected message", m); + + ParticipantResult results = _controllerQueue.getNext(); + + assertNotNull("no results", results); + assertFalse(results.getStartInMillis() == 0); + assertFalse(results.getEndInMillis() == 0); + } + + static class TestClientJmsDelegate extends ClientJmsDelegate + { + + public TestClientJmsDelegate(Context context) + { + super(context); + } + + @Override + public void addSession(final String sessionName, final Session newSession) + { + super.addSession(sessionName, newSession); + } + + @Override + public void addConnection(final String connectionName, final Connection newConnection) + { + super.addConnection(connectionName, newConnection); + } + } +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java new file mode 100644 index 0000000000..75d0941c57 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/ControllerAndClientTest.java @@ -0,0 +1,263 @@ +/* + * 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.qpid.systest.disttest.controllerandclient; + +import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPONSE_TIMEOUT; +import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT; +import static org.apache.qpid.systest.disttest.SystemTestConstants.TEST_RESULT_TIMEOUT; + +import java.util.Collection; +import java.util.List; + +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.Queue; +import javax.jms.Session; +import javax.naming.NamingException; + +import org.apache.qpid.systest.disttest.ConfigFileTestHelper; +import org.apache.qpid.disttest.client.Client; +import org.apache.qpid.disttest.client.ClientState; +import org.apache.qpid.disttest.controller.Controller; +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.controller.TestResult; +import org.apache.qpid.disttest.controller.config.Config; +import org.apache.qpid.disttest.jms.ClientJmsDelegate; +import org.apache.qpid.disttest.jms.ControllerJmsDelegate; +import org.apache.qpid.disttest.message.ConsumerParticipantResult; +import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.disttest.message.ProducerParticipantResult; +import org.apache.qpid.disttest.results.aggregation.ITestResult; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ControllerAndClientTest extends DistributedTestSystemTestBase +{ + private static final Logger LOGGER = LoggerFactory.getLogger(ControllerAndClientTest.class); + private static final long CLIENT_BACKGROUND_THREAD_WAIT_TIME = 5000; + + private Controller _controller; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _controller = new Controller(new ControllerJmsDelegate(_context), REGISTRATION_TIMEOUT, COMMAND_RESPONSE_TIMEOUT); + _controller.setTestResultTimeout(TEST_RESULT_TIMEOUT); + } + + public void testProducerAndConsumerInSeparateClients() throws Exception + { + List resultList = runTestsForTwoClients("producerAndConsumerInSeparateClients.json", 1); + + TestResult testResult1 = resultList.get(0); + assertEquals("Unexpected test name", "Test 1", testResult1.getName()); + List test1ParticipantResults = testResult1.getParticipantResults(); + assertEquals("Unexpected number of participant results for test 1", 2, test1ParticipantResults.size()); + assertParticipantNames(test1ParticipantResults, "participantConsumer1", "participantProducer1"); + ConsumerParticipantResult result = null; + for (ParticipantResult participantResult : test1ParticipantResults) + { + if (participantResult instanceof ConsumerParticipantResult) + { + result = (ConsumerParticipantResult)participantResult; + break; + } + } + assertNotNull("Consumer results not recived", result); + Collection latencies = result.getMessageLatencies(); + assertNotNull("Latency results are not collected", latencies); + assertEquals("Unexpected latency results", 1, latencies.size()); + } + + public void testProducerClient() throws Exception + { + Session session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = session.createQueue("producerClient"); + MessageConsumer consumer = session.createConsumer(queue); + + // queue is not declared in configuration + // controller is not able to clean it + // cleaning manually + while(consumer.receive(1000l) != null); + + final Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), "produceClient.json"); + _controller.setConfig(config); + final Client client1 = new Client(new ClientJmsDelegate(_context)); + final Thread client1Thread = createBackgroundClientThread(client1); + _controller.awaitClientRegistrations(); + + ResultsForAllTests results = _controller.runAllTests(); + _controller.stopAllRegisteredClients(); + + assertClientThreadsShutdown(client1Thread); + assertClientsStopped(ClientState.STOPPED, client1); + assertFalse("Test should have no errors", results.hasErrors()); + List allTestResults = results.getTestResults(); + assertEquals("Unexpected number of test results", 1, allTestResults.size()); + ITestResult testResult1 = allTestResults.get(0); + assertEquals("Unexpected test name", "Test 1", testResult1.getName()); + List test1ParticipantResults = testResult1.getParticipantResults(); + assertEquals("Unexpected number of participant results for test 1", 1, test1ParticipantResults.size()); + assertParticipantNames(test1ParticipantResults, "participantProducer1"); + + // check message properties + for (int i=0; i< 10; i++) + { + Message message = consumer.receive(1000l); + assertNotNull("Message " + i + " is not received", message); + assertEquals("Unexpected priority", i, message.getJMSPriority()); + assertEquals("Unexpected id", i, message.getIntProperty("id")); + assertEquals("Unexpected test", "test-value", message.getStringProperty("test")); + } + } + + public void testProducerAndThreeConsumersInSeparateClients() throws Exception + { + List resultList = runTestsForTwoClients("producerAndThreeConsumersInSeparateClients.json", 1); + + TestResult testResult1 = resultList.get(0); + List test1ParticipantResults = testResult1.getParticipantResults(); + assertEquals("Unexpected number of participant results for test", 4, test1ParticipantResults.size()); + + assertParticipantNames(test1ParticipantResults, "participantConsumer1", "participantConsumer2", "participantConsumer3", "participantProducer1"); + + ConsumerParticipantResult consumer1 = (ConsumerParticipantResult) test1ParticipantResults.get(0); + assertEquals(3, consumer1.getNumberOfMessagesProcessed()); + assertEquals(true, consumer1.isSynchronousConsumer()); + + ProducerParticipantResult producer1 = (ProducerParticipantResult) test1ParticipantResults.get(3); + assertEquals(9, producer1.getNumberOfMessagesProcessed()); + assertEquals(2, producer1.getBatchSize()); + assertEquals(50, producer1.getInterval()); + } + + public void testIteratingFeature() throws Exception + { + List resultList = runTestsForTwoClients("iteratingFeature.json", 2); + + assertTestResultMessageSize(resultList.get(0), 0, 100, 10); + assertTestResultMessageSize(resultList.get(1), 1, 200, 5); + + } + + private void assertTestResultMessageSize(TestResult testResult, int iterationNumber, int expectedMessageSize, int expectedNumberOfMessages) + { + List test1ParticipantResults = testResult.getParticipantResults(); + assertEquals("Unexpected number of participant results for test", 2, test1ParticipantResults.size()); + + ParticipantResult producer1 = test1ParticipantResults.get(1); + + assertEquals(expectedMessageSize, producer1.getPayloadSize()); + assertEquals(iterationNumber, producer1.getIterationNumber()); + } + + public void testTwoTests() throws Exception + { + List resultList = runTestsForTwoClients("testWithTwoTests.json", 2); + + assertEquals("Test 1", resultList.get(0).getName()); + assertEquals("Test 2", resultList.get(1).getName()); + } + + private List runTestsForTwoClients(String jsonConfigFile, int expectedNumberOfTests) throws NamingException, InterruptedException + { + final Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), jsonConfigFile); + _controller.setConfig(config); + + final Client client1 = new Client(new ClientJmsDelegate(_context)); + final Client client2 = new Client(new ClientJmsDelegate(_context)); + + final Thread client1Thread = createBackgroundClientThread(client1); + final Thread client2Thread = createBackgroundClientThread(client2); + + _controller.awaitClientRegistrations(); + + ResultsForAllTests results = _controller.runAllTests(); + _controller.stopAllRegisteredClients(); + + assertClientThreadsShutdown(client1Thread, client2Thread); + assertClientsStopped(ClientState.STOPPED, client1, client2); + + assertFalse("Test should have no errors", results.hasErrors()); + + List allTestResults = (List)results.getTestResults(); + assertEquals("Unexpected number of test results", expectedNumberOfTests, allTestResults.size()); + + return allTestResults; + } + + + private void assertParticipantNames(List participants, String... expectedOrderedParticipantNames) + { + assertEquals("Size of list of expected participant names is different from actual", expectedOrderedParticipantNames.length, participants.size()); + + for (int i = 0; i < expectedOrderedParticipantNames.length; i++) + { + String expectedParticipantName = expectedOrderedParticipantNames[i]; + ParticipantResult participant = participants.get(i); + assertEquals(expectedParticipantName, participant.getParticipantName()); + } + } + + private void assertClientsStopped(ClientState expectedState, final Client... clients) + { + for (Client client : clients) + { + assertEquals(client.getClientName() + " in unexpected state", expectedState, client.getState()); + } + } + + private void assertClientThreadsShutdown(final Thread... clientThreads) + throws InterruptedException + { + for (Thread clientThread : clientThreads) + { + clientThread.join(2000); + assertFalse(clientThread.getName() + " should have shutdown", clientThread.isAlive()); + } + } + + private Thread createBackgroundClientThread(final Client client) throws NamingException + { + final String clientThreadName = client.getClientName() + "-thread"; + final Thread clientThread = new Thread(new Runnable() + { + @Override + public void run() + { + try + { + client.start(); + client.waitUntilStopped(CLIENT_BACKGROUND_THREAD_WAIT_TIME); + } + finally + { + LOGGER.debug("Client thread {} finished", clientThreadName); + } + } + }, clientThreadName); + clientThread.start(); + return clientThread; + } + +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json new file mode 100644 index 0000000000..89123302b7 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/iteratingFeature.json @@ -0,0 +1,63 @@ +{ + "_tests":[ + { + "_name": "Test iteration feature", + "_iterations":[ + { + "_messageSize": 100, + "_numberOfMessages": 10 + }, + { + "_messageSize": 200, + "_numberOfMessages": 5 + } + ], + "_queues":[ + { + "_name": "direct://amq.direct//testQueue" + } + ], + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer1", + "_destinationName": "direct://amq.direct//testQueue" + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_consumers": [ + { + "_name": "participantConsumer1", + "_destinationName": "direct://amq.direct//testQueue" + } + ] + } + ] + } + ] + } + ] + }] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json new file mode 100644 index 0000000000..605e5cb585 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/produceClient.json @@ -0,0 +1,41 @@ +{ + "_tests":[ + { + "_name": "Test 1"; + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer1", + "_destinationName": "direct://amq.direct//producerClient", + "_numberOfMessages": 10; + "_messageProviderName": "testProvider1" + } + ] + } + ] + } + ]; + "_messageProviders":[ + { + "_name": "testProvider1"; + "_messageProperties": { + "priority": {"@def": "list"; "_items": [0,1,2,3,4,5,6,7,8,9]}; + "id": {"@def": "range"; "_upper": 10; "_type": "int"}; + "test": "test-value" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json new file mode 100644 index 0000000000..a008dc40d8 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndConsumerInSeparateClients.json @@ -0,0 +1,56 @@ +{ + "_tests":[ + { + "_name": "Test 1"; + "_queues":[ + { + "_name": "direct://amq.direct//testQueue" + } + ]; + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 1 + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_consumers": [ + { + "_name": "participantConsumer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 1, + "_evaluateLatency": true + } + ] + } + ] + } + ] + } + ] + }] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json new file mode 100644 index 0000000000..f94c4f0ae0 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/producerAndThreeConsumersInSeparateClients.json @@ -0,0 +1,77 @@ +{ + "_tests":[ + { + "_name": "ProducerAndThreeConsumersInSeparateClients"; + "_queues":[ + { + "_name": "direct://amq.direct//testQueue" + } + ]; + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 9, + "_batchSize": 2, + "_interval": 50 + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_consumers": [ + { + "_name": "participantConsumer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 3 + } + ] + }, + { + "_sessionName": "session2", + "_consumers": [ + { + "_name": "participantConsumer2", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 3 + } + ] + }, + { + "_sessionName": "session3", + "_consumers": [ + { + "_name": "participantConsumer3", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 3 + } + ] + } + ] + } + ] + } + ] + }] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json new file mode 100644 index 0000000000..4abd7f4feb --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controllerandclient/testWithTwoTests.json @@ -0,0 +1,107 @@ +{ + "_tests":[ + { + "_name": "Test 1"; + "_queues":[ + { + "_name": "direct://amq.direct//testQueue" + } + ]; + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 1 + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_consumers": [ + { + "_name": "participantconsumer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 1 + } + ] + } + ] + } + ] + } + ] + }, + { + "_name": "Test 2"; + "_queues":[ + { + "_name": "direct://amq.direct//testQueue2" + } + ]; + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer2", + "_destinationName": "direct://amq.direct//testQueue2", + "_numberOfMessages": 1 + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_consumers": [ + { + "_name": "participantConsumer2", + "_destinationName": "direct://amq.direct//testQueue2", + "_numberOfMessages": 1 + } + ] + } + ] + } + ] + } + ] + }] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java new file mode 100644 index 0000000000..349ddb276e --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/DistributedControllerTest.java @@ -0,0 +1,157 @@ +/* + * 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.qpid.systest.disttest.controlleronly; + +import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPONSE_TIMEOUT; +import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TemporaryQueue; + +import org.apache.qpid.systest.disttest.ConfigFileTestHelper; +import org.apache.qpid.disttest.controller.Controller; +import org.apache.qpid.disttest.controller.config.Config; +import org.apache.qpid.disttest.jms.ControllerJmsDelegate; +import org.apache.qpid.disttest.jms.JmsMessageAdaptor; +import org.apache.qpid.disttest.message.Command; +import org.apache.qpid.disttest.message.CommandType; +import org.apache.qpid.disttest.message.RegisterClientCommand; +import org.apache.qpid.disttest.message.Response; +import org.apache.qpid.systest.disttest.DistributedTestSystemTestBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DistributedControllerTest extends DistributedTestSystemTestBase +{ + private static final Logger LOGGER = LoggerFactory.getLogger(DistributedControllerTest.class); + + private static final String CLIENT1 = "client1"; + private Controller _controller = null; + private Session _session = null; + private Connection _connection = null; + private Destination _controllerQueue = null; + private TemporaryQueue _clientQueue = null; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + _controllerQueue = (Destination) _context.lookup("controllerqueue"); + + final ConnectionFactory connectionFactory = (ConnectionFactory) _context.lookup("connectionfactory"); + _connection = connectionFactory.createConnection(); + _connection.start(); + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _clientQueue = _session.createTemporaryQueue(); + + _controller = new Controller(new ControllerJmsDelegate(_context), REGISTRATION_TIMEOUT, COMMAND_RESPONSE_TIMEOUT); + } + + @Override + protected void tearDown() throws Exception + { + try + { + if (_connection != null) + { + _connection.close(); + } + } + finally + { + super.tearDown(); + } + } + + public void testControllerSendsOneCommandToSingleClient() throws Exception + { + Config config = ConfigFileTestHelper.getConfigFromResource(getClass(), "distributedControllerTest.json"); + _controller.setConfig(config); + + sendRegistration(CLIENT1); + _controller.awaitClientRegistrations(); + + final ArrayBlockingQueue commandList = new ArrayBlockingQueue(4); + final MessageConsumer clientConsumer = _session.createConsumer(_clientQueue); + final AtomicReference listenerException = new AtomicReference(); + final MessageProducer producer = _session.createProducer(_controllerQueue); + clientConsumer.setMessageListener(new MessageListener() + { + @Override + public void onMessage(Message message) + { + try + { + Command command = JmsMessageAdaptor.messageToCommand(message); + LOGGER.debug("Test client received " + command); + commandList.add(command); + producer.send(JmsMessageAdaptor.commandToMessage(_session, new Response(CLIENT1, command.getType()))); + } + catch(Exception e) + { + listenerException.set(e); + } + } + }); + + _controller.runAllTests(); + assertCommandType(CommandType.CREATE_CONNECTION, commandList); + assertCommandType(CommandType.START_TEST, commandList); + assertCommandType(CommandType.TEAR_DOWN_TEST, commandList); + + _controller.stopAllRegisteredClients(); + assertCommandType(CommandType.STOP_CLIENT, commandList); + assertNull("Unexpected exception occured", listenerException.get()); + Command command = commandList.poll(1l, TimeUnit.SECONDS); + assertNull("Unexpected command is received", command); + } + + private void assertCommandType(CommandType expectedType, BlockingQueue commandList) throws InterruptedException + { + Command command = commandList.poll(1l, TimeUnit.SECONDS); + assertNotNull("Command of type " + expectedType + " is not received", command); + assertEquals("Unexpected command type", expectedType, command.getType()); + } + + private void sendRegistration(final String clientId) throws JMSException + { + final MessageProducer registrationProducer = _session.createProducer(_controllerQueue); + + final Command command = new RegisterClientCommand(clientId, _clientQueue.getQueueName()); + final Message registrationMessage = JmsMessageAdaptor.commandToMessage(_session, command); + registrationProducer.send(registrationMessage); + LOGGER.debug("sent registrationMessage: " + registrationMessage); + } + +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json new file mode 100644 index 0000000000..b49603ef23 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/controlleronly/distributedControllerTest.json @@ -0,0 +1,17 @@ +{ + "_tests":[ + { + "_name": "Test 1"; + "_clients":[ + { + "_name": "client1", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory" + } + ] + } + ] + }] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java new file mode 100644 index 0000000000..010eec4982 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java @@ -0,0 +1,100 @@ +/* + * 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.qpid.systest.disttest.endtoend; + +import static org.apache.qpid.disttest.AbstractRunner.JNDI_CONFIG_PROP; +import static org.apache.qpid.disttest.ControllerRunner.OUTPUT_DIR_PROP; +import static org.apache.qpid.disttest.ControllerRunner.RUN_ID; +import static org.apache.qpid.disttest.ControllerRunner.TEST_CONFIG_PROP; +import static org.apache.qpid.disttest.ControllerRunner.WRITE_TO_DB; + +import java.io.File; +import java.io.IOException; + +import org.apache.qpid.disttest.ControllerRunner; +import org.apache.qpid.disttest.message.ParticipantAttribute; +import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; +import org.apache.qpid.test.utils.QpidBrokerTestCase; +import org.apache.qpid.util.FileUtils; + +public class EndToEndTest extends QpidBrokerTestCase +{ + private ControllerRunner _runner; + private static final String TEST_CONFIG = "qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json"; + private static final String JNDI_CONFIG_FILE = "qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/perftests.systests.properties"; + private static final String RUN1 = "run1"; + + public void testRunner() throws Exception + { + File csvOutputDir = createTemporaryCsvDirectory(); + assertTrue("CSV output dir must not exist",csvOutputDir.isDirectory()); + + final String[] args = new String[] {TEST_CONFIG_PROP + "=" + TEST_CONFIG, + JNDI_CONFIG_PROP + "=" + JNDI_CONFIG_FILE, + WRITE_TO_DB + "=true", + RUN_ID + "=" + RUN1, + OUTPUT_DIR_PROP + "=" + csvOutputDir.getAbsolutePath()}; + _runner = new ControllerRunner(); + _runner.parseArgumentsIntoConfig(args); + _runner.runController(); + + File expectedCsvOutputFile = new File(csvOutputDir, "endtoend.csv"); + assertTrue("CSV output file must exist", expectedCsvOutputFile.exists()); + final String csvContents = FileUtils.readFileAsString(expectedCsvOutputFile); + final String[] csvLines = csvContents.split("\n"); + + int numberOfHeaders = 1; + int numberOfParticipants = 2; + int numberOfSummaries = 3; + + int numberOfExpectedRows = numberOfHeaders + numberOfParticipants + numberOfSummaries; + assertEquals("Unexpected number of lines in CSV", numberOfExpectedRows, csvLines.length); + + assertDataRowsHaveCorrectTestAndClientName("End To End 1", "producingClient", "participantProducer1", csvLines[1], 1); + assertDataRowsHaveCorrectTestAndClientName("End To End 1", "consumingClient", "participantConsumer1", csvLines[3], 1); + + assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PARTICIPANTS_NAME, csvLines[4], 1); + assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME, csvLines[2], 1); + assertDataRowsHaveCorrectTestAndClientName("End To End 1", "", TestResultAggregator.ALL_PRODUCER_PARTICIPANTS_NAME, csvLines[5], 1); + + } + + private void assertDataRowsHaveCorrectTestAndClientName(String testName, String clientName, String participantName, String csvLine, int expectedNumberOfMessagesProcessed) + { + final int DONT_STRIP_EMPTY_LAST_FIELD_FLAG = -1; + String[] cells = csvLine.split(",", DONT_STRIP_EMPTY_LAST_FIELD_FLAG); + // All attributes become cells in the CSV, so this will be true + assertEquals("Unexpected number of cells in CSV line " + csvLine, ParticipantAttribute.values().length, cells.length); + assertEquals("Unexpected test name in CSV line " + csvLine, testName, cells[ParticipantAttribute.TEST_NAME.ordinal()]); + assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[ParticipantAttribute.CONFIGURED_CLIENT_NAME.ordinal()]); + assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[ParticipantAttribute.PARTICIPANT_NAME.ordinal()]); + assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED.ordinal()]); + + } + + private File createTemporaryCsvDirectory() throws IOException + { + String tmpDir = System.getProperty("java.io.tmpdir"); + File csvDir = new File(tmpDir, "csv"); + csvDir.mkdir(); + csvDir.deleteOnExit(); + return csvDir; + } + +} diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json new file mode 100644 index 0000000000..1b7cc51265 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/endtoend/endtoend.json @@ -0,0 +1,65 @@ +{ + "_tests":[ + { + "_name": "End To End 1"; + "_queues":[ + { + "_name": "direct://amq.direct//testQueue" + } + ]; + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_producers": [ + { + "_name": "participantProducer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 1 + } + ] + } + ]; + "_messageProviders":[ + { + "_name": "testProvider1"; + "_messageProperties": { + "priority": {"@def": "list"; "_items": [1,2,3,4,4]}; + "id": {"@def": "random"; "_upper": 10}; + "test": "test-value" + } + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_consumers": [ + { + "_name": "participantConsumer1", + "_destinationName": "direct://amq.direct//testQueue", + "_numberOfMessages": 1 + } + ] + } + ] + } + ] + } + ] + }] +} \ No newline at end of file diff --git a/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/perftests.systests.properties b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/perftests.systests.properties new file mode 100644 index 0000000000..149e632048 --- /dev/null +++ b/qpid/java/qpid-perftests-systests/src/main/java/org/apache/qpid/systest/disttest/perftests.systests.properties @@ -0,0 +1,29 @@ +# 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. + +# this file is used for running system tests of the performance test framework, +# (i.e. not for running the performance tests themselves!) + +java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory + +# use QpidBrokerTestCase's default port +connectionfactory.connectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:15672' + +destination.controllerqueue = direct://amq.direct//controllerqueue + +jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver +jdbcUrl=jdbc:derby:/tmp/tempDbDirectory/perftestResultsDb;create=true diff --git a/qpid/java/qpid-systests-parent/pom.xml b/qpid/java/qpid-systests-parent/pom.xml index 15fc567a77..eaea72cb22 100644 --- a/qpid/java/qpid-systests-parent/pom.xml +++ b/qpid/java/qpid-systests-parent/pom.xml @@ -72,6 +72,8 @@ + src/main/java + src/main/resources diff --git a/qpid/java/systests/pom.xml b/qpid/java/systests/pom.xml index 070e9f9ace..319a3da5b2 100644 --- a/qpid/java/systests/pom.xml +++ b/qpid/java/systests/pom.xml @@ -185,8 +185,4 @@ - - src/main/java - - -- cgit v1.2.1 From 3ef9fddf33a341bc5f7aedf0cf8eabd02ef09922 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sun, 16 Mar 2014 19:49:13 +0000 Subject: QPID-5600: remove stale and unused RELEASE_NOTES.txt and containing qpid/java/release-docs directory git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1578149 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/release-docs/RELEASE_NOTES.txt | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 qpid/java/release-docs/RELEASE_NOTES.txt diff --git a/qpid/java/release-docs/RELEASE_NOTES.txt b/qpid/java/release-docs/RELEASE_NOTES.txt deleted file mode 100644 index f94c45fd4d..0000000000 --- a/qpid/java/release-docs/RELEASE_NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -Apache Qpid Java 0.8 Release Notes -------------------------------------------- - -The Qpid 0.8 release contains support for AMQP 0-8, 0-9 and 0-10. You -can access the specifications from - -http://www.amqp.org/confluence/display/AMQP/AMQP+Specification - -For full details of Apache Qpid's capabilities see our detailed -project documentation at: - -http://cwiki.apache.org/confluence/display/qpid/Qpid+Java+Documentation - -From the link above you can access our Getting Started Guide, FAQ, Build How To -and detailed developer documentation. - -Known Issues/Outstanding Work ------------------------------ - -You can view the outstanding task list for Qpid by visiting our JIRA: -http://issues.apache.org/jira/browse/QPID -- cgit v1.2.1 From f4181185a51484a8176df73decf67959f26b3c20 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sun, 16 Mar 2014 19:49:30 +0000 Subject: QPID-5048: unexclude some dirs, make the test-profiles exclusion specific only to the test ssl resources git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1578150 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index b9b7eafac1..74042dd0bc 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -334,10 +334,8 @@ build/** - resources/** - test-profiles/** - release-docs/** lib/** + test-profiles/test_resources/ssl/** @@ -400,10 +398,8 @@ build/** - resources/** - test-profiles/** - release-docs/** lib/** + test-profiles/test_resources/ssl/** -- cgit v1.2.1 From eba5294974fb2a73b4e765c74196ba4a63079f03 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Sun, 16 Mar 2014 19:49:49 +0000 Subject: QPID-5048: stop the new perftets-systests module from making a release archive git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1578151 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/qpid-perftests-systests/build.xml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/qpid/java/qpid-perftests-systests/build.xml b/qpid/java/qpid-perftests-systests/build.xml index 3d82ee5e7e..07d2263e43 100644 --- a/qpid/java/qpid-perftests-systests/build.xml +++ b/qpid/java/qpid-perftests-systests/build.xml @@ -43,25 +43,4 @@ - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.1