diff options
author | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
commit | 9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch) | |
tree | 2a890e1df09e5b896a9b4168a7b22648f559a1f2 /java/perftests | |
parent | 172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff) | |
download | qpid-python-asyncstore.tar.gz |
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/perftests')
176 files changed, 4793 insertions, 939 deletions
diff --git a/java/perftests/build.xml b/java/perftests/build.xml index c59986c06d..d29649ad68 100644 --- a/java/perftests/build.xml +++ b/java/perftests/build.xml @@ -33,7 +33,7 @@ </condition> <property name="module.depends" value="client common"/> - <property name="module.test.depends" value="systests broker common/test management/common ${perftests.optional.test.depends}"/> + <property name="module.test.depends" value="systests broker common/tests management/common ${perftests.optional.test.depends}"/> <import file="../module.xml"/> diff --git a/java/perftests/etc/chartdefs/1001-MessageSize-Transient.chartdef b/java/perftests/etc/chartdefs/1001-MessageSize-Transient-ByteSec.chartdef index 757a396dff..7559b5934e 100644 --- a/java/perftests/etc/chartdefs/1001-MessageSize-Transient.chartdef +++ b/java/perftests/etc/chartdefs/1001-MessageSize-Transient-ByteSec.chartdef @@ -18,15 +18,20 @@ # chartType=XYLINE -chartTitle=Impact of Message Size +chartTitle=Impact of Message Size Bytes/S chartSubtitle=Transient messages +chartDescription=1P 1C, transient, auto-ack, with message payload between 256-262144 bytes. + xAxisTitle=Message Size (B) yAxisTitle=Throughput (KB/s) series.1.statement=SELECT payloadSizeB, throughputKbPerS FROM MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=red series.2.statement=SELECT payloadSizeB, throughputKbPerS FROM MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1002-MessageSize-Persistent.chartdef b/java/perftests/etc/chartdefs/1002-MessageSize-Persistent-ByteSec.chartdef index 58c280e227..db8a5f3896 100644 --- a/java/perftests/etc/chartdefs/1002-MessageSize-Persistent.chartdef +++ b/java/perftests/etc/chartdefs/1002-MessageSize-Persistent-ByteSec.chartdef @@ -18,15 +18,20 @@ # chartType=XYLINE -chartTitle=Impact of Message Size +chartTitle=Impact of Message Size Bytes/S chartSubtitle=Persistent messages +chartDescription=1P 1C, persistent, auto-ack, with message payload between 256-262144 bytes. + xAxisTitle=Message Size (B) yAxisTitle=Throughput (KB/s) series.1.statement=SELECT payloadSizeB, throughputKbPerS FROM MessageSize WHERE testName like '% PERSISTENT' AND participantName = 'All' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=red series.2.statement=SELECT payloadSizeB, throughputKbPerS FROM MessageSize WHERE testName like '% PERSISTENT' AND participantName = 'All' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1003-MessageSize-Transient-MsgSec.chartdef b/java/perftests/etc/chartdefs/1003-MessageSize-Transient-MsgSec.chartdef new file mode 100644 index 0000000000..7f18fcc986 --- /dev/null +++ b/java/perftests/etc/chartdefs/1003-MessageSize-Transient-MsgSec.chartdef @@ -0,0 +1,37 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Impact of Message Size +chartSubtitle=Transient messages +chartDescription=1P 1C, transient, auto-ack, with message payload between 256-262144 bytes. + +xAxisTitle=Message Size (B) +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT payloadSizeB, throughputMessagesPerS FROM MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All' +series.1.legend=Current +series.1.dir=${csvCurrentDir} +series.1.colourName=red + +series.2.statement=SELECT payloadSizeB, throughputMessagesPerS FROM MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All' +series.2.legend=Baseline +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1004-MessageSize-Persistent-MsgSec.chartdef b/java/perftests/etc/chartdefs/1004-MessageSize-Persistent-MsgSec.chartdef new file mode 100644 index 0000000000..667be044bc --- /dev/null +++ b/java/perftests/etc/chartdefs/1004-MessageSize-Persistent-MsgSec.chartdef @@ -0,0 +1,37 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Impact of Message Size +chartSubtitle=Persistent messages +chartDescription=1P 1C, persistent, auto-ack, with message payload between 256-262144 bytes. + +xAxisTitle=Message Size (B) +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT payloadSizeB, throughputMessagesPerS FROM MessageSize WHERE testName like '% PERSISTENT' AND participantName = 'All' +series.1.legend=Current +series.1.dir=${csvCurrentDir} +series.2.colourName=red + +series.2.statement=SELECT payloadSizeB, throughputMessagesPerS FROM MessageSize WHERE testName like '% PERSISTENT' AND participantName = 'All' +series.2.legend=Baseline +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1011-VaryingNumberOfProducers.chartdef b/java/perftests/etc/chartdefs/1011-VaryingNumberOfProducers-AutoAck.chartdef index f39e7c3d0d..b3038c1671 100644 --- a/java/perftests/etc/chartdefs/1011-VaryingNumberOfProducers.chartdef +++ b/java/perftests/etc/chartdefs/1011-VaryingNumberOfProducers-AutoAck.chartdef @@ -18,23 +18,30 @@ # chartType=XYLINE -chartTitle=Varying number of producers +chartTitle=Varying number of producers - auto ack chartSubtitle=Persistent 1KB messages +chartDescription=1,2,5,10 P/Cs, persistent, auto-ack, with message payload 1KB. + xAxisTitle=Producers -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT totalNumberOfProducers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' +series.1.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' and acknowledgeMode = '1' series.1.legend=1 Consumer series.1.dir=${csvCurrentDir} +series.1.colourName=red -series.2.statement=SELECT totalNumberOfProducers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '5' +series.2.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '5' and acknowledgeMode = '1' series.2.legend=5 Consumer series.2.dir=${csvCurrentDir} +series.2.colourName=blue -series.3.statement=SELECT totalNumberOfProducers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '10' +series.3.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '10' and acknowledgeMode = '1' series.3.legend=10 Consumer series.3.dir=${csvCurrentDir} +series.3.colourName=green -series.4.statement=SELECT totalNumberOfProducers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' +series.4.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' and acknowledgeMode = '1' series.4.legend=1 Consumer (baseline) series.4.dir=${csvBaselineDir} +series.4.colourName=dark_red +series.4.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1012-VaryingNumberOfConsumers.chartdef b/java/perftests/etc/chartdefs/1012-VaryingNumberOfConsumers-AutoAck.chartdef index 0f0b35a7c8..d1f3d6e9a4 100644 --- a/java/perftests/etc/chartdefs/1012-VaryingNumberOfConsumers.chartdef +++ b/java/perftests/etc/chartdefs/1012-VaryingNumberOfConsumers-AutoAck.chartdef @@ -18,23 +18,30 @@ # chartType=XYLINE -chartTitle=Varying number of consumers +chartTitle=Varying number of consumers - auto ack chartSubtitle=Persistent 1KB messages +chartDescription=1,2,5,10 P/Cs, persistent, auto-ack, with message payload 1KB. + xAxisTitle=Consumers -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT totalNumberOfConsumers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '1' +series.1.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '1' and acknowledgeMode = '1' series.1.legend=1 Producer series.1.dir=${csvCurrentDir} +series.1.colourName=blue -series.2.statement=SELECT totalNumberOfConsumers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '5' +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '5' and acknowledgeMode = '1' series.2.legend=5 Producers series.2.dir=${csvCurrentDir} +series.2.colourName=green -series.3.statement=SELECT totalNumberOfConsumers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' +series.3.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' and acknowledgeMode = '1' series.3.legend=10 Producers series.3.dir=${csvCurrentDir} +series.3.colourName=red -series.4.statement=SELECT totalNumberOfConsumers, throughputKbPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' +series.4.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' and acknowledgeMode = '1' series.4.legend=10 Producers (baseline) series.4.dir=${csvBaselineDir} +series.4.colourName=dark_red +series.4.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef b/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef new file mode 100644 index 0000000000..42ba6f8f20 --- /dev/null +++ b/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef @@ -0,0 +1,47 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +chartType=XYLINE +chartTitle=Varying number of producers - transacted +chartSubtitle=Persistent 1KB messages +chartDescription=1,2,5,10 P/Cs, persistent, transacted, with message payload 1KB. + +xAxisTitle=Producers +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' and acknowledgeMode = '0' +series.1.legend=1 Consumer +series.1.dir=${csvCurrentDir} +series.1.colourName=red + +series.2.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '5' and acknowledgeMode = '0' +series.2.legend=5 Consumer +series.2.dir=${csvCurrentDir} +series.2.colourName=blue + +series.3.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '10' and acknowledgeMode = '0' +series.3.legend=10 Consumer +series.3.dir=${csvCurrentDir} +series.3.colourName=green + +series.4.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' and acknowledgeMode = '0' +series.4.legend=1 Consumer (baseline) +series.4.dir=${csvBaselineDir} +series.4.colourName=dark_red +series.4.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef b/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef new file mode 100644 index 0000000000..0afd162ad0 --- /dev/null +++ b/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef @@ -0,0 +1,47 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +chartType=XYLINE +chartTitle=Varying number of consumers - transacted +chartSubtitle=Persistent 1KB messages +chartDescription=1,2,5,10 P/Cs, persistent, transacted, with message payload 1KB. + +xAxisTitle=Consumers +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '1' and acknowledgeMode = '0' +series.1.legend=1 Producer +series.1.dir=${csvCurrentDir} +series.1.colourName=blue + +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '5' and acknowledgeMode = '0' +series.2.legend=5 Producers +series.2.dir=${csvCurrentDir} +series.2.colourName=green + +series.3.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' and acknowledgeMode = '0' +series.3.legend=10 Producers +series.3.dir=${csvCurrentDir} +series.3.colourName=red + +series.4.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' and acknowledgeMode = '0' +series.4.legend=10 Producers (baseline) +series.4.dir=${csvBaselineDir} +series.4.colourName=dark_red +series.4.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1021-AcknowledgementModes-Persistent.chartdef b/java/perftests/etc/chartdefs/1021-AcknowledgementModes-Persistent.chartdef index 30aee40c27..827f8b5567 100644 --- a/java/perftests/etc/chartdefs/1021-AcknowledgementModes-Persistent.chartdef +++ b/java/perftests/etc/chartdefs/1021-AcknowledgementModes-Persistent.chartdef @@ -19,17 +19,20 @@ chartType=BAR chartTitle=Performance of acknowledgement modes -chartSubtitle=Persistent messages (1024b) +chartSubtitle=Persistent messages (1KB) +chartDescription=1P 1C, persistent, with message payload 1KB. + xAxisTitle=Acknowledge mode (0=session transacted; 1=auto-acknowledge) -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT acknowledgeMode, throughputKbPerS FROM AcknowledgementModes WHERE testName like 'Persistent%' AND participantName = 'All' ORDER BY acknowledgeMode +series.1.statement=SELECT acknowledgeMode, throughputMessagesPerS FROM AcknowledgementModes WHERE testName like 'Persistent%' AND participantName = 'All' ORDER BY acknowledgeMode series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=blue - -series.2.statement=SELECT acknowledgeMode, throughputKbPerS FROM AcknowledgementModes WHERE testName like 'Persistent%' AND participantName = 'All' ORDER BY acknowledgeMode +series.2.statement=SELECT acknowledgeMode, throughputMessagesPerS FROM AcknowledgementModes WHERE testName like 'Persistent%' AND participantName = 'All' ORDER BY acknowledgeMode series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red diff --git a/java/perftests/etc/chartdefs/1022-AcknowledgementModes-Transient.chartdef b/java/perftests/etc/chartdefs/1022-AcknowledgementModes-Transient.chartdef index 7a26391deb..8ca5d838e2 100644 --- a/java/perftests/etc/chartdefs/1022-AcknowledgementModes-Transient.chartdef +++ b/java/perftests/etc/chartdefs/1022-AcknowledgementModes-Transient.chartdef @@ -20,13 +20,17 @@ chartType=BAR chartTitle=Performance of acknowledgement modes chartSubtitle=Transient messages (1024b) +chartDescription=1P 1C, transient, with message payload 1KB. + xAxisTitle=Acknowledge mode (0=session transacted; 1=auto-acknowledge) -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT acknowledgeMode, throughputKbPerS FROM AcknowledgementModes WHERE testName like 'Transient%' AND participantName = 'All' ORDER BY acknowledgeMode +series.1.statement=SELECT acknowledgeMode, throughputMessagesPerS FROM AcknowledgementModes WHERE testName like 'Transient%' AND participantName = 'All' ORDER BY acknowledgeMode series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=blue -series.2.statement=SELECT acknowledgeMode, throughputKbPerS FROM AcknowledgementModes WHERE testName like 'Transient%' AND participantName = 'All' ORDER BY acknowledgeMode +series.2.statement=SELECT acknowledgeMode, throughputMessagesPerS FROM AcknowledgementModes WHERE testName like 'Transient%' AND participantName = 'All' ORDER BY acknowledgeMode series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red diff --git a/java/perftests/etc/chartdefs/1030-BatchSize-Equal.chartdef b/java/perftests/etc/chartdefs/1030-BatchSize-Equal.chartdef new file mode 100644 index 0000000000..97b712e027 --- /dev/null +++ b/java/perftests/etc/chartdefs/1030-BatchSize-Equal.chartdef @@ -0,0 +1,37 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Transaction Batch Sizes Equal +chartSubtitle=Persistent 1KB messages +chartDescription=1P 1C, persistent, transacted with message payload 1KB with producer/consumer batch size varying between 1-400 messages for both P and C + +xAxisTitle=Batch Size +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT batchSize, throughputMessagesPerS FROM BatchSize WHERE participantName = 'All' +series.1.legend=Equal Producer/Consumer +series.1.dir=${csvCurrentDir} +series.1.colourName=red + +series.2.statement=SELECT batchSize, throughputMessagesPerS FROM BatchSize WHERE participantName = 'All' +series.2.legend=Equal Producer/Consumer (Baseline) +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1031-BatchSize-Unequal.chartdef b/java/perftests/etc/chartdefs/1031-BatchSize-Unequal.chartdef new file mode 100644 index 0000000000..51b3bb2144 --- /dev/null +++ b/java/perftests/etc/chartdefs/1031-BatchSize-Unequal.chartdef @@ -0,0 +1,53 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Transaction Batch Size Unequal +chartSubtitle=Persistent 1KB messages +chartDescription=1P 1C, persistent, transacted with message payload 1KB with fixed batch size 1 for one party whilst other varies between 1-400 messages + +xAxisTitle=Batch Size +yAxisTitle=Throughput (messages/s) + +# +# If csvjdbc could do sub-selects (allowing us to extract the consumer/producer batch size from the All Consumers/All Producers rows), +# we would not need the workaround where we have testdef place the consumer/producer batch size into testName field +# + +series.1.statement=SELECT testName, throughputMessagesPerS FROM BatchSizeProducerVaries WHERE participantName = 'All' +series.1.legend=Variable Producer, Fixed Consumer +series.1.dir=${csvCurrentDir} +series.1.colourName=red + +series.2.statement=SELECT testName, throughputMessagesPerS FROM BatchSizeProducerVaries WHERE participantName = 'All' +series.2.legend=Variable Producer, Fixed Consumer (Baseline) +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 + +series.3.statement=SELECT testName, throughputMessagesPerS FROM BatchSizeConsumerVaries WHERE participantName = 'All' +series.3.legend=Fixed Producer, Variable Consumer +series.3.dir=${csvCurrentDir} +series.3.colourName=blue + +series.4.statement=SELECT testName, throughputMessagesPerS FROM BatchSizeConsumerVaries WHERE participantName = 'All' +series.4.legend=Fixed Producer, Variable Consumer (Baseline) +series.4.dir=${csvBaselineDir} +series.4.colourName=dark_blue +series.4.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1040-QueueTypes.chartdef b/java/perftests/etc/chartdefs/1040-QueueTypes.chartdef index 42ed69c19d..aacedab421 100644 --- a/java/perftests/etc/chartdefs/1040-QueueTypes.chartdef +++ b/java/perftests/etc/chartdefs/1040-QueueTypes.chartdef @@ -20,13 +20,17 @@ chartType=BAR chartTitle=Queue Types chartSubtitle=Persistent 1KB messages +chartDescription=1P 1C, persistent, auto-ack with message payload 1KB. Sorted queue - 160,000 random keys, Priority - iteriates priority 0..9. + xAxisTitle=Queue Types -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT testName, throughputKbPerS FROM QueueTypes WHERE participantName = 'All' +series.1.statement=SELECT testName, throughputMessagesPerS FROM QueueTypes WHERE participantName = 'All' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=blue -series.2.statement=SELECT testName, throughputKbPerS FROM QueueTypes WHERE participantName = 'All' +series.2.statement=SELECT testName, throughputMessagesPerS FROM QueueTypes WHERE participantName = 'All' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red diff --git a/java/perftests/etc/chartdefs/1050-VaryingNumberOfProducerSessionsSingleConnection.chartdef b/java/perftests/etc/chartdefs/1050-VaryingNumberOfProducerSessionsSingleConnection.chartdef new file mode 100644 index 0000000000..46696bf942 --- /dev/null +++ b/java/perftests/etc/chartdefs/1050-VaryingNumberOfProducerSessionsSingleConnection.chartdef @@ -0,0 +1,49 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Varying number of producer sessions on single connection +chartSubtitle=Persistent messages (1024b) +chartDescription=1-80P transacted on single connection, 20C transacted on separate connections, persistent, message payload 1KB. + +xAxisTitle=Number of producer sessions +yAxisTitle=Throughput (KB/s) + +# testName contains the number of sessions +series.1.statement=SELECT testName, throughputKbPerS FROM VaryingNumberOfProducerSessionsSingleConnection WHERE participantName = 'All' +series.1.legend=Current - End-to-end throughput +series.1.dir=${csvCurrentDir} +series.1.colourName=red + +series.2.statement=SELECT testName, throughputKbPerS FROM VaryingNumberOfProducerSessionsSingleConnection WHERE participantName = 'All Producers' +series.2.legend=Current - Producer only throughput +series.2.dir=${csvCurrentDir} +series.2.colourName=blue + +series.3.statement=SELECT testName, throughputKbPerS FROM VaryingNumberOfProducerSessionsSingleConnection WHERE participantName = 'All' +series.3.legend=Baseline - End-to-end throughput +series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red +series.3.strokeWidth=-1 + +series.4.statement=SELECT testName, throughputKbPerS FROM VaryingNumberOfProducerSessionsSingleConnection WHERE participantName = 'All Producers' +series.4.legend=Baseline - Producer only throughput +series.4.dir=${csvBaselineDir} +series.4.colourName=dark_blue +series.4.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1300-QueueConsumersWithNonOverlappingSelectors-Transient.chartdef b/java/perftests/etc/chartdefs/1300-QueueConsumersWithNonOverlappingSelectors-Transient.chartdef new file mode 100644 index 0000000000..5081b379e7 --- /dev/null +++ b/java/perftests/etc/chartdefs/1300-QueueConsumersWithNonOverlappingSelectors-Transient.chartdef @@ -0,0 +1,37 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Impact of non-overlapping selectors on queue consumers with transient messages +chartSubtitle=Transient 1KB messages +xAxisTitle=Consumers +yAxisTitle=Throughput (messages/s) +chartDescription=Impact of non-overlapping selectors on queue consumers with transient messages, auto-ack, message payload of 1024 bytes, 1 producer, varying number of consumers from 1 to 32. + +series.1.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithNonOverlappingSelectors WHERE participantName = 'All' and testName like '%non overlapping - NON_PERSISTENT%' +series.1.legend=Current +series.1.dir=${csvCurrentDir} +series.1.colourName=blue + +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithNonOverlappingSelectors WHERE participantName = 'All' and testName like '%non overlapping - NON_PERSISTENT%' +series.2.legend=Baseline +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.stokeWidth=-1 + diff --git a/java/perftests/etc/chartdefs/1301-QueueConsumersWithNonOverlappingSelectors-Persistent.chartdef b/java/perftests/etc/chartdefs/1301-QueueConsumersWithNonOverlappingSelectors-Persistent.chartdef new file mode 100644 index 0000000000..137f7bde36 --- /dev/null +++ b/java/perftests/etc/chartdefs/1301-QueueConsumersWithNonOverlappingSelectors-Persistent.chartdef @@ -0,0 +1,43 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Impact of non-overlapping selectors on queue consumers with persistent messages +chartSubtitle=Persistent 1KB messages +xAxisTitle=Consumers +yAxisTitle=Throughput (messages/s) +chartDescription=Impact of non-overlapping selectors on queue consumers with persistent messages, auto-ack, message payload of 1024 bytes, 1 producer, varying number of consumers from 1 to 32.. + + +series.1.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithNonOverlappingSelectors WHERE participantName = 'All' and testName like '%non overlapping - PERSISTENT' +series.1.legend=Current +series.1.dir=${csvCurrentDir} +series.1.colourName=blue + +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithNonOverlappingSelectors WHERE participantName = 'All' and testName like '%non overlapping - PERSISTENT' +series.2.legend=Baseline +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.stokeWidth=-1 + +series.3.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '1' and acknowledgeMode = '1' +series.3.legend=Current: no selectors +series.3.dir=${csvCurrentDir} +series.3.colourName=green + diff --git a/java/perftests/etc/chartdefs/1302-QueueConsumersWithOverlappingSelectors-Transient.chartdef b/java/perftests/etc/chartdefs/1302-QueueConsumersWithOverlappingSelectors-Transient.chartdef new file mode 100644 index 0000000000..74f370317b --- /dev/null +++ b/java/perftests/etc/chartdefs/1302-QueueConsumersWithOverlappingSelectors-Transient.chartdef @@ -0,0 +1,36 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Impact of 50%-overlapping selectors in queue consumers with transient messages +chartSubtitle=Transient 1KB messages +xAxisTitle=Consumers +yAxisTitle=Throughput (messages/s) +chartDescription=Impact of 50%-overlapping selectors in queue consumers with transient messages, auto-ack, message payload 1KB, 1 producer, varying number of consumers from 2 to 32. + +series.1.statement=SELECT totalNumberOfConsumers,throughputMessagesPerS FROM QueueConsumersWithOverlappingSelectors WHERE participantName = 'All' and testName like '%50_ overlapping - NON_PERSISTENT%' +series.1.legend=Current +series.1.dir=${csvCurrentDir} +series.1.colourName=blue + +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithOverlappingSelectors WHERE participantName = 'All' and testName like '%50_ overlapping - NON_PERSISTENT%' +series.2.legend=Baseline +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.stokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1303-QueueConsumersWithOverlappingSelectors-Persistent.chartdef b/java/perftests/etc/chartdefs/1303-QueueConsumersWithOverlappingSelectors-Persistent.chartdef new file mode 100644 index 0000000000..0dd78e02ef --- /dev/null +++ b/java/perftests/etc/chartdefs/1303-QueueConsumersWithOverlappingSelectors-Persistent.chartdef @@ -0,0 +1,42 @@ +# +# 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. +# + +chartType=XYLINE +chartTitle=Impact of 50%-overlapping selectors in queue consumers with persistent messages +chartDescription=Impact of 50%-overlapping selectors in queue consumers with persistent messages, auto-ack, message payload of 1KB, 1 producer, varying number of consumers from 2 to 32. +chartSubtitle=Persistent 1KB messages +xAxisTitle=Consumers +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithOverlappingSelectors WHERE participantName = 'All' and testName like '%50_ overlapping - PERSISTENT%' +series.1.legend=Current +series.1.dir=${csvCurrentDir} +series.1.colourName=blue + +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM QueueConsumersWithOverlappingSelectors WHERE participantName = 'All' and testName like '%50_ overlapping - PERSISTENT%' +series.2.legend=Baseline +series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.stokeWidth=-1 + +series.3.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '1' and acknowledgeMode = '1' +series.3.legend=Current: no selectors +series.3.dir=${csvCurrentDir} +series.3.colourName=green + diff --git a/java/perftests/etc/chartdefs/1500-Topic-NumberOfConsumers.chartdef b/java/perftests/etc/chartdefs/1500-Topic-NumberOfConsumers.chartdef index 305c5009e2..073cee810d 100644 --- a/java/perftests/etc/chartdefs/1500-Topic-NumberOfConsumers.chartdef +++ b/java/perftests/etc/chartdefs/1500-Topic-NumberOfConsumers.chartdef @@ -20,13 +20,18 @@ chartType=XYLINE chartTitle=Number of topic consumers chartSubtitle=Transient 1KB messages +chartDescription=1P 1-100C transient, transacted, with message payload 1KB. + xAxisTitle=Numer of consumers -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT testName, throughputKbPerS FROM Topic-NumberOfConsumers WHERE participantName = 'All' +series.1.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM Topic-NumberOfConsumers WHERE participantName = 'All' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=red -series.2.statement=SELECT testName, throughputKbPerS FROM Topic-NumberOfConsumers WHERE participantName = 'All' +series.2.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM Topic-NumberOfConsumers WHERE participantName = 'All' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1501-Topic-NumberOfTopics.chartdef b/java/perftests/etc/chartdefs/1501-Topic-NumberOfTopics.chartdef index 9bc53e5a9e..b32f43d0c2 100644 --- a/java/perftests/etc/chartdefs/1501-Topic-NumberOfTopics.chartdef +++ b/java/perftests/etc/chartdefs/1501-Topic-NumberOfTopics.chartdef @@ -20,13 +20,18 @@ chartType=XYLINE chartTitle=Number of topics chartSubtitle=Transient 1KB messages +chartDescription=1,10,50,100 PC, transient, transacted, with each PC pair having own topic, message payload 1KB. + xAxisTitle=Numer of topics -yAxisTitle=Throughput (KB/s) +yAxisTitle=Throughput (messages/s) -series.1.statement=SELECT testName, throughputKbPerS FROM Topic-NumberOfTopics WHERE participantName = 'All' +series.1.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM Topic-NumberOfTopics WHERE participantName = 'All' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=red -series.2.statement=SELECT testName, throughputKbPerS FROM Topic-NumberOfTopics WHERE participantName = 'All' +series.2.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM Topic-NumberOfTopics WHERE participantName = 'All' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.strokeWidth=-1 diff --git a/java/perftests/etc/chartdefs/1502-Topic-Persistence.chartdef b/java/perftests/etc/chartdefs/1502-Topic-Persistence.chartdef index ce64d14ac4..5fd905ab4f 100644 --- a/java/perftests/etc/chartdefs/1502-Topic-Persistence.chartdef +++ b/java/perftests/etc/chartdefs/1502-Topic-Persistence.chartdef @@ -20,13 +20,18 @@ chartType=BAR chartTitle=Topic transient/durable subscriptions chartSubtitle=1KB messages -xAxisTitle=Durable subscription -yAxisTitle=Throughput (KB/s) +chartDescription=1P 10C, transacted, message payload 1KB, transient messages on non-durable sub, persistent messages on durable sub -series.1.statement=SELECT isDurableSubscription, throughputKbPerS FROM Topic-Persistence WHERE participantName = 'All Consumers' +xAxisTitle=Subscription type (true durable, false non durable) +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT isDurableSubscription, throughputMessagesPerS FROM Topic-Persistence WHERE participantName = 'All Consumers' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=blue -series.2.statement=SELECT isDurableSubscription, throughputKbPerS FROM Topic-Persistence WHERE participantName = 'All Consumers' +series.2.statement=SELECT isDurableSubscription, throughputMessagesPerS FROM Topic-Persistence WHERE participantName = 'All Consumers' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.stokeWidth=2 diff --git a/java/perftests/etc/chartdefs/1503-Topic-AckModes.chartdef b/java/perftests/etc/chartdefs/1503-Topic-AckModes.chartdef index 5ccc166fc8..9edb1950a4 100644 --- a/java/perftests/etc/chartdefs/1503-Topic-AckModes.chartdef +++ b/java/perftests/etc/chartdefs/1503-Topic-AckModes.chartdef @@ -20,13 +20,18 @@ chartType=BAR chartTitle=Topic acknowledge modes chartSubtitle=Transient 1KB messages -xAxisTitle=Ack Mode -yAxisTitle=Throughput (KB/s) +chartDescription=1P 10C, transient, non-durable subscription, message payload 1KB -series.1.statement=SELECT acknowledgeMode, throughputKbPerS FROM Topic-AckModes WHERE participantName = 'All' +xAxisTitle=Ack Mode (0=transaction 1=auto-ack) +yAxisTitle=Throughput (messages/s) + +series.1.statement=SELECT acknowledgeMode, throughputMessagesPerS FROM Topic-AckModes WHERE participantName = 'All' series.1.legend=Current series.1.dir=${csvCurrentDir} +series.1.colourName=blue -series.2.statement=SELECT acknowledgeMode, throughputKbPerS FROM Topic-AckModes WHERE participantName = 'All' +series.2.statement=SELECT acknowledgeMode, throughputMessagesPerS FROM Topic-AckModes WHERE participantName = 'All' series.2.legend=Baseline series.2.dir=${csvBaselineDir} +series.2.colourName=dark_red +series.2.stokeWidth=2 diff --git a/java/perftests/etc/chartdefs/2001-Latency-MessageSize-Transient.chartdef b/java/perftests/etc/chartdefs/2001-Latency-MessageSize-Transient.chartdef index c892ea16cf..67a0278bff 100644 --- a/java/perftests/etc/chartdefs/2001-Latency-MessageSize-Transient.chartdef +++ b/java/perftests/etc/chartdefs/2001-Latency-MessageSize-Transient.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Impact of message size on latency chartSubtitle=Transient messages +chartDescription=1P 1C, transient, auto-ack, with message payload between 256-262144 bytes. + xAxisTitle=Message Size (B) yAxisTitle=Latency (millis) series.1.statement=SELECT payloadSizeB, maxLatency, 0 FROM Latency-MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All Consumers' series.1.legend=Maximum latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT payloadSizeB, averageLatency,latencyStandardDeviation FROM Latency-MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All Consumers' series.2.legend=Average latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT payloadSizeB, averageLatency,latencyStandardDeviation FROM Latency-MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All Consumers' series.3.legend=Average latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT payloadSizeB, minLatency,0 FROM Latency-MessageSize WHERE testName like '%TRANSIENT' AND participantName = 'All Consumers' series.4.legend=Minimum latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/2002-Latency-MessageSize-Persistent.chartdef b/java/perftests/etc/chartdefs/2002-Latency-MessageSize-Persistent.chartdef index 167e62603a..e9761f07d8 100644 --- a/java/perftests/etc/chartdefs/2002-Latency-MessageSize-Persistent.chartdef +++ b/java/perftests/etc/chartdefs/2002-Latency-MessageSize-Persistent.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Impact of message size on latency chartSubtitle=Persistent messages +chartDescription=1P 1C, persistent, auto-ack, with message payload between 256-262144 bytes. + xAxisTitle=Message Size (B) yAxisTitle=Latency (millis) series.1.statement=SELECT payloadSizeB, maxLatency, 0 FROM Latency-MessageSize WHERE testName like '%PERSISTENT' AND participantName = 'All Consumers' series.1.legend=Maximum latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT payloadSizeB, averageLatency, latencyStandardDeviation FROM Latency-MessageSize WHERE testName like '%PERSISTENT' AND participantName = 'All Consumers' series.2.legend=Average latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT payloadSizeB, averageLatency, latencyStandardDeviation FROM Latency-MessageSize WHERE testName like '%PERSISTENT' AND participantName = 'All Consumers' series.3.legend=Average latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT payloadSizeB, minLatency, 0 FROM Latency-MessageSize WHERE testName like '%PERSISTENT' AND participantName = 'All Consumers' series.4.legend=Minimum latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/2011-Latency-QueuesWithNonOverlappingSelectors-Transient.chartdef b/java/perftests/etc/chartdefs/2011-Latency-QueuesWithNonOverlappingSelectors-Transient.chartdef index 45c6031b1e..663912b622 100644 --- a/java/perftests/etc/chartdefs/2011-Latency-QueuesWithNonOverlappingSelectors-Transient.chartdef +++ b/java/perftests/etc/chartdefs/2011-Latency-QueuesWithNonOverlappingSelectors-Transient.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Latency with consumers having non-overlapping selectors chartSubtitle=Transient 1KB messages +chartDescription=1P 1-10C, transient, auto-ack, with message payload 1KB. + xAxisTitle=Consumers yAxisTitle=Latency (millis) series.1.statement=SELECT totalNumberOfConsumers, maxLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - NON_PERSISTENT%' series.1.legend=Max latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - NON_PERSISTENT%' series.2.legend=Average latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - NON_PERSISTENT%' series.3.legend=Average latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT totalNumberOfConsumers, minLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - NON_PERSISTENT%' series.4.legend=Min latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/2012-Latency-QueuesWithOverlappingSelectors-Transient.chartdef b/java/perftests/etc/chartdefs/2012-Latency-QueuesWithOverlappingSelectors-Transient.chartdef index 351a4639b1..3b9e207e10 100644 --- a/java/perftests/etc/chartdefs/2012-Latency-QueuesWithOverlappingSelectors-Transient.chartdef +++ b/java/perftests/etc/chartdefs/2012-Latency-QueuesWithOverlappingSelectors-Transient.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Latency with consumers having 50%-overlapping selectors chartSubtitle=Transient 1KB messages +chartDescription=1P 1-10C, transient, auto-ack, with message payload 1KB. + xAxisTitle=Consumers yAxisTitle=Latency (millis) series.1.statement=SELECT totalNumberOfConsumers, maxLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - NON_PERSISTENT%' series.1.legend=Max latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - NON_PERSISTENT%' series.2.legend=Average latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - NON_PERSISTENT%' series.3.legend=Average latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT totalNumberOfConsumers, minLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - NON_PERSISTENT%' series.4.legend=Min latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/2021-Latency-QueuesWithNonOverlappingSelectors-Persistent.chartdef b/java/perftests/etc/chartdefs/2021-Latency-QueuesWithNonOverlappingSelectors-Persistent.chartdef index 9d95075b3d..296d115d3f 100644 --- a/java/perftests/etc/chartdefs/2021-Latency-QueuesWithNonOverlappingSelectors-Persistent.chartdef +++ b/java/perftests/etc/chartdefs/2021-Latency-QueuesWithNonOverlappingSelectors-Persistent.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Latency with consumers having non-overlapping selectors chartSubtitle=Persistent 1KB messages +chartDescription=1P 1-10C, persistent, auto-ack, with message payload 1KB. + xAxisTitle=Consumers yAxisTitle=Latency (millis) series.1.statement=SELECT totalNumberOfConsumers, maxLatency,0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - PERSISTENT' series.1.legend=Max latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT totalNumberOfConsumers, averageLatency, latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - PERSISTENT' series.2.legend=Average latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT totalNumberOfConsumers, averageLatency, latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - PERSISTENT' series.3.legend=Average latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT totalNumberOfConsumers, minLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%non overlapping - PERSISTENT' series.4.legend=Min latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/2022-Latency-QueuesWithOverlappingSelectors-Persistent.chartdef b/java/perftests/etc/chartdefs/2022-Latency-QueuesWithOverlappingSelectors-Persistent.chartdef index 9a323d4044..65be60b5e5 100644 --- a/java/perftests/etc/chartdefs/2022-Latency-QueuesWithOverlappingSelectors-Persistent.chartdef +++ b/java/perftests/etc/chartdefs/2022-Latency-QueuesWithOverlappingSelectors-Persistent.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Latency with consumers having 50%-overlapping selectors chartSubtitle=Persistent 1KB messages +chartDescription=1P 1-10C, persistent, auto-ack, with message payload 1KB. + xAxisTitle=Consumers yAxisTitle=Latency (millis) series.1.statement=SELECT totalNumberOfConsumers, maxLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - PERSISTENT%' series.1.legend=Max latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - PERSISTENT%' series.2.legend=Average latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - PERSISTENT%' series.3.legend=Average latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT totalNumberOfConsumers, minLatency, 0 FROM Latency-QueuesWithSelectors WHERE participantName = 'All Consumers' and testName like '%overlapping 50% - PERSISTENT%' series.4.legend=Min latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/2031-Latency-VaryingNumberOfParticipants.chartdef b/java/perftests/etc/chartdefs/2031-Latency-VaryingNumberOfParticipants.chartdef index 82cf1168ef..d52b05d870 100644 --- a/java/perftests/etc/chartdefs/2031-Latency-VaryingNumberOfParticipants.chartdef +++ b/java/perftests/etc/chartdefs/2031-Latency-VaryingNumberOfParticipants.chartdef @@ -20,25 +20,32 @@ chartType=STATISTICAL_BAR chartTitle=Latency, varying number of participants chartSubtitle=Persistent 1KB messages +chartDescription=1,2,5,10 P/Cs, persistent, auto-ack, with message payload 1KB. + xAxisTitle=Consumers yAxisTitle=Latency (millis) series.1.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-VaryingNumberOfParticipants WHERE participantName = 'All Consumers' and testName like '% - 1 producer - PERSISTENT' series.1.legend=1 producer series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-VaryingNumberOfParticipants WHERE participantName = 'All Consumers' and testName like '% - 2 producers - PERSISTENT' series.2.legend=2 producers series.2.dir=${csvCurrentDir} +series.2.colourName=green series.3.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-VaryingNumberOfParticipants WHERE participantName = 'All Consumers' and testName like '% - 5 producers - PERSISTENT' series.3.legend=5 producers series.3.dir=${csvCurrentDir} +series.3.colourName=magenta series.4.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-VaryingNumberOfParticipants WHERE participantName = 'All Consumers' and testName like '% - 10 producers - PERSISTENT' series.4.legend=10 producers series.4.dir=${csvCurrentDir} +series.4.colourName=red series.5.statement=SELECT totalNumberOfConsumers, averageLatency,latencyStandardDeviation FROM Latency-VaryingNumberOfParticipants WHERE participantName = 'All Consumers' and testName like '% - 10 producers - PERSISTENT' series.5.legend=10 producers (baseline) series.5.dir=${csvBaselineDir} +series.5.colourName=dark_red diff --git a/java/perftests/etc/chartdefs/2041-Latency-QueueTypes.chartdef b/java/perftests/etc/chartdefs/2041-Latency-QueueTypes.chartdef index c1aae19376..dac8a52f89 100644 --- a/java/perftests/etc/chartdefs/2041-Latency-QueueTypes.chartdef +++ b/java/perftests/etc/chartdefs/2041-Latency-QueueTypes.chartdef @@ -20,21 +20,27 @@ chartType=STATISTICAL_BAR chartTitle=Latency on different queues chartSubtitle=Persistent 1KB messages +chartDescription=1P 1C, persistent, auto-ack with message payload 1KB. Sorted queue - 400 varied keys, Priority - 200 varied priorities. + xAxisTitle=Queue type yAxisTitle=Latency (millis) series.1.statement=SELECT testName, maxLatency,0 FROM Latency-QueueTypes WHERE participantName = 'All Consumers' series.1.legend=Maximum latency series.1.dir=${csvCurrentDir} +series.1.colourName=blue series.2.statement=SELECT testName, averageLatency,latencyStandardDeviation FROM Latency-QueueTypes WHERE participantName = 'All Consumers' series.2.legend=Average Latency series.2.dir=${csvCurrentDir} +series.2.colourName=red series.3.statement=SELECT testName, averageLatency,latencyStandardDeviation FROM Latency-QueueTypes WHERE participantName = 'All Consumers' series.3.legend=Average Latency (baseline) series.3.dir=${csvBaselineDir} +series.3.colourName=dark_red series.4.statement=SELECT testName, minLatency,0 FROM Latency-QueueTypes WHERE participantName = 'All Consumers' series.4.legend=Minimum latency series.4.dir=${csvCurrentDir} +series.4.colourName=green diff --git a/java/perftests/etc/chartdefs/timeseries/1001-Large-Messages-Transient.chartdef b/java/perftests/etc/chartdefs/timeseries/1001-Large-Messages-Transient.chartdef new file mode 100644 index 0000000000..e77f7b4eff --- /dev/null +++ b/java/perftests/etc/chartdefs/timeseries/1001-Large-Messages-Transient.chartdef @@ -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. +# + +chartType=TIMELINE +chartTitle=Large transient messages +chartDescription=1P 1C, transient, auto-ack, with message payload 65536 bytes. + +xAxisTitle=Date +yAxisTitle=Throughput (KB/s) + +series.1.statement=SELECT insertedTimestamp, throughputKbPerS FROM RESULTS WHERE participantName = 'All' AND testName = 'Message Size - 1P-1C - TRANSIENT' and payloadSizeB = 65536 +series.1.colourName=red +series.1.legend=Throughput diff --git a/java/perftests/etc/chartdefs/timeseries/1002-Large-Messages-Persistent.chartdef b/java/perftests/etc/chartdefs/timeseries/1002-Large-Messages-Persistent.chartdef new file mode 100644 index 0000000000..ffcf8c26b8 --- /dev/null +++ b/java/perftests/etc/chartdefs/timeseries/1002-Large-Messages-Persistent.chartdef @@ -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. +# + +chartType=TIMELINE +chartTitle=Large persistent messages +chartDescription=1P 1C, persistent, auto-ack, with message payload 65536 bytes. + +xAxisTitle=Date +yAxisTitle=Throughput (KB/s) + +series.1.statement=SELECT insertedTimestamp, throughputKbPerS FROM RESULTS WHERE participantName = 'All' AND testName = 'Message Size - 1P-1C - PERSISTENT' and payloadSizeB = 65536 +series.1.colourName=red +series.1.legend=Throughput diff --git a/java/perftests/etc/chartdefs/timeseries/1011-MultipleProducersAndConsumers-Persistent.chartdef b/java/perftests/etc/chartdefs/timeseries/1011-MultipleProducersAndConsumers-Persistent.chartdef new file mode 100644 index 0000000000..ba01d4b7ad --- /dev/null +++ b/java/perftests/etc/chartdefs/timeseries/1011-MultipleProducersAndConsumers-Persistent.chartdef @@ -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. +# + +chartType=TIMELINE +chartTitle=Multiple producers and consumers - auto ack +chartSubtitle=Persistent 1KB messages +chartDescription=10 P/Cs, persistent, auto-ack, with message payload 1KB. + +xAxisTitle=Date +yAxisTitle=Throughput (KB/s) + +series.1.statement=SELECT insertedTimestamp, throughputKbPerS FROM RESULTS WHERE participantName = 'All' AND testName = 'Varying number of participants: 10 consumers - 10 producers - PERSISTENT' +series.1.colourName=red +series.1.legend=Throughput
\ No newline at end of file diff --git a/java/perftests/etc/chartdefs/1030-BatchSize.chartdef b/java/perftests/etc/chartdefs/timeseries/1030-Batch-Size-Small.chartdef index 1f01aa85aa..f755bf4a5b 100644 --- a/java/perftests/etc/chartdefs/1030-BatchSize.chartdef +++ b/java/perftests/etc/chartdefs/timeseries/1030-Batch-Size-Small.chartdef @@ -17,17 +17,14 @@ # under the License. # -chartType=XYLINE -chartTitle=Transaction Batch Size +chartType=TIMELINE +chartTitle=Transactions chartSubtitle=Persistent 1KB messages -xAxisTitle=Batch Size -yAxisTitle=Throughput (KB/s) - -series.1.statement=SELECT batchSize, throughputKbPerS FROM BatchSize WHERE participantName = 'All' -series.1.legend=Current -series.1.dir=${csvCurrentDir} +chartDescription=1P 1C, persistent, transacted with message payload 1KB with batch size 1 for both P and C -series.2.statement=SELECT batchSize, throughputKbPerS FROM BatchSize WHERE participantName = 'All' -series.2.legend=Baseline -series.2.dir=${csvBaselineDir} +xAxisTitle=Date +yAxisTitle=Throughput (KB/s) +series.1.statement=SELECT insertedTimestamp, throughputKbPerS FROM RESULTS WHERE participantName = 'All' AND testName = 'Batch Size 1-1 - PERSISTENT' +series.1.colourName=red +series.1.legend=Throughput
\ No newline at end of file diff --git a/java/perftests/etc/chartdefs/timeseries/1031-Batch-Size-Large.chartdef b/java/perftests/etc/chartdefs/timeseries/1031-Batch-Size-Large.chartdef new file mode 100644 index 0000000000..ca390f8226 --- /dev/null +++ b/java/perftests/etc/chartdefs/timeseries/1031-Batch-Size-Large.chartdef @@ -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. +# + +chartType=TIMELINE +chartTitle=Transactions with large batches +chartSubtitle=Persistent 1KB messages +chartDescription=1P 1C, persistent, transacted with message payload 1KB with batch size 100 for both P and C + +xAxisTitle=Date +yAxisTitle=Throughput (KB/s) + +series.1.statement=SELECT insertedTimestamp, throughputKbPerS FROM RESULTS WHERE participantName = 'All' AND testName = 'Batch Size 100-100 - PERSISTENT' +series.1.colourName=red +series.1.legend=Throughput diff --git a/java/perftests/etc/chartdefs/timeseries/1040-SortedQueue.chartdef b/java/perftests/etc/chartdefs/timeseries/1040-SortedQueue.chartdef new file mode 100644 index 0000000000..6dce3a1a77 --- /dev/null +++ b/java/perftests/etc/chartdefs/timeseries/1040-SortedQueue.chartdef @@ -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. +# + +chartType=TIMELINE +chartTitle=Sorted queue +chartSubtitle=Persistent 1KB messages +chartDescription=1P 1C, persistent, auto-ack with message payload 1KB. Sorted queue with 160,000 random keys + +xAxisTitle=Date +yAxisTitle=Throughput (KB/s) + +series.1.statement=SELECT insertedTimestamp, throughputKbPerS FROM RESULTS WHERE participantName = 'All' AND testName = 'queue-type:sorted-queue' +series.1.colourName=red +series.1.legend=Throughput
\ No newline at end of file diff --git a/java/perftests/etc/perftests-jndi.properties b/java/perftests/etc/perftests-jndi.properties index f33af6fdd5..ce6493b49a 100644 --- a/java/perftests/etc/perftests-jndi.properties +++ b/java/perftests/etc/perftests-jndi.properties @@ -20,3 +20,7 @@ java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextF connectionfactory.connectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672' destination.controllerqueue = direct://amq.direct//controllerqueue?autodelete='true' + +jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver +# writes to a results database in ./perftestResultsDb by default. +jdbcUrl=jdbc:derby:perftestResultsDb;create=true diff --git a/java/perftests/etc/run-perftests.sh b/java/perftests/etc/run-perftests.sh new file mode 100755 index 0000000000..f963879e7e --- /dev/null +++ b/java/perftests/etc/run-perftests.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# 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. +# + +# Runs the perftests using a typical configuration. + +BASE_DIR=`dirname $0` +DURATION=${1:-5000} +AMQP_VERSION=${2:-0-91} + +echo Will run perftests using a maximum duration of ${DURATION}ms and AMQP protocol version ${AMQP_VERSION}. +echo + +java -cp "${BASE_DIR}:${BASE_DIR}/../../build/lib/*" \ + -Dqpid.amqp.version=${AMQP_VERSION} -Dqpid.dest_syntax=BURL \ + -Dqpid.disttest.duration=$DURATION \ + org.apache.qpid.disttest.ControllerRunner \ + jndi-config=${BASE_DIR}/perftests-jndi.properties \ + test-config=${BASE_DIR}/testdefs \ + distributed=false \ + writeToDb=true diff --git a/java/perftests/etc/testdefs/BatchSize.js b/java/perftests/etc/testdefs/BatchSize.js new file mode 100644 index 0000000000..f17751b7b5 --- /dev/null +++ b/java/perftests/etc/testdefs/BatchSize.js @@ -0,0 +1,102 @@ +/* + * + * 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. + * + */ + +var jsonObject = { + _tests:[] +}; + +var duration = 30000; + +var txBatchSizes = [[1,1], [2,2], [5,5], [10,10], [20,20], [50,50], [100,100], [200,200], [400,400]]; + +var acknowledgeMode = 0; +var deliveryMode = 2; +var messageSize = 1024; + +for(i=0; i < txBatchSizes.length ; i++) +{ + var producerBatchSize = txBatchSizes[i][0]; + var consumerBatchSize = txBatchSizes[i][1]; + var queueName = "txBatchSize" + producerBatchSize + "_" + consumerBatchSize; + var destination = "direct://amq.direct//" + queueName + "?durable='true'"; + + var test = { + "_name": "Batch Size " + producerBatchSize + "-" + consumerBatchSize + " - PERSISTENT", + "_queues":[ + { + "_name": queueName, + "_durable": true + } + ], + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": acknowledgeMode, + "_producers": [ + { + "_name": "Producer1", + "_destinationName": destination, + "_messageSize": messageSize, + "_deliveryMode": deliveryMode, + "_batchSize": producerBatchSize, + "_maximumDuration": duration + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": acknowledgeMode, + "_consumers": [ + { + "_name": "Consumer1", + "_destinationName": destination, + "_batchSize": consumerBatchSize, + "_maximumDuration": duration + } + ] + } + ] + } + ] + } + ] + }; + + jsonObject._tests= jsonObject._tests.concat(test); +} diff --git a/java/perftests/etc/testdefs/BatchSize.json b/java/perftests/etc/testdefs/BatchSize.json deleted file mode 100644 index eeb446bad6..0000000000 --- a/java/perftests/etc/testdefs/BatchSize.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "_tests":[ - { - "_name": "Batch Size- PERSISTENT"; - "_iterations":[ - { - "_batchSize": 1 - }, - { - "_batchSize": 2 - }, - { - "_batchSize": 5 - }, - { - "_batchSize": 10 - }, - { - "_batchSize": 20 - }, - { - "_batchSize": 50 - }, - { - "_batchSize": 100 - } - ], - "_queues":[ - { - "_name": "direct://amq.direct//batchSize?durable='true'", - "_durable": true - } - ], - "_clients":[ - { - "_name": "producingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_acknowledgeMode": 0, - "_producers": [ - { - "_name": "Producer1", - "_destinationName": "direct://amq.direct//batchSize?durable='true'", - "_messageSize": 1024, - "_maximumDuration": 30000, - "_deliveryMode": 2 - } - ] - } - ] - } - ] - }, - { - "_name": "consumingClient", - "_connections":[ - { - "_name": "connection1", - "_factory": "connectionfactory", - "_sessions": [ - { - "_sessionName": "session1", - "_acknowledgeMode": 0, - "_consumers": [ - { - "_name": "Consumer1", - "_destinationName": "direct://amq.direct//batchSize?durable='true'", - "_maximumDuration": 30000 - } - ] - } - ] - } - ] - } - ] - } - ] -} diff --git a/java/perftests/etc/testdefs/BatchSizeConsumerVaries.js b/java/perftests/etc/testdefs/BatchSizeConsumerVaries.js new file mode 100644 index 0000000000..b491f431c9 --- /dev/null +++ b/java/perftests/etc/testdefs/BatchSizeConsumerVaries.js @@ -0,0 +1,102 @@ +/* + * + * 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. + * + */ + +var jsonObject = { + _tests:[] +}; + +var duration = 30000; + +var txBatchSizes = [[1,1], [1,2], [1,5], [1,10], [1,20], [1,50], [1,100], [1,200], [1,400]]; + +var acknowledgeMode = 0; +var deliveryMode = 2; +var messageSize = 1024; + +for(i=0; i < txBatchSizes.length ; i++) +{ + var producerBatchSize = txBatchSizes[i][0]; + var consumerBatchSize = txBatchSizes[i][1]; + var queueName = "txBatchSize" + producerBatchSize + "_" + consumerBatchSize; + var destination = "direct://amq.direct//" + queueName + "?durable='true'"; + + var test = { + "_name": consumerBatchSize,// hack - use test name to expose the consumer batch size on the All result rows + "_queues":[ + { + "_name": queueName, + "_durable": true + } + ], + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": acknowledgeMode, + "_producers": [ + { + "_name": "Producer1", + "_destinationName": destination, + "_messageSize": messageSize, + "_deliveryMode": deliveryMode, + "_batchSize": producerBatchSize, + "_maximumDuration": duration + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": acknowledgeMode, + "_consumers": [ + { + "_name": "Consumer1", + "_destinationName": destination, + "_batchSize": consumerBatchSize, + "_maximumDuration": duration + } + ] + } + ] + } + ] + } + ] + }; + + jsonObject._tests= jsonObject._tests.concat(test); +} diff --git a/java/perftests/etc/testdefs/BatchSizeProducerVaries.js b/java/perftests/etc/testdefs/BatchSizeProducerVaries.js new file mode 100644 index 0000000000..ac23c52c9e --- /dev/null +++ b/java/perftests/etc/testdefs/BatchSizeProducerVaries.js @@ -0,0 +1,102 @@ +/* + * + * 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. + * + */ + +var jsonObject = { + _tests:[] +}; + +var duration = 30000; + +var txBatchSizes = [[1,1], [2,1], [5,1], [10,1], [20,1], [50,1], [100,1], [200,1], [400,1]]; + +var acknowledgeMode = 0; +var deliveryMode = 2; +var messageSize = 1024; + +for(i=0; i < txBatchSizes.length ; i++) +{ + var producerBatchSize = txBatchSizes[i][0]; + var consumerBatchSize = txBatchSizes[i][1]; + var queueName = "txBatchSize" + producerBatchSize + "_" + consumerBatchSize; + var destination = "direct://amq.direct//" + queueName + "?durable='true'"; + + var test = { + "_name": producerBatchSize,// hack - use test name to expose the producer batch size on the All result rows + "_queues":[ + { + "_name": queueName, + "_durable": true + } + ], + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": acknowledgeMode, + "_producers": [ + { + "_name": "Producer1", + "_destinationName": destination, + "_messageSize": messageSize, + "_deliveryMode": deliveryMode, + "_batchSize": producerBatchSize, + "_maximumDuration": duration + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": acknowledgeMode, + "_consumers": [ + { + "_name": "Consumer1", + "_destinationName": destination, + "_batchSize": consumerBatchSize, + "_maximumDuration": duration + } + ] + } + ] + } + ] + } + ] + }; + + jsonObject._tests= jsonObject._tests.concat(test); +} diff --git a/java/perftests/etc/testdefs/QueueConsumersWithNonOverlappingSelectors.js b/java/perftests/etc/testdefs/QueueConsumersWithNonOverlappingSelectors.js new file mode 100644 index 0000000000..0dd45b0392 --- /dev/null +++ b/java/perftests/etc/testdefs/QueueConsumersWithNonOverlappingSelectors.js @@ -0,0 +1,120 @@ +/* + * + * 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. + * + */ +var jsonObject = { + _tests:[] +}; + +for (var i=0; i<2; i++) +{ + var deliveryMode = i+1; + var durable = (deliveryMode == 2); + var suffix = durable ? "PERSISTENT" : "NON-PERSISTENT"; + var queueName = "direct://amq.direct//queue-selectors-" + suffix + "?durable='" + durable + "'"; + var consumerNumbers = [1, 2, 4, 8, 16, 32]; + var consumerAcknowledgeMode = 1; + for (var j=0; j<consumerNumbers.length; j++) + { + var consumerNumber = consumerNumbers[j]; + var testName = "Queues with selectors: " +consumerNumber + " consumers - 1 producer - non overlapping - " + suffix; + var test = { + "_name": testName, + "_queues":[ + { + "_name": queueName, + "_durable": durable, + "_attributes": + { + "x-qpid-capacity": 10485760, + "x-qpid-flow-resume-capacity": 8388608 + } + } + ], + "_clients":[ + { + "_name": "producingClient", + "_messageProviders": [ + { + "_name": "messageProvider", + "_messageProperties": { + "id": { + "@def": "range", + "_lower": 1, + "_upper": consumerNumber, + "_type": "int" + } + } + } + ], + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": 1, + "_producers": [ + { + "_name": "Producer1", + "_destinationName": queueName, + "_maximumDuration": 60000, + "_deliveryMode": deliveryMode, + "_messageSize": 1024, + "_messageProviderName": "messageProvider" + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[] + } + ] + }; + for(var n=0; n<consumerNumber; n++) + { + var consumerConnection = { + "_name": "connection" + n, + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session" + n, + "_acknowledgeMode": consumerAcknowledgeMode, + "_consumers": [ + { + "_name": "Consumer" + n, + "_destinationName": queueName, + "_maximumDuration": 60000, + "_selector": "id=" + ( n + 1) + } + ] + } + ] + }; + test._clients[1]._connections.push(consumerConnection); + } + jsonObject._tests.push(test); + } +} + diff --git a/java/perftests/etc/testdefs/QueueConsumersWithOverlappingSelectors.js b/java/perftests/etc/testdefs/QueueConsumersWithOverlappingSelectors.js new file mode 100644 index 0000000000..20cfb4ad45 --- /dev/null +++ b/java/perftests/etc/testdefs/QueueConsumersWithOverlappingSelectors.js @@ -0,0 +1,131 @@ +/* + * + * 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. + * + */ +var jsonObject = { + _tests:[] +}; + +for (var i=0; i<2; i++) +{ + var deliveryMode = i+1; + var durable = (deliveryMode == 2); + var suffix = durable ? "PERSISTENT" : "NON-PERSISTENT"; + var queueName = "direct://amq.direct//queue-selectors-overlapping-" + suffix + "?durable='" + durable + "'"; + var consumerNumbers = [2, 4, 8, 16, 32]; + var consumerAcknowledgeMode = 1; + for (var j=0; j<consumerNumbers.length; j++) + { + var consumerNumber = consumerNumbers[j]; + var testName = "Queues with selectors: " +consumerNumber + " consumers - 1 producer - 50% overlapping - " + suffix; + var test = { + "_name": testName, + "_queues":[ + { + "_name": queueName, + "_durable": durable, + "_attributes": + { + "x-qpid-capacity": 10485760, + "x-qpid-flow-resume-capacity": 8388608 + } + } + ], + "_clients":[ + { + "_name": "producingClient", + "_messageProviders": [ + { + "_name": "messageProvider", + "_messageProperties": { + "id": { + "@def": "range", + "_lower": 1, + "_upper": consumerNumber * 2, + "_type": "int" + } + } + } + ], + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session1", + "_acknowledgeMode": 1, + "_producers": [ + { + "_name": "Producer1", + "_destinationName": queueName, + "_maximumDuration": 60000, + "_deliveryMode": deliveryMode, + "_messageSize": 1024, + "_messageProviderName": "messageProvider" + } + ] + } + ] + } + ] + }, + { + "_name": "consumingClient", + "_connections":[] + } + ] + }; + + var selectorBase = ""; + var maxId = consumerNumber * 2; + // odd IDs overlaps in each selector expression + for (var m = 1; m <= maxId; m+=2) + { + selectorBase += " or id=" + m; + } + for(var n = 0, id = 0 ; n< consumerNumber; n++) + { + // even IDs are unique per each selector expression + id = id + 2; + selector = "id=" + id + selectorBase; + var consumerConnection = { + "_name": "connection" + n, + "_factory": "connectionfactory", + "_sessions": [ + { + "_sessionName": "session" + n, + "_acknowledgeMode": consumerAcknowledgeMode, + "_consumers": [ + { + "_name": "Consumer" + n, + "_destinationName": queueName, + "_maximumDuration": 60000, + "_selector": selector + } + ] + } + ] + }; + test._clients[1]._connections.push(consumerConnection); + } + jsonObject._tests.push(test); + } +} + diff --git a/java/perftests/etc/testdefs/Topic-AckModes.js b/java/perftests/etc/testdefs/Topic-AckModes.js index 63c4b8646e..3f7eb5d3a7 100644 --- a/java/perftests/etc/testdefs/Topic-AckModes.js +++ b/java/perftests/etc/testdefs/Topic-AckModes.js @@ -27,13 +27,10 @@ var jsonObject = { "_name": "Topic ack modes", "_iterations": [ { - "_acknowledgeMode": 1 - }, - { - "_acknowledgeMode": 2 + "_acknowledgeMode": 0 }, { - "_acknowledgeMode": 3 + "_acknowledgeMode": 1 } ], "_clients": [ @@ -50,6 +47,7 @@ var jsonObject = { { "_name": "Producer", "_destinationName": topicName, + "_isTopic": true, "_deliveryMode": 1, "_maximumDuration": duration, "_startDelay": 2000 // gives the consumers time to implicitly create the topic @@ -75,6 +73,7 @@ var jsonObject = { { "_name": "Consumer-__INDEX", "_destinationName": topicName, + "_isTopic": true, "_maximumDuration": duration, } ] diff --git a/java/perftests/etc/testdefs/Topic-NumberOfConsumers.js b/java/perftests/etc/testdefs/Topic-NumberOfConsumers.js index 58ae2f5862..1d38ff08e5 100644 --- a/java/perftests/etc/testdefs/Topic-NumberOfConsumers.js +++ b/java/perftests/etc/testdefs/Topic-NumberOfConsumers.js @@ -42,10 +42,12 @@ for(i=0; i < numbersOfConsumers.length ; i++) "_sessions": [ { "_sessionName": "session1", + "_acknowledgeMode": 0, "_producers": [ { "_name": "Producer1", "_destinationName": topicName, + "_isTopic": true, "_deliveryMode": 1, "_maximumDuration": duration, "_startDelay": 2000 // gives the consumers time to implicitly create the topic @@ -66,10 +68,12 @@ for(i=0; i < numbersOfConsumers.length ; i++) "_sessions": [ { "_sessionName": "session1", + "_acknowledgeMode": 0, "_consumers": [ { "_name": "Consumer-__INDEX", "_destinationName": topicName, + "_isTopic": true, "_maximumDuration": duration } ] diff --git a/java/perftests/etc/testdefs/Topic-NumberOfTopics.js b/java/perftests/etc/testdefs/Topic-NumberOfTopics.js index d31dd36c76..811f8e3a07 100644 --- a/java/perftests/etc/testdefs/Topic-NumberOfTopics.js +++ b/java/perftests/etc/testdefs/Topic-NumberOfTopics.js @@ -45,10 +45,12 @@ for(i=0; i < numbersOfTopics.length ; i++) "_sessions": [ { "_sessionName": "session1", + "_acknowledgeMode": 0, "_producers": [ { "_name": "Producer-__INDEX", "_destinationName": topicName, + "_isTopic": true, "_deliveryMode": 1, "_maximumDuration": duration, "_startDelay": 2000 // gives the consumers time to implicitly create the topic @@ -71,10 +73,12 @@ for(i=0; i < numbersOfTopics.length ; i++) "_sessions": [ { "_sessionName": "session1", + "_acknowledgeMode": 0, "_consumers": [ { "_name": "Consumer-__INDEX", "_destinationName": topicName, + "_isTopic": true, "_maximumDuration": duration } ] diff --git a/java/perftests/etc/testdefs/Topic-Persistence.js b/java/perftests/etc/testdefs/Topic-Persistence.js index bbec7ab8ed..96872b6c55 100644 --- a/java/perftests/etc/testdefs/Topic-Persistence.js +++ b/java/perftests/etc/testdefs/Topic-Persistence.js @@ -26,8 +26,9 @@ var jsonObject = { { "_name": "Topic persistence", "_iterations": [ - // note that we use _durableSubscription (the JaveBeans property name) - // rather than _isDurableSubscription (the field name) + // Note that we use _durableSubscription (more like the JavaBeans property name) + // rather than _isDurableSubscription (the field name, which we use elsewhere). + // This convention is required within the _iterations definition. { "_deliveryMode": 1, "_durableSubscription": false @@ -47,10 +48,12 @@ var jsonObject = { "_sessions": [ { "_sessionName": "session1", + "_acknowledgeMode": 0, "_producers": [ { "_name": "Producer", "_destinationName": topicName, + "_isTopic": true, "_maximumDuration": duration, "_startDelay": 2000 // gives the consumers time to implicitly create the topic } @@ -71,6 +74,7 @@ var jsonObject = { "_sessions": [ { "_sessionName": "session1", + "_acknowledgeMode": 0, "_consumers": [ { "_name": "Consumer-__INDEX", diff --git a/java/perftests/etc/testdefs/VaryingNumberOfParticipants.json b/java/perftests/etc/testdefs/VaryingNumberOfParticipants.json index 457b0bc348..03dd2848b6 100644 --- a/java/perftests/etc/testdefs/VaryingNumberOfParticipants.json +++ b/java/perftests/etc/testdefs/VaryingNumberOfParticipants.json @@ -8,6 +8,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -18,7 +26,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -42,7 +49,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -65,6 +71,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -75,7 +89,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -99,7 +112,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -116,7 +128,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -139,6 +150,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -149,7 +168,6 @@ "_sessions": [ { "_sessionName": "session0", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -173,7 +191,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -190,7 +207,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -207,7 +223,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -224,7 +239,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -241,7 +255,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -267,6 +280,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -277,7 +298,6 @@ "_sessions": [ { "_sessionName": "session0", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -301,7 +321,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -318,7 +337,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -335,7 +353,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -352,7 +369,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -369,7 +385,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -386,7 +401,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer6", @@ -403,7 +417,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer7", @@ -420,7 +433,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer8", @@ -437,7 +449,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer9", @@ -454,7 +465,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer10", @@ -480,6 +490,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -490,7 +508,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -509,7 +526,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -533,7 +549,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -560,6 +575,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -570,7 +593,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -589,7 +611,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -613,7 +634,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -630,7 +650,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -657,6 +676,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -667,7 +694,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -686,7 +712,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -710,7 +735,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -727,7 +751,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -744,7 +767,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -761,7 +783,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -778,7 +799,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -804,6 +824,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -814,7 +842,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -833,7 +860,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -857,7 +883,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -874,7 +899,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -891,7 +915,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -908,7 +931,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -925,7 +947,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -942,7 +963,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer6", @@ -959,7 +979,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer7", @@ -976,7 +995,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer8", @@ -993,7 +1011,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer9", @@ -1010,7 +1027,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer10", @@ -1036,6 +1052,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -1046,7 +1070,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -1065,7 +1088,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -1084,7 +1106,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -1103,7 +1124,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -1122,7 +1142,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -1146,7 +1165,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -1173,6 +1191,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -1183,7 +1209,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -1202,7 +1227,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -1221,7 +1245,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -1240,7 +1263,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -1259,7 +1281,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -1283,7 +1304,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -1300,7 +1320,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -1328,6 +1347,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -1338,7 +1365,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -1357,7 +1383,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -1376,7 +1401,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -1395,7 +1419,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -1414,7 +1437,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -1438,7 +1460,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -1455,7 +1476,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -1472,7 +1492,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -1489,7 +1508,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -1506,7 +1524,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -1532,6 +1549,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -1542,7 +1567,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -1561,7 +1585,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -1580,7 +1603,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -1599,7 +1621,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -1618,7 +1639,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -1642,7 +1662,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -1659,7 +1678,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -1676,7 +1694,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -1693,7 +1710,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -1710,7 +1726,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -1727,7 +1742,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer6", @@ -1744,7 +1758,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer7", @@ -1761,7 +1774,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer8", @@ -1778,7 +1790,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer9", @@ -1795,7 +1806,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer10", @@ -1822,6 +1832,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -1832,7 +1850,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -1851,7 +1868,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -1870,7 +1886,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -1889,7 +1904,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -1908,7 +1922,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -1927,7 +1940,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer6", @@ -1946,7 +1958,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer7", @@ -1965,7 +1976,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer8", @@ -1984,7 +1994,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer9", @@ -2003,7 +2012,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer10", @@ -2027,7 +2035,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -2054,6 +2061,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -2064,7 +2079,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -2083,7 +2097,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -2102,7 +2115,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -2121,7 +2133,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -2140,7 +2151,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -2159,7 +2169,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer6", @@ -2178,7 +2187,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer7", @@ -2197,7 +2205,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer8", @@ -2216,7 +2223,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer9", @@ -2235,7 +2241,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer10", @@ -2259,7 +2264,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -2276,7 +2280,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -2304,6 +2307,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -2314,7 +2325,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -2333,7 +2343,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -2352,7 +2361,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -2371,7 +2379,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -2390,7 +2397,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -2409,7 +2415,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer6", @@ -2428,7 +2433,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer7", @@ -2447,7 +2451,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer8", @@ -2466,7 +2469,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer9", @@ -2485,7 +2487,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer10", @@ -2509,7 +2510,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -2526,7 +2526,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -2543,7 +2542,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -2560,7 +2558,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -2577,7 +2574,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -2604,6 +2600,14 @@ "_durable": true } ], + "_iterations":[ + { + "_acknowledgeMode": 0 + }, + { + "_acknowledgeMode": 1 + } + ], "_clients":[ { "_name": "producingClient", @@ -2614,7 +2618,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer1", @@ -2633,7 +2636,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer2", @@ -2652,7 +2654,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer3", @@ -2671,7 +2672,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer4", @@ -2690,7 +2690,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer5", @@ -2709,7 +2708,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer6", @@ -2728,7 +2726,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer7", @@ -2747,7 +2744,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer8", @@ -2766,7 +2762,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer9", @@ -2785,7 +2780,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_producers": [ { "_name": "Producer10", @@ -2809,7 +2803,6 @@ "_sessions": [ { "_sessionName": "session1", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer1", @@ -2826,7 +2819,6 @@ "_sessions": [ { "_sessionName": "session2", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer2", @@ -2843,7 +2835,6 @@ "_sessions": [ { "_sessionName": "session3", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer3", @@ -2860,7 +2851,6 @@ "_sessions": [ { "_sessionName": "session4", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer4", @@ -2877,7 +2867,6 @@ "_sessions": [ { "_sessionName": "session5", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer5", @@ -2894,7 +2883,6 @@ "_sessions": [ { "_sessionName": "session6", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer6", @@ -2911,7 +2899,6 @@ "_sessions": [ { "_sessionName": "session7", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer7", @@ -2928,7 +2915,6 @@ "_sessions": [ { "_sessionName": "session8", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer8", @@ -2945,7 +2931,6 @@ "_sessions": [ { "_sessionName": "session9", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer9", @@ -2962,7 +2947,6 @@ "_sessions": [ { "_sessionName": "session10", - "_acknowledgeMode": 1, "_consumers": [ { "_name": "Consumer10", diff --git a/java/perftests/etc/testdefs/VaryingNumberOfProducerSessionsSingleConnection.js b/java/perftests/etc/testdefs/VaryingNumberOfProducerSessionsSingleConnection.js new file mode 100644 index 0000000000..c62a8344b1 --- /dev/null +++ b/java/perftests/etc/testdefs/VaryingNumberOfProducerSessionsSingleConnection.js @@ -0,0 +1,95 @@ +/* + * + * 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. + * + */ +var jsonObject = { + _tests:[] +}; + +var duration = 30000; +var queueName = "direct://amq.direct//varNumOfSessions?durable='true'"; + +var numbersOfSessions = [1, 2, 5, 10, 20, 40, 80]; +var numberOfConsumingClients = 20; + +for(i=0; i < numbersOfSessions.length ; i++) +{ + var sessionNumber = numbersOfSessions[i]; + var test = { + "_name": sessionNumber, + "_queues":[ + { + "_name": queueName, + "_durable": "true" + } + ], + "_clients":[ + { + "_name": "producingClient", + "_connections":[ + { + "_name": "connection1", + "_factory": "connectionfactory", + "_sessions": QPID.times(sessionNumber, + { + "_sessionName": "session__SESSION_INDEX", + "_producers": [ + { + "_name": "Producer__SESSION_INDEX", + "_destinationName": queueName, + "_deliveryMode": 2, + "_acknowledgeMode": 0, + "_maximumDuration": duration + } + ] + }, + "__SESSION_INDEX") + } + ] + }, + ].concat(QPID.times(numberOfConsumingClients, + { + "_name": "consumingClient__CONSUMING_CLIENT_INDEX", + "_connections":[ + { + "_name": "client__CONSUMING_CLIENT_INDEXconnection1", + "_factory": "connectionfactory", + "_sessions": + [ + { + "_sessionName": "client__CONSUMING_CLIENT_INDEXsession1", + "_consumers": [ + { + "_name": "client__CONSUMING_CLIENT_INDEXConsumer1Session1", + "_destinationName": queueName, + "_acknowledgeMode": 1, + "_maximumDuration": duration + } + ] + } + ] + } + ] + }, + "__CONSUMING_CLIENT_INDEX")) + }; + + jsonObject._tests= jsonObject._tests.concat(test); +} + diff --git a/java/perftests/etc/visualisation-timeseries.sh b/java/perftests/etc/visualisation-timeseries.sh new file mode 100755 index 0000000000..32db2cb010 --- /dev/null +++ b/java/perftests/etc/visualisation-timeseries.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# 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. +# + +# Runs the visualisation tool against perftest output assumed to be in a Derby database in the current directory + +BASE_DIR=`dirname $0` + +# Uncomment to read perftest data from a Derby database +JDBC_URL=jdbcUrl=jdbc:derby:perftestResultsDb +JDBC_DRIVER=jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver + +java -cp "${BASE_DIR}:${BASE_DIR}/../../build/lib/*" \ + -Djava.awt.headless=true -Dlog4j.configuration=file:log4j.properties \ + org.apache.qpid.disttest.charting.ChartingUtil \ + chart-defs=chartdefs/timeseries \ + ${JDBC_DRIVER} ${JDBC_URL} diff --git a/java/perftests/etc/visualisation.sh b/java/perftests/etc/visualisation.sh new file mode 100755 index 0000000000..53a3f94f9c --- /dev/null +++ b/java/perftests/etc/visualisation.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# 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. +# + +# Runs the visualisation tool against perftest CSV output assumed to be in the current directory + +BASE_DIR=`dirname $0` + +# Uncomment to read perftest data from a Derby database +# JDBC_URL=jdbcUrl=jdbc:derby:perftestResultsDb +# JDBC_DRIVER=jdbcDriverClass=org.apache.derby.jdbc.EmbeddedDriver + +java -cp "${BASE_DIR}:${BASE_DIR}/../../build/lib/*" \ + -Djava.awt.headless=true -Dlog4j.configuration=file:log4j.properties \ + -DcsvCurrentDir=. \ + -DcsvBaselineDir=. \ + org.apache.qpid.disttest.charting.ChartingUtil \ + chart-defs=chartdefs \ + ${JDBC_DRIVER} ${JDBC_URL} diff --git a/java/perftests/example/brokerconfig/log4j.xml b/java/perftests/example/brokerconfig/log4j.xml index 7dbb1bc87d..7e53d2667b 100644 --- a/java/perftests/example/brokerconfig/log4j.xml +++ b/java/perftests/example/brokerconfig/log4j.xml @@ -68,7 +68,7 @@ <param name="backupFilesToPath" value="${QPID_WORK}/backup/log"/> <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%d %-5p [%t] (%F:%L) - %m%n"/> + <param name="ConversionPattern" value="%d %-5p [%t] (%c{2}) - %m%n"/> </layout> </appender> diff --git a/java/perftests/example/perftests-jndi.properties b/java/perftests/example/perftests-jndi.properties index 04a8ad9101..1c0fd57663 100644 --- a/java/perftests/example/perftests-jndi.properties +++ b/java/perftests/example/perftests-jndi.properties @@ -24,3 +24,6 @@ java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextF connectionfactory.connectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672' destination.controllerqueue = direct://amq.direct//controllerqueue?autodelete='true' + +driverName=org.apache.derby.jdbc.EmbeddedDriver +jdbcUrl=jdbc:derby:/tmp/perftestResultsDb;create=true diff --git a/java/perftests/example/run.sh b/java/perftests/example/run.sh index cb68c52853..31124a060a 100755 --- a/java/perftests/example/run.sh +++ b/java/perftests/example/run.sh @@ -18,5 +18,5 @@ # under the License. # -java -cp ".:${QPID_HOME}/lib/*" -Dqpid.dest_syntax=BURL org.apache.qpid.disttest.ControllerRunner jndi-config=perftests-jndi.properties test-config=$1 distributed=false +java -cp ".:${QPID_HOME}/lib/*" -Dqpid.dest_syntax=BURL org.apache.qpid.disttest.ControllerRunner jndi-config=perftests-jndi.properties test-config=$1 distributed=false writeToDb=true diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java index 8c1f8675e3..e962bfe799 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ArgumentParser.java @@ -34,10 +34,14 @@ public class ArgumentParser throw new IllegalArgumentException("arguments must have format <name>=<value>: " + arg); } - if(initialValues.put(splitArg[0], splitArg[1]) == null) + + String argumentKey = splitArg[0]; + String argumentValue = splitArg[1]; + if(!initialValues.containsKey(argumentKey)) { throw new IllegalArgumentException("not a valid configuration property: " + arg); } + initialValues.put(argumentKey, argumentValue); } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java index fb4c1b700b..ee374e180d 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ConfigFileHelper.java @@ -60,15 +60,4 @@ public class ConfigFileHelper return testConfigFile; } - - /** - * generateOutputCsvNameFrom("/config/testConfigFile.js", "/output") returns /output/testConfigFile.csv - */ - public String generateOutputCsvNameFrom(String testConfigFile, String outputDir) - { - final String filenameOnlyWithExtension = new File(testConfigFile).getName(); - final String cvsFile = filenameOnlyWithExtension.replaceFirst(".?\\w*$", ".csv"); - - return new File(outputDir, cvsFile).getAbsolutePath(); - } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java index aea0ea301a..449130a328 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ControllerRunner.java @@ -19,9 +19,9 @@ */ package org.apache.qpid.disttest; +import java.io.File; import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; +import java.util.ArrayList; import java.util.List; import javax.naming.Context; @@ -30,9 +30,9 @@ import org.apache.qpid.disttest.controller.Controller; import org.apache.qpid.disttest.controller.ResultsForAllTests; import org.apache.qpid.disttest.controller.config.Config; import org.apache.qpid.disttest.controller.config.ConfigReader; +import org.apache.qpid.disttest.db.ResultsDbWriter; import org.apache.qpid.disttest.jms.ControllerJmsDelegate; import org.apache.qpid.disttest.results.aggregation.Aggregator; -import org.apache.qpid.disttest.results.formatting.CSVFormater; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,20 +43,29 @@ public class ControllerRunner extends AbstractRunner public static final String TEST_CONFIG_PROP = "test-config"; public static final String DISTRIBUTED_PROP = "distributed"; public static final String OUTPUT_DIR_PROP = "outputdir"; + public static final String WRITE_TO_DB = "writeToDb"; + public static final String RUN_ID = "runId"; private static final String TEST_CONFIG_DEFAULT = "perftests-config.json"; private static final String DISTRIBUTED_DEFAULT = "false"; private static final String OUTPUT_DIR_DEFAULT = "."; + public static final String WRITE_TO_DB_DEFAULT = "false"; private final Aggregator _aggregator = new Aggregator(); private final ConfigFileHelper _configFileHelper = new ConfigFileHelper(); + private ResultsFileWriter _resultsFileWriter; + + private ResultsDbWriter _resultsDbWriter; + public ControllerRunner() { getCliOptions().put(TEST_CONFIG_PROP, TEST_CONFIG_DEFAULT); getCliOptions().put(DISTRIBUTED_PROP, DISTRIBUTED_DEFAULT); getCliOptions().put(OUTPUT_DIR_PROP, OUTPUT_DIR_DEFAULT); + getCliOptions().put(WRITE_TO_DB, WRITE_TO_DB_DEFAULT); + getCliOptions().put(RUN_ID, null); } public static void main(String[] args) throws Exception @@ -69,6 +78,8 @@ public class ControllerRunner extends AbstractRunner public void runController() throws Exception { Context context = getContext(); + setUpResultFilesWriter(); + setUpResultsDbWriter(); ControllerJmsDelegate jmsDelegate = new ControllerJmsDelegate(context); @@ -82,6 +93,24 @@ public class ControllerRunner extends AbstractRunner } } + private void setUpResultsDbWriter() + { + String writeToDbStr = getCliOptions().get(WRITE_TO_DB); + if(Boolean.valueOf(writeToDbStr)) + { + String runId = getCliOptions().get(RUN_ID); + _resultsDbWriter = new ResultsDbWriter(getContext(), runId); + _resultsDbWriter.createResultsTableIfNecessary(); + } + } + + void setUpResultFilesWriter() + { + String outputDirString = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP); + File outputDir = new File(outputDirString); + _resultsFileWriter = new ResultsFileWriter(outputDir); + } + private void runTests(ControllerJmsDelegate jmsDelegate) { Controller controller = new Controller(jmsDelegate, DistributedTestConstants.REGISTRATION_TIMEOUT, DistributedTestConstants.COMMAND_RESPONSE_TIMEOUT); @@ -92,6 +121,8 @@ public class ControllerRunner extends AbstractRunner try { + List<ResultsForAllTests> results = new ArrayList<ResultsForAllTests>(); + for (String testConfigFile : testConfigFiles) { final Config testConfig = buildTestConfigFrom(testConfigFile); @@ -100,8 +131,11 @@ public class ControllerRunner extends AbstractRunner controller.awaitClientRegistrations(); LOGGER.info("Running test : " + testConfigFile); - runTest(controller, testConfigFile); + ResultsForAllTests testResult = runTest(controller, testConfigFile); + results.add(testResult); } + + _resultsFileWriter.writeResultsSummary(results); } catch(Exception e) { @@ -113,7 +147,7 @@ public class ControllerRunner extends AbstractRunner } } - private void runTest(Controller controller, String testConfigFile) + private ResultsForAllTests runTest(Controller controller, String testConfigFile) { final Config testConfig = buildTestConfigFrom(testConfigFile); controller.setConfig(testConfig); @@ -121,9 +155,13 @@ public class ControllerRunner extends AbstractRunner ResultsForAllTests rawResultsForAllTests = controller.runAllTests(); ResultsForAllTests resultsForAllTests = _aggregator.aggregateResults(rawResultsForAllTests); - String outputDir = getCliOptions().get(ControllerRunner.OUTPUT_DIR_PROP); - final String outputFile = _configFileHelper.generateOutputCsvNameFrom(testConfigFile, outputDir); - writeResultsToFile(resultsForAllTests, outputFile); + _resultsFileWriter.writeResultsToFile(resultsForAllTests, testConfigFile); + if(_resultsDbWriter != null) + { + _resultsDbWriter.writeResults(resultsForAllTests); + } + + return resultsForAllTests; } private void createClientsIfNotDistributed(final List<String> testConfigFiles) @@ -148,36 +186,6 @@ public class ControllerRunner extends AbstractRunner } } - private void writeResultsToFile(ResultsForAllTests resultsForAllTests, String outputFile) - { - FileWriter writer = null; - try - { - final String outputCsv = new CSVFormater().format(resultsForAllTests); - writer = new FileWriter(outputFile); - writer.write(outputCsv); - LOGGER.info("Wrote " + resultsForAllTests.getTestResults().size() + " test result(s) to output file " + outputFile); - } - catch (IOException e) - { - throw new DistributedTestException("Unable to write output file " + outputFile, e); - } - finally - { - if (writer != null) - { - try - { - writer.close(); - } - catch (IOException e) - { - LOGGER.error("Failed to close stream for file " + outputFile, e); - } - } - } - } - private Config buildTestConfigFrom(String testConfigFile) { ConfigReader configReader = new ConfigReader(); diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java b/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java new file mode 100644 index 0000000000..81b717403d --- /dev/null +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/ResultsFileWriter.java @@ -0,0 +1,112 @@ +/* + * 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.disttest; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; + +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; +import org.apache.qpid.disttest.results.formatting.CSVFormatter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ResultsFileWriter +{ + private static final Logger LOGGER = LoggerFactory.getLogger(ResultsFileWriter.class); + + static final String TEST_SUMMARY_FILE_NAME = "test-summary.csv"; + + private final File _outputDir; + + private CSVFormatter _csvFormater = new CSVFormatter(); + + private TestResultAggregator _testResultAggregator = new TestResultAggregator(); + + public ResultsFileWriter(File outputDir) + { + _outputDir = outputDir; + } + + public void writeResultsToFile(ResultsForAllTests resultsForAllTests, String testConfigFile) + { + final String outputFile = generateOutputCsvNameFrom(testConfigFile); + writeResultsToOutputFile(resultsForAllTests, outputFile); + } + + public void writeResultsSummary(List<ResultsForAllTests> allResultsList) + { + ResultsForAllTests combinedResults = _testResultAggregator.aggregateTestResults(allResultsList); + writeResultsToOutputFile(combinedResults, new File(_outputDir, TEST_SUMMARY_FILE_NAME).getAbsolutePath()); + } + + /** + * generateOutputCsvNameFrom("/config/testConfigFile.js", "/output") returns /output/testConfigFile.csv + */ + private String generateOutputCsvNameFrom(String testConfigFile) + { + final String filenameOnlyWithExtension = new File(testConfigFile).getName(); + final String cvsFile = filenameOnlyWithExtension.replaceFirst(".?\\w*$", ".csv"); + + return new File(_outputDir, cvsFile).getAbsolutePath(); + } + + private void writeResultsToOutputFile(ResultsForAllTests resultsForAllTests, String outputFile) + { + FileWriter writer = null; + try + { + final String outputCsv = _csvFormater.format(resultsForAllTests); + writer = new FileWriter(outputFile); + writer.write(outputCsv); + LOGGER.info("Wrote " + resultsForAllTests.getTestResults().size() + " test result(s) to output file " + outputFile); + } + catch (IOException e) + { + throw new DistributedTestException("Unable to write output file " + outputFile, e); + } + finally + { + if (writer != null) + { + try + { + writer.close(); + } + catch (IOException e) + { + LOGGER.error("Failed to close stream for file " + outputFile, e); + } + } + } + } + + void setCsvFormater(CSVFormatter csvFormater) + { + _csvFormater = csvFormater; + } + + void setTestResultAggregator(TestResultAggregator testResultAggregator) + { + _testResultAggregator = testResultAggregator; + } + +} diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java index f9d50e8e64..d3a5e30191 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ConsumerParticipant.java @@ -35,7 +35,6 @@ import javax.jms.MessageListener; import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.jms.ClientJmsDelegate; -import org.apache.qpid.disttest.message.ConsumerParticipantResult; import org.apache.qpid.disttest.message.CreateConsumerCommand; import org.apache.qpid.disttest.message.ParticipantResult; import org.slf4j.Logger; @@ -103,16 +102,22 @@ public class ConsumerParticipant implements Participant } Date end = new Date(); - int numberOfMessagesSent = _totalNumberOfMessagesReceived.get(); + int numberOfMessagesReceived = _totalNumberOfMessagesReceived.get(); long totalPayloadSize = _totalPayloadSizeOfAllMessagesReceived.get(); int payloadSize = getPayloadSizeForResultIfConstantOrZeroOtherwise(_allConsumedPayloadSizes); - ConsumerParticipantResult result = _resultFactory.createForConsumer( + if (LOGGER.isInfoEnabled()) + { + LOGGER.info("Consumer {} finished consuming. Number of messages consumed: {}", + getName(), numberOfMessagesReceived); + } + + ParticipantResult result = _resultFactory.createForConsumer( getName(), registeredClientName, _command, acknowledgeMode, - numberOfMessagesSent, + numberOfMessagesReceived, payloadSize, totalPayloadSize, start, end, _messageLatencies); @@ -174,7 +179,7 @@ public class ConsumerParticipant implements Participant { LOGGER.trace("Committing: batch size " + _command.getBatchSize() ); } - _jmsDelegate.commitOrAcknowledgeMessage(message, _command.getSessionName()); + _jmsDelegate.commitOrAcknowledgeMessageIfNecessary(_command.getSessionName(), message); } } @@ -199,7 +204,7 @@ public class ConsumerParticipant implements Participant } // commit/acknowledge remaining messages if necessary - _jmsDelegate.commitOrAcknowledgeMessage(message, _command.getSessionName()); + _jmsDelegate.commitOrAcknowledgeMessageIfNecessary(_command.getSessionName(), message); } return false; } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java index bb9ce26f7e..10f62708a4 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ParticipantExecutor.java @@ -108,8 +108,16 @@ public class ParticipantExecutor } finally { + try + { + _participant.releaseResources(); + } + catch(Exception e) + { + LOGGER.error("Participant " + _participant + " unable to release resources", e); + } + _client.sendResults(result); - _participant.releaseResources(); } } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java index 63cbe98b5c..a9da837dea 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/client/ProducerParticipant.java @@ -58,17 +58,25 @@ public class ProducerParticipant implements Participant @Override public ParticipantResult doIt(String registeredClientName) throws Exception { - if (_command.getMaximumDuration() == 0 && _command.getNumberOfMessages() == 0) + long numberOfMessages = _command.getNumberOfMessages(); + long maximumDuration = _command.getMaximumDuration(); + + if (maximumDuration == 0 && numberOfMessages == 0) { throw new DistributedTestException("number of messages and duration cannot both be zero"); } - int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName()); + long duration = maximumDuration - _command.getStartDelay(); + if (maximumDuration > 0 && duration <= 0) + { + throw new DistributedTestException("Start delay must be less than maximum test duration"); + } + final long requiredDuration = duration > 0 ? duration : 0; doSleepForStartDelay(); - final long requiredDuration = _command.getMaximumDuration() - _command.getStartDelay(); - + final int batchSize = _command.getBatchSize(); + final int acknowledgeMode = _jmsDelegate.getAcknowledgeMode(_command.getSessionName()); final long startTime = System.currentTimeMillis(); Message lastPublishedMessage = null; @@ -78,10 +86,20 @@ public class ProducerParticipant implements Participant _limiter = ExecutorWithLimitsFactory.createExecutorWithLimit(startTime, requiredDuration); - LOGGER.info("Producer {} about to send messages", getName()); + if (LOGGER.isInfoEnabled()) + { + LOGGER.info("Producer {} about to send messages. Duration limit: {} ms, Message limit: {}", + new Object[]{getName(), requiredDuration, numberOfMessages}); + } while (true) { + if (numberOfMessages > 0 && numberOfMessagesSent >= numberOfMessages + || requiredDuration > 0 && System.currentTimeMillis() - startTime >= requiredDuration) + { + break; + } + try { lastPublishedMessage = _limiter.execute(new Callable<Message>() @@ -110,35 +128,35 @@ public class ProducerParticipant implements Participant LOGGER.trace("message " + numberOfMessagesSent + " sent by " + this); } - final boolean batchLimitReached = _command.getBatchSize() <= 0 - || numberOfMessagesSent % _command.getBatchSize() == 0; + final boolean batchLimitReached = batchSize <= 0 + || numberOfMessagesSent % batchSize == 0; if (batchLimitReached) { - if (LOGGER.isTraceEnabled() && _command.getBatchSize() > 0) + if (LOGGER.isTraceEnabled() && batchSize > 0) { - LOGGER.trace("Committing: batch size " + _command.getBatchSize() ); + LOGGER.trace("Committing: batch size " + batchSize ); } - _jmsDelegate.commitOrAcknowledgeMessage(lastPublishedMessage, _command.getSessionName()); + _jmsDelegate.commitIfNecessary(_command.getSessionName()); doSleepForInterval(); } - - if (_command.getNumberOfMessages() > 0 && numberOfMessagesSent >= _command.getNumberOfMessages() - || requiredDuration > 0 && System.currentTimeMillis() - startTime >= requiredDuration) - { - break; - } } // commit the remaining batch messages - if (_command.getBatchSize() > 0 && numberOfMessagesSent % _command.getBatchSize() != 0) + if (batchSize > 0 && numberOfMessagesSent % batchSize != 0) { if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Committing: batch size " + _command.getBatchSize() ); + LOGGER.trace("Committing: batch size " + batchSize ); } - _jmsDelegate.commitOrAcknowledgeMessage(lastPublishedMessage, _command.getSessionName()); + _jmsDelegate.commitIfNecessary(_command.getSessionName()); + } + + if (LOGGER.isInfoEnabled()) + { + LOGGER.info("Producer {} finished publishing. Number of messages published: {}", + getName(), numberOfMessagesSent); } Date start = new Date(startTime); diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java index eaccb54f0e..5a726c50b4 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ClientRegistry.java @@ -57,34 +57,54 @@ public class ClientRegistry return Collections.unmodifiableSet(_registeredClientNames); } - public int awaitClients(int numberOfClientsToAwait, long timeout) + /** + * @return the number of clients that are still absent. + */ + public int awaitClients(final int numberOfClientsToAwait, final long idleTimeout) { - final long endTime = System.currentTimeMillis() + timeout; + long deadlineForNextRegistration = deadline(idleTimeout); - int numberOfClientsAbsent = numberOfClientsToAwait - _registeredClientNames.size(); - long remainingTimeout = endTime - System.currentTimeMillis(); + int numberOfClientsAbsent = numberAbsent(numberOfClientsToAwait); - while(numberOfClientsAbsent > 0 && remainingTimeout > 0) + while(numberOfClientsAbsent > 0 && System.currentTimeMillis() < deadlineForNextRegistration) { synchronized (_lock) { try { - _lock.wait(remainingTimeout); + _lock.wait(idleTimeout); } catch (InterruptedException e) { Thread.currentThread().interrupt(); + return numberOfClientsAbsent; } } - numberOfClientsAbsent = numberOfClientsToAwait - _registeredClientNames.size(); - remainingTimeout = endTime - System.currentTimeMillis(); + int newNumberAbsent = numberAbsent(numberOfClientsToAwait); + if(newNumberAbsent < numberOfClientsAbsent) + { + // a registration was received since the last loop, so reset the timeout + deadlineForNextRegistration = deadline(idleTimeout); + } + + numberOfClientsAbsent = newNumberAbsent; } return numberOfClientsAbsent < 0 ? 0 : numberOfClientsAbsent; } + + private long deadline(final long idleTimeout) + { + return System.currentTimeMillis() + idleTimeout; + } + + private int numberAbsent(int numberOfClientsToAwait) + { + return numberOfClientsToAwait - _registeredClientNames.size(); + } + private void notifyAllWaiters() { synchronized (_lock) diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java index 6c5ff3450c..d4474e2c12 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/ResultsForAllTests.java @@ -21,7 +21,9 @@ package org.apache.qpid.disttest.controller; import java.util.ArrayList; import java.util.List; +import org.apache.qpid.disttest.message.ParticipantResult; import org.apache.qpid.disttest.results.aggregation.ITestResult; +import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; public class ResultsForAllTests { @@ -46,4 +48,23 @@ public class ResultsForAllTests { return _hasErrors; } + + public ResultsForAllTests getAllParticipantsResult() + { + ResultsForAllTests summaryResultsForAllTests = new ResultsForAllTests(); + + for (ITestResult testResult : _results) + { + for(ParticipantResult participantResult : testResult.getParticipantResults()) + { + if(TestResultAggregator.ALL_CONSUMER_PARTICIPANTS_NAME.equals(participantResult.getParticipantName())) + { + TestResult summaryTestResult = new TestResult(testResult.getName()); + summaryTestResult.addParticipantResult(participantResult); + summaryResultsForAllTests.add(summaryTestResult); + } + } + } + return summaryResultsForAllTests; + } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java index 110de8a4ea..dcccccdd5f 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ConsumerConfig.java @@ -24,7 +24,6 @@ import org.apache.qpid.disttest.message.CreateConsumerCommand; public class ConsumerConfig extends ParticipantConfig { - private boolean _isTopic; private boolean _isDurableSubscription; private boolean _isBrowsingSubscription; private String _selector; @@ -35,7 +34,6 @@ public class ConsumerConfig extends ParticipantConfig // For Gson public ConsumerConfig() { - _isTopic = false; _isDurableSubscription = false; _isBrowsingSubscription = false; _selector = null; @@ -56,9 +54,8 @@ public class ConsumerConfig extends ParticipantConfig boolean noLocal, boolean synchronous) { - super(consumerName, destinationName, numberOfMessages, batchSize, maximumDuration); + super(consumerName, destinationName, isTopic, numberOfMessages, batchSize, maximumDuration); - _isTopic = isTopic; _isDurableSubscription = isDurableSubscription; _isBrowsingSubscription = isBrowsingSubscription; _selector = selector; @@ -73,7 +70,6 @@ public class ConsumerConfig extends ParticipantConfig setParticipantProperties(createConsumerCommand); createConsumerCommand.setSessionName(sessionName); - createConsumerCommand.setTopic(_isTopic); createConsumerCommand.setDurableSubscription(_isDurableSubscription); createConsumerCommand.setBrowsingSubscription(_isBrowsingSubscription); createConsumerCommand.setSelector(_selector); diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java index 16f7b0d18d..99ae4b7426 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ParticipantConfig.java @@ -33,6 +33,7 @@ public abstract class ParticipantConfig private boolean _alreadyLoggedAboutOverriddenDuration; private String _destinationName; + private boolean _isTopic; private long _numberOfMessages; private String _name; private int _batchSize; @@ -51,12 +52,14 @@ public abstract class ParticipantConfig public ParticipantConfig( String name, String destinationName, + boolean isTopic, long numberOfMessages, int batchSize, long maximumDuration) { _name = name; _destinationName = destinationName; + _isTopic = isTopic; _numberOfMessages = numberOfMessages; _batchSize = batchSize; _maximumDuration = maximumDuration; @@ -66,6 +69,7 @@ public abstract class ParticipantConfig { createParticipantCommand.setParticipantName(_name); createParticipantCommand.setDestinationName(_destinationName); + createParticipantCommand.setTopic(_isTopic); createParticipantCommand.setNumberOfMessages(_numberOfMessages); createParticipantCommand.setBatchSize(_batchSize); diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java index f2369ed671..88c188d3ac 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/controller/config/ProducerConfig.java @@ -59,7 +59,7 @@ public class ProducerConfig extends ParticipantConfig long startDelay, String messageProviderName) { - super(producerName, destinationName, numberOfMessages, batchSize, maximumDuration); + super(producerName, destinationName, false, numberOfMessages, batchSize, maximumDuration); _deliveryMode = deliveryMode; _messageSize = messageSize; diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java b/java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java new file mode 100644 index 0000000000..fdea03ae5e --- /dev/null +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/db/ResultsDbWriter.java @@ -0,0 +1,467 @@ +/* + * 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.disttest.db; + +import static org.apache.qpid.disttest.message.ParticipantAttribute.ACKNOWLEDGE_MODE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.AVERAGE_LATENCY; +import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.DELIVERY_MODE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.ERROR_MESSAGE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_BROWSING_SUBSCRIPTION; +import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_DURABLE_SUBSCRIPTION; +import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_NO_LOCAL; +import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SELECTOR; +import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SYNCHRONOUS_CONSUMER; +import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_TOPIC; +import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER; +import static org.apache.qpid.disttest.message.ParticipantAttribute.LATENCY_STANDARD_DEVIATION; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MAX_LATENCY; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MIN_LATENCY; +import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PRIORITY; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_INTERVAL; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_START_DELAY; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TAKEN; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TO_LIVE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_CONSUMERS; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_PRODUCERS; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_PAYLOAD_PROCESSED; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; +import java.util.Hashtable; +import java.util.TimeZone; + +import javax.naming.Context; +import javax.naming.NamingException; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.log4j.Logger; +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.disttest.results.aggregation.ITestResult; + +/** + * Intended call sequence: + * <ul> + * <li>{@link #ResultsDbWriter(Context, String)}</li> + * <li>{@link #createResultsTableIfNecessary()}</li> + * <li>{@link #writeResults(ResultsForAllTests)} (usually multiple times)</li> + * </ul> + */ +public class ResultsDbWriter +{ + private static final Logger _logger = Logger.getLogger(ResultsDbWriter.class); + + private static final String RESULTS_TABLE_NAME = "RESULTS"; + + /** column name */ + static final String INSERTED_TIMESTAMP = "insertedTimestamp"; + /** column name */ + static final String RUN_ID = "runId"; + + private static final String TABLE_EXISTENCE_QUERY = "SELECT 1 FROM SYS.SYSTABLES WHERE TABLENAME = ?"; + + private static final String CREATE_RESULTS_TABLE = String.format( + "CREATE TABLE %1$s (" + + "%2$s varchar(200) not null" + // TEST_NAME + ", %3$s bigint not null" + // ITERATION_NUMBER + ", %4$s varchar(200) not null" + // PARTICIPANT_NAME + ", %5$s double not null" + // THROUGHPUT + ", %6$s double" + // AVERAGE_LATENCY + ", %7$s varchar(200)" + // CONFIGURED_CLIENT_NAME + ", %8$s bigint" + // NUMBER_OF_MESSAGES_PROCESSED + ", %9$s bigint" + // PAYLOAD_SIZE + ", %10$s bigint" + // PRIORITY + ", %11$s bigint" + // TIME_TO_LIVE + ", %12$s bigint" + // ACKNOWLEDGE_MODE + ", %13$s bigint" + // DELIVERY_MODE + ", %14$s bigint" + // BATCH_SIZE + ", %15$s bigint" + // MAXIMUM_DURATION + ", %16$s bigint" + // PRODUCER_START_DELAY + ", %17$s bigint" + // PRODUCER_INTERVAL + ", %18$s bigint" + // IS_TOPIC + ", %19$s bigint" + // IS_DURABLE_SUBSCRIPTION + ", %20$s bigint" + // IS_BROWSING_SUBSCRIPTION + ", %21$s bigint" + // IS_SELECTOR + ", %22$s bigint" + // IS_NO_LOCAL + ", %23$s bigint" + // IS_SYNCHRONOUS_CONSUMER + ", %24$s bigint" + // TOTAL_NUMBER_OF_CONSUMERS + ", %25$s bigint" + // TOTAL_NUMBER_OF_PRODUCERS + ", %26$s bigint" + // TOTAL_PAYLOAD_PROCESSED + ", %27$s bigint" + // TIME_TAKEN + ", %28$s varchar(2000)" + // ERROR_MESSAGE + ", %29$s bigint" + // MIN_LATENCY + ", %30$s bigint" + // MAX_LATENCY + ", %31$s double" + // LATENCY_STANDARD_DEVIATION + ", %32$s varchar(200) not null" + + ", %33$s timestamp not null" + + ")", + RESULTS_TABLE_NAME, + TEST_NAME.getDisplayName(), + ITERATION_NUMBER.getDisplayName(), + PARTICIPANT_NAME.getDisplayName(), + THROUGHPUT.getDisplayName(), + AVERAGE_LATENCY.getDisplayName(), + CONFIGURED_CLIENT_NAME.getDisplayName(), + NUMBER_OF_MESSAGES_PROCESSED.getDisplayName(), + PAYLOAD_SIZE.getDisplayName(), + PRIORITY.getDisplayName(), + TIME_TO_LIVE.getDisplayName(), + ACKNOWLEDGE_MODE.getDisplayName(), + DELIVERY_MODE.getDisplayName(), + BATCH_SIZE.getDisplayName(), + MAXIMUM_DURATION.getDisplayName(), + PRODUCER_START_DELAY.getDisplayName(), + PRODUCER_INTERVAL.getDisplayName(), + IS_TOPIC.getDisplayName(), + IS_DURABLE_SUBSCRIPTION.getDisplayName(), + IS_BROWSING_SUBSCRIPTION.getDisplayName(), + IS_SELECTOR.getDisplayName(), + IS_NO_LOCAL.getDisplayName(), + IS_SYNCHRONOUS_CONSUMER.getDisplayName(), + TOTAL_NUMBER_OF_CONSUMERS.getDisplayName(), + TOTAL_NUMBER_OF_PRODUCERS.getDisplayName(), + TOTAL_PAYLOAD_PROCESSED.getDisplayName(), + TIME_TAKEN.getDisplayName(), + ERROR_MESSAGE.getDisplayName(), + MIN_LATENCY.getDisplayName(), + MAX_LATENCY.getDisplayName(), + LATENCY_STANDARD_DEVIATION.getDisplayName(), + RUN_ID, + INSERTED_TIMESTAMP + ); + + public static final String DRIVER_NAME = "jdbcDriverClass"; + public static final String URL = "jdbcUrl"; + + private final String _url; + private final String _runId; + + private final Clock _clock; + + /** + * @param runId may be null, in which case a default value is chosen based on current GMT time + * @param context must contain environment entries {@value #DRIVER_NAME} and {@value #URL}. + */ + public ResultsDbWriter(Context context, String runId) + { + this(context, runId, new Clock()); + } + + /** only call directly from tests */ + ResultsDbWriter(Context context, String runId, Clock clock) + { + _clock = clock; + _runId = defaultIfNullRunId(runId); + + _url = initialiseJdbc(context); + } + + private String defaultIfNullRunId(String runId) + { + if(runId == null) + { + Date dateNow = new Date(_clock.currentTimeMillis()); + Calendar calNow = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); + calNow.setTime(dateNow); + return String.format("run %1$tF %1$tT.%tL", calNow); + } + else + { + return runId; + } + } + + public String getRunId() + { + return _runId; + } + + /** + * Uses the context's environment to load the JDBC driver class and return the + * JDBC URL specified therein. + * @return the JDBC URL + */ + private String initialiseJdbc(Context context) + { + Hashtable<?, ?> environment = null; + try + { + environment = context.getEnvironment(); + + String driverName = (String) environment.get(DRIVER_NAME); + if(driverName == null) + { + throw new IllegalArgumentException("JDBC driver name " + DRIVER_NAME + + " missing from context environment: " + environment); + } + + Class.forName(driverName); + + Object url = environment.get(URL); + if(url == null) + { + throw new IllegalArgumentException("JDBC URL " + URL + " missing from context environment: " + environment); + } + return (String) url; + } + catch (NamingException e) + { + throw constructorRethrow(e, environment); + } + catch (ClassNotFoundException e) + { + throw constructorRethrow(e, environment); + } + } + + private RuntimeException constructorRethrow(Exception e, Hashtable<?, ?> environment) + { + return new RuntimeException("Couldn't initialise ResultsDbWriter from context with environment" + environment, e); + } + + public void createResultsTableIfNecessary() + { + try + { + Connection connection = null; + try + { + connection = DriverManager.getConnection(_url); + if(!tableExists(RESULTS_TABLE_NAME, connection)) + { + Statement statement = connection.createStatement(); + try + { + _logger.info("About to create results table using SQL: " + CREATE_RESULTS_TABLE); + statement.execute(CREATE_RESULTS_TABLE); + } + finally + { + statement.close(); + } + } + } + finally + { + if(connection != null) + { + connection.close(); + } + } + } + catch (SQLException e) + { + throw new RuntimeException("Couldn't create results table", e); + } + + } + + private boolean tableExists(final String tableName, final Connection conn) throws SQLException + { + PreparedStatement stmt = conn.prepareStatement(TABLE_EXISTENCE_QUERY); + try + { + stmt.setString(1, tableName); + ResultSet rs = stmt.executeQuery(); + try + { + return rs.next(); + } + finally + { + rs.close(); + } + } + finally + { + stmt.close(); + } + } + + public void writeResults(ResultsForAllTests results) + { + try + { + writeResultsThrowingException(results); + } + catch (SQLException e) + { + throw new RuntimeException("Couldn't write results " + results, e); + } + _logger.info(this + " wrote " + results.getTestResults().size() + " results to database"); + } + + private void writeResultsThrowingException(ResultsForAllTests results) throws SQLException + { + Connection connection = null; + try + { + connection = DriverManager.getConnection(_url); + + for (ITestResult testResult : results.getTestResults()) + { + for (ParticipantResult participantResult : testResult.getParticipantResults()) + { + writeParticipantResult(connection, participantResult); + } + } + } + finally + { + if(connection != null) + { + connection.close(); + } + } + } + + private void writeParticipantResult(Connection connection, ParticipantResult participantResult) throws SQLException + { + if(_logger.isDebugEnabled()) + { + _logger.debug("About to write to DB the following participant result: " + participantResult); + } + + PreparedStatement statement = null; + try + { + String sqlTemplate = String.format( + "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) " + + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + RESULTS_TABLE_NAME, + TEST_NAME.getDisplayName(), + ITERATION_NUMBER.getDisplayName(), + PARTICIPANT_NAME.getDisplayName(), + THROUGHPUT.getDisplayName(), + AVERAGE_LATENCY.getDisplayName(), + CONFIGURED_CLIENT_NAME.getDisplayName(), + NUMBER_OF_MESSAGES_PROCESSED.getDisplayName(), + PAYLOAD_SIZE.getDisplayName(), + PRIORITY.getDisplayName(), + TIME_TO_LIVE.getDisplayName(), + ACKNOWLEDGE_MODE.getDisplayName(), + DELIVERY_MODE.getDisplayName(), + BATCH_SIZE.getDisplayName(), + MAXIMUM_DURATION.getDisplayName(), + PRODUCER_START_DELAY.getDisplayName(), + PRODUCER_INTERVAL.getDisplayName(), + IS_TOPIC.getDisplayName(), + IS_DURABLE_SUBSCRIPTION.getDisplayName(), + IS_BROWSING_SUBSCRIPTION.getDisplayName(), + IS_SELECTOR.getDisplayName(), + IS_NO_LOCAL.getDisplayName(), + IS_SYNCHRONOUS_CONSUMER.getDisplayName(), + TOTAL_NUMBER_OF_CONSUMERS.getDisplayName(), + TOTAL_NUMBER_OF_PRODUCERS.getDisplayName(), + TOTAL_PAYLOAD_PROCESSED.getDisplayName(), + TIME_TAKEN.getDisplayName(), + ERROR_MESSAGE.getDisplayName(), + MIN_LATENCY.getDisplayName(), + MAX_LATENCY.getDisplayName(), + LATENCY_STANDARD_DEVIATION.getDisplayName(), + RUN_ID, + INSERTED_TIMESTAMP + ); + statement = connection.prepareStatement(sqlTemplate); + + int columnIndex = 1; + statement.setString(columnIndex++, participantResult.getTestName()); + statement.setInt(columnIndex++, participantResult.getIterationNumber()); + statement.setString(columnIndex++, participantResult.getParticipantName()); + statement.setDouble(columnIndex++, participantResult.getThroughput()); + statement.setDouble(columnIndex++, participantResult.getAverageLatency()); + statement.setString(columnIndex++, participantResult.getConfiguredClientName()); + statement.setLong(columnIndex++, participantResult.getNumberOfMessagesProcessed()); + statement.setLong(columnIndex++, participantResult.getPayloadSize()); + statement.setLong(columnIndex++, participantResult.getPriority()); + statement.setLong(columnIndex++, participantResult.getTimeToLive()); + statement.setLong(columnIndex++, participantResult.getAcknowledgeMode()); + statement.setLong(columnIndex++, participantResult.getDeliveryMode()); + statement.setLong(columnIndex++, participantResult.getBatchSize()); + statement.setLong(columnIndex++, participantResult.getMaximumDuration()); + statement.setLong(columnIndex++, 0 /* TODO PRODUCER_START_DELAY*/); + statement.setLong(columnIndex++, 0 /* TODO PRODUCER_INTERVAL*/); + statement.setLong(columnIndex++, 0 /* TODO IS_TOPIC*/); + statement.setLong(columnIndex++, 0 /* TODO IS_DURABLE_SUBSCRIPTION*/); + statement.setLong(columnIndex++, 0 /* TODO IS_BROWSING_SUBSCRIPTION*/); + statement.setLong(columnIndex++, 0 /* TODO IS_SELECTOR*/); + statement.setLong(columnIndex++, 0 /* TODO IS_NO_LOCAL*/); + statement.setLong(columnIndex++, 0 /* TODO IS_SYNCHRONOUS_CONSUMER*/); + statement.setLong(columnIndex++, participantResult.getTotalNumberOfConsumers()); + statement.setLong(columnIndex++, participantResult.getTotalNumberOfProducers()); + statement.setLong(columnIndex++, participantResult.getTotalPayloadProcessed()); + statement.setLong(columnIndex++, participantResult.getTimeTaken()); + statement.setString(columnIndex++, participantResult.getErrorMessage()); + statement.setLong(columnIndex++, participantResult.getMinLatency()); + statement.setLong(columnIndex++, participantResult.getMaxLatency()); + statement.setDouble(columnIndex++, participantResult.getLatencyStandardDeviation()); + + statement.setString(columnIndex++, _runId); + statement.setTimestamp(columnIndex++, new Timestamp(_clock.currentTimeMillis())); + + statement.execute(); + connection.commit(); + } + catch(SQLException e) + { + _logger.error("Couldn't write " + participantResult, e); + } + finally + { + if (statement != null) + { + statement.close(); + } + } + } + + public static class Clock + { + public long currentTimeMillis() + { + return System.currentTimeMillis(); + } + } + + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("runId", _runId) + .append("url", _url) + .toString(); + } +} diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java index 3f8afc9a9a..f242111dc5 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ClientJmsDelegate.java @@ -218,7 +218,15 @@ public class ClientJmsDelegate synchronized(session) { - final Destination destination = session.createQueue(command.getDestinationName()); + final Destination destination; + if(command.isTopic()) + { + destination = session.createTopic(command.getDestinationName()); + } + else + { + destination = session.createQueue(command.getDestinationName()); + } final MessageProducer jmsProducer = session.createProducer(destination); @@ -373,30 +381,6 @@ public class ClientJmsDelegate } } - public void commitOrAcknowledgeMessage(final Message message, final String sessionName) - { - try - { - final Session session = _testSessions.get(sessionName); - if (session.getTransacted()) - { - synchronized(session) - { - session.commit(); - } - } - else if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) - { - message.acknowledge(); - } - } - catch (final JMSException jmse) - { - throw new DistributedTestException("Unable to commit or acknowledge message on session: " + - sessionName, jmse); - } - } - public int getAcknowledgeMode(final String sessionName) { try @@ -493,31 +477,36 @@ public class ClientJmsDelegate } } - public void rollbackOrRecover(String sessionName) + public void commitOrAcknowledgeMessageIfNecessary(final String sessionName, final Message message) { try { final Session session = _testSessions.get(sessionName); - synchronized(session) + if (session.getTransacted()) { - if (session.getTransacted()) - { - session.rollback(); - } - else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) + synchronized(session) { - session.recover(); + session.commit(); } } + else if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) + { + message.acknowledge(); + } } catch (final JMSException jmse) { - throw new DistributedTestException("Unable to rollback or recover on session: " + + throw new DistributedTestException("Unable to commit or acknowledge message on session: " + sessionName, jmse); } } - public void releaseMessage(String sessionName) + public void commitIfNecessary(final String sessionName) + { + commitOrAcknowledgeMessageIfNecessary(sessionName, null); + } + + public void rollbackOrRecoverIfNecessary(String sessionName) { try { @@ -528,7 +517,7 @@ public class ClientJmsDelegate { session.rollback(); } - else + else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { session.recover(); } @@ -536,7 +525,8 @@ public class ClientJmsDelegate } catch (final JMSException jmse) { - LOGGER.warn("Unable to rollback or recover on session: " + sessionName, jmse); + throw new DistributedTestException("Unable to rollback or recover on session: " + + sessionName, jmse); } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java index c80e641e5c..782f7ae2fd 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/ControllerJmsDelegate.java @@ -224,12 +224,12 @@ public class ControllerJmsDelegate public void createQueues(List<QueueConfig> queues) { - _queueCreator.createQueues(_session, queues); + _queueCreator.createQueues(_connection, _session, queues); } public void deleteQueues(List<QueueConfig> queues) { - _queueCreator.deleteQueues(_session, queues); + _queueCreator.deleteQueues(_connection, _session, queues); } public void addCommandListener(CommandListener commandListener) diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java index 4d4850eccf..d7e0007b28 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/NoOpQueueCreator.java @@ -20,18 +20,19 @@ package org.apache.qpid.disttest.jms; import java.util.List; +import javax.jms.Connection; import javax.jms.Session; import org.apache.qpid.disttest.controller.config.QueueConfig; public class NoOpQueueCreator implements QueueCreator { @Override - public void createQueues(Session session, List<QueueConfig> configs) + public void createQueues(Connection connection, Session session, List<QueueConfig> configs) { } @Override - public void deleteQueues(Session session, List<QueueConfig> configs) + public void deleteQueues(Connection connection, Session session, List<QueueConfig> configs) { } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java index 6874abe7d4..ef2cfb6cd4 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QpidQueueCreator.java @@ -20,21 +20,29 @@ package org.apache.qpid.disttest.jms; import java.util.List; +import javax.jms.Connection; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; import javax.jms.Session; + import org.apache.qpid.client.AMQDestination; import org.apache.qpid.client.AMQSession; import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.controller.config.QueueConfig; +import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.FieldTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + public class QpidQueueCreator implements QueueCreator { private static final Logger LOGGER = LoggerFactory.getLogger(QpidQueueCreator.class); private static final FieldTable EMPTY_QUEUE_BIND_ARGUMENTS = new FieldTable(); + private static final String QUEUE_CREATOR_DRAIN_POLL_TIMEOUT = "qpid.disttest.queue.creator.drainPollTime"; + private static int _drainPollTimeout = Integer.getInteger(QUEUE_CREATOR_DRAIN_POLL_TIMEOUT, 500); @Override - public void createQueues(Session session, List<QueueConfig> configs) + public void createQueues(Connection connection, Session session, List<QueueConfig> configs) { AMQSession<?, ?> amqSession = (AMQSession<?, ?>)session; for (QueueConfig queueConfig : configs) @@ -44,12 +52,88 @@ public class QpidQueueCreator implements QueueCreator } @Override - public void deleteQueues(Session session, List<QueueConfig> configs) + public void deleteQueues(Connection connection, Session session, List<QueueConfig> configs) { AMQSession<?, ?> amqSession = (AMQSession<?, ?>)session; for (QueueConfig queueConfig : configs) { - deleteQueue(amqSession, queueConfig); + AMQDestination destination = createAMQDestination(amqSession, queueConfig); + + // drainQueue method is added because deletion of queue with a lot + // of messages takes time and might cause the timeout exception + drainQueue(connection, destination); + + deleteQueue(amqSession, destination.getAMQQueueName()); + } + } + + private AMQDestination createAMQDestination(AMQSession<?, ?> amqSession, QueueConfig queueConfig) + { + try + { + return (AMQDestination) amqSession.createQueue(queueConfig.getName()); + } + catch (Exception e) + { + throw new DistributedTestException("Failed to create amq destionation object:" + queueConfig, e); + } + } + + private long getQueueDepth(AMQSession<?, ?> amqSession, AMQDestination destination) + { + try + { + long queueDepth = amqSession.getQueueDepth(destination); + return queueDepth; + } + catch (Exception e) + { + throw new DistributedTestException("Failed to query queue depth:" + destination, e); + } + } + + private void drainQueue(Connection connection, AMQDestination destination) + { + Session noAckSession = null; + try + { + LOGGER.debug("About to drain the queue {}", destination.getQueueName()); + noAckSession = connection.createSession(false, org.apache.qpid.jms.Session.NO_ACKNOWLEDGE); + MessageConsumer messageConsumer = noAckSession.createConsumer(destination); + + long currentQueueDepth = getQueueDepth((AMQSession<?,?>)noAckSession, destination); + int counter = 0; + while (currentQueueDepth > 0) + { + LOGGER.info("Queue {} has {} message(s)", destination.getQueueName(), currentQueueDepth); + + while(messageConsumer.receive(_drainPollTimeout) != null) + { + counter++; + } + + currentQueueDepth = getQueueDepth((AMQSession<?,?>)noAckSession, destination); + } + LOGGER.info("Drained {} message(s) from queue {} ", counter, destination.getQueueName()); + messageConsumer.close(); + } + catch (Exception e) + { + throw new DistributedTestException("Failed to drain queue:" + destination, e); + } + finally + { + if (noAckSession != null) + { + try + { + noAckSession.close(); + } + catch (JMSException e) + { + throw new DistributedTestException("Failed to close n/a session:" + noAckSession, e); + } + } } } @@ -66,7 +150,7 @@ public class QpidQueueCreator implements QueueCreator EMPTY_QUEUE_BIND_ARGUMENTS, destination.getExchangeName(), destination, autoDelete); - LOGGER.debug("Created queue " + queueConfig); + LOGGER.debug("Created queue {}", queueConfig); } catch (Exception e) { @@ -74,20 +158,19 @@ public class QpidQueueCreator implements QueueCreator } } - private void deleteQueue(AMQSession<?, ?> session, QueueConfig queueConfig) + private void deleteQueue(AMQSession<?, ?> session, AMQShortString queueName) { try { // The Qpid AMQSession API currently makes the #deleteQueue method protected and the // raw protocol method public. This should be changed then we should switch the below to // use #deleteQueue. - AMQDestination destination = (AMQDestination) session.createQueue(queueConfig.getName()); - session.sendQueueDelete(destination.getAMQQueueName()); - LOGGER.debug("Deleted queue " + queueConfig.getName()); + session.sendQueueDelete(queueName); + LOGGER.debug("Deleted queue {}", queueName); } catch (Exception e) { - throw new DistributedTestException("Failed to delete queue:" + queueConfig.getName(), e); + throw new DistributedTestException("Failed to delete queue:" + queueName, e); } } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java index 0947dd53cb..a37cd7888c 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/jms/QueueCreator.java @@ -20,12 +20,13 @@ package org.apache.qpid.disttest.jms; import java.util.List; +import javax.jms.Connection; import javax.jms.Session; import org.apache.qpid.disttest.controller.config.QueueConfig; public interface QueueCreator { - public void createQueues(final Session session, final List<QueueConfig> configs); - public void deleteQueues(final Session session, final List<QueueConfig> configs); + void createQueues(Connection connection, Session session, List<QueueConfig> configs); + void deleteQueues(Connection connection, Session session, List<QueueConfig> configs); } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java index ad9aa31472..e78f6965d2 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ConsumerParticipantResult.java @@ -134,6 +134,7 @@ public class ConsumerParticipantResult extends ParticipantResult _messageLatencies = messageLatencies; } + @Override @OutputAttribute(attribute=ParticipantAttribute.MIN_LATENCY) public long getMinLatency() { @@ -145,6 +146,7 @@ public class ConsumerParticipantResult extends ParticipantResult _minLatency = minLatency; } + @Override @OutputAttribute(attribute=ParticipantAttribute.MAX_LATENCY) public long getMaxLatency() { @@ -156,6 +158,7 @@ public class ConsumerParticipantResult extends ParticipantResult _maxLatency = maxLatency; } + @Override @OutputAttribute(attribute=ParticipantAttribute.AVERAGE_LATENCY) public double getAverageLatency() { @@ -167,6 +170,7 @@ public class ConsumerParticipantResult extends ParticipantResult _averageLatency = averageLatency; } + @Override @OutputAttribute(attribute=ParticipantAttribute.LATENCY_STANDARD_DEVIATION) public double getLatencyStandardDeviation() { diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java index 68c21fbf83..07a60504c8 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateConsumerCommand.java @@ -21,7 +21,6 @@ package org.apache.qpid.disttest.message; public class CreateConsumerCommand extends CreateParticpantCommand { - private boolean _isTopic; private boolean _isDurableSubscription; private boolean _isBrowsingSubscription; private String _selector; @@ -75,16 +74,6 @@ public class CreateConsumerCommand extends CreateParticpantCommand this._noLocal = noLocal; } - public boolean isTopic() - { - return _isTopic; - } - - public void setTopic(boolean isTopic) - { - this._isTopic = isTopic; - } - public boolean isSynchronous() { return _synchronous; diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java index b1caa6ef75..e7349bf795 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/CreateParticpantCommand.java @@ -23,6 +23,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; public abstract class CreateParticpantCommand extends Command { + private boolean _isTopic; private String _participantName; private String _sessionName; private String _destinationName; @@ -65,6 +66,16 @@ public abstract class CreateParticpantCommand extends Command _destinationName = destinationName; } + public boolean isTopic() + { + return _isTopic; + } + + public void setTopic(boolean isTopic) + { + _isTopic = isTopic; + } + public long getNumberOfMessages() { return _numberOfMessages; diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java index 0418562a2d..1154ff306c 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantAttribute.java @@ -18,6 +18,8 @@ */ package org.apache.qpid.disttest.message; +import java.text.DecimalFormat; + import org.apache.qpid.disttest.client.Participant; /** @@ -31,6 +33,8 @@ public enum ParticipantAttribute { TEST_NAME("testName"), ITERATION_NUMBER("iterationNumber"), + THROUGHPUT("throughputKbPerS", "#"), + AVERAGE_LATENCY("averageLatency", "#"), CONFIGURED_CLIENT_NAME("clientName"), PARTICIPANT_NAME("participantName"), NUMBER_OF_MESSAGES_PROCESSED("numberOfMessages"), @@ -52,24 +56,56 @@ public enum ParticipantAttribute TOTAL_NUMBER_OF_CONSUMERS("totalNumberOfConsumers"), TOTAL_NUMBER_OF_PRODUCERS("totalNumberOfProducers"), TOTAL_PAYLOAD_PROCESSED("totalPayloadProcessedB"), - THROUGHPUT("throughputKbPerS"), TIME_TAKEN("timeTakenMs"), ERROR_MESSAGE("errorMessage"), MIN_LATENCY("minLatency"), MAX_LATENCY("maxLatency"), - AVERAGE_LATENCY("averageLatency"), - LATENCY_STANDARD_DEVIATION("latencyStandardDeviation") + LATENCY_STANDARD_DEVIATION("latencyStandardDeviation"), + MESSAGE_THROUGHPUT("throughputMessagesPerS") ; private String _displayName; + private String _decimalFormat; ParticipantAttribute(String displayName) { _displayName = displayName; } + ParticipantAttribute(String displayName, String decimalFormat) + { + _displayName = displayName; + _decimalFormat = decimalFormat; + } + + public String getDecimalFormat() + { + return _decimalFormat; + } + public String getDisplayName() { return _displayName; } + + public String format(Object attributeValue) + { + if(attributeValue == null) + { + return null; + } + + String attributeAsString = String.valueOf(attributeValue); + + if(_decimalFormat != null) + { + DecimalFormat decimalFormat = new DecimalFormat(_decimalFormat); + double attributeAsDoule = Double.valueOf(attributeAsString); + return decimalFormat.format(attributeAsDoule); + } + else + { + return attributeAsString; + } + } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java index a6d3d91bae..0a824a316b 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java @@ -22,11 +22,12 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE; import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME; import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER; import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION; -import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MESSAGE_THROUGHPUT; import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED; -import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT; import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE; import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT; import java.util.Comparator; import java.util.Date; @@ -49,6 +50,7 @@ public class ParticipantResult extends Response private long _totalPayloadProcessed; private int _payloadSize; private double _throughput; + private int _messageThroughput; private int _totalNumberOfConsumers; private int _totalNumberOfProducers; @@ -236,6 +238,17 @@ public class ParticipantResult extends Response _throughput = throughput; } + @OutputAttribute(attribute=MESSAGE_THROUGHPUT) + public int getMessageThroughput() + { + return _messageThroughput; + } + + public void setMessageThroughput(int throughput) + { + _messageThroughput = throughput; + } + public void setTotalNumberOfConsumers(int totalNumberOfConsumers) { _totalNumberOfConsumers = totalNumberOfConsumers; @@ -269,4 +282,41 @@ public class ParticipantResult extends Response _acknowledgeMode = acknowledgeMode; } + public double getLatencyStandardDeviation() + { + return 0.0; + } + + @OutputAttribute(attribute = ParticipantAttribute.MIN_LATENCY) + public long getMinLatency() + { + return 0; + } + + @OutputAttribute(attribute = ParticipantAttribute.MAX_LATENCY) + public long getMaxLatency() + { + return 0; + } + + @OutputAttribute(attribute = ParticipantAttribute.AVERAGE_LATENCY) + public double getAverageLatency() + { + return 0; + } + + public int getPriority() + { + return 0; + } + + public long getTimeToLive() + { + return 0; + } + + public int getDeliveryMode() + { + return 0; + } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java index 766c90eec8..2d9399a3d3 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/message/ProducerParticipantResult.java @@ -42,6 +42,7 @@ public class ProducerParticipantResult extends ParticipantResult setParticipantName(participantName); } + @Override @OutputAttribute(attribute=PRIORITY) public int getPriority() { @@ -53,6 +54,7 @@ public class ProducerParticipantResult extends ParticipantResult _priority = priority; } + @Override @OutputAttribute(attribute=TIME_TO_LIVE) public long getTimeToLive() { @@ -86,6 +88,7 @@ public class ProducerParticipantResult extends ParticipantResult _interval = producerInterval; } + @Override @OutputAttribute(attribute=DELIVERY_MODE) public int getDeliveryMode() { @@ -96,5 +99,4 @@ public class ProducerParticipantResult extends ParticipantResult { this._deliveryMode = deliveryMode; } - } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java index 3f9cdff69d..6230067486 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ITestResult.java @@ -22,10 +22,8 @@ import java.util.List; import org.apache.qpid.disttest.message.ParticipantResult; -// TODO rename me!! public interface ITestResult { - // TODO should weaken to Collection List<ParticipantResult> getParticipantResults(); diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java index 4dcabe6c7b..c21a78d359 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregator.java @@ -142,6 +142,7 @@ public class ParticipantResultAggregator aggregatedResult.setStartDate(new Date(_minStartDate)); aggregatedResult.setEndDate(new Date(_maxEndDate)); aggregatedResult.setThroughput(calculateThroughputInKiloBytesPerSecond()); + aggregatedResult.setMessageThroughput(calculateThroughputInMessagesPerSecond()); } private void setRolledUpConstantAttributes(ParticipantResult aggregatedResult) @@ -197,4 +198,14 @@ public class ParticipantResultAggregator return totalPayloadProcessedInKiloBytes/durationInSeconds; } + private int calculateThroughputInMessagesPerSecond() + { + double durationInMillis = _maxEndDate - _minStartDate; + if (durationInMillis == 0 ) + { + return 0; + } + + return (int)Math.round((_numberOfMessagesProcessed * 1000.0d)/durationInMillis); + } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java index 5934e0e997..954828b043 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregator.java @@ -18,6 +18,9 @@ */ package org.apache.qpid.disttest.results.aggregation; +import java.util.List; + +import org.apache.qpid.disttest.controller.ResultsForAllTests; import org.apache.qpid.disttest.message.ConsumerParticipantResult; import org.apache.qpid.disttest.message.ParticipantResult; import org.apache.qpid.disttest.message.ProducerParticipantResult; @@ -102,5 +105,26 @@ public class TestResultAggregator aggregatedAllResult.setNumberOfMessagesProcessed(aggregatedConsumerResult.getNumberOfMessagesProcessed()); aggregatedAllResult.setTotalPayloadProcessed(aggregatedConsumerResult.getTotalPayloadProcessed()); aggregatedAllResult.setThroughput(aggregatedConsumerResult.getThroughput()); + aggregatedAllResult.setMessageThroughput(aggregatedConsumerResult.getMessageThroughput()); + } + + /** + * Produces a single {@link ResultsForAllTests} from the supplied list, only containing + * the "All participants" results. + */ + public ResultsForAllTests aggregateTestResults(List<ResultsForAllTests> allResultsList) + { + ResultsForAllTests retVal = new ResultsForAllTests(); + + for (ResultsForAllTests resultsForAllTests : allResultsList) + { + ResultsForAllTests allParticipantsResult = resultsForAllTests.getAllParticipantsResult(); + for (ITestResult testResult : allParticipantsResult.getTestResults()) + { + retVal.add(testResult); + } + } + + return retVal; } } diff --git a/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java b/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java index 52e53ca624..ea7a3f78c7 100644 --- a/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormater.java +++ b/java/perftests/src/main/java/org/apache/qpid/disttest/results/formatting/CSVFormatter.java @@ -32,7 +32,7 @@ import org.apache.qpid.disttest.results.aggregation.ITestResult; /** * produces CSV output using the ordered enums in {@link ParticipantAttribute} */ -public class CSVFormater +public class CSVFormatter { public String format(ResultsForAllTests results) { @@ -66,7 +66,9 @@ public class CSVFormater List<Object> attributeValues = new ArrayList<Object>(); for (ParticipantAttribute attribute : ParticipantAttribute.values()) { - attributeValues.add(attributeValueMap.get(attribute)); + Object attributeValue = attributeValueMap.get(attribute); + String attributeValueFormatted = attribute.format(attributeValue); + attributeValues.add(attributeValueFormatted); } String row = StringUtils.join(attributeValues.toArray(), ","); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java index a10b3b359e..629442d86c 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ConfigFileHelperTest.java @@ -39,14 +39,6 @@ public class ConfigFileHelperTest extends QpidTestCase _testDir = TestFileUtils.createTestDirectory(); } - public void testGenerateOutputCsvNameFrom() - { - String outputDir = "/tmp/outputDir"; - - assertEquals("/tmp/outputDir/my.json.file.csv", _configFileHelper.generateOutputCsvNameFrom("/tmp/my.json.file.json", outputDir)); - assertEquals("/tmp/outputDir/my.js.file.csv", _configFileHelper.generateOutputCsvNameFrom("/tmp/my.js.file.js", outputDir)); - } - public void testGetTestConfigFilesForDirectory() throws Exception { String jsFile = createFile("file1.js"); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java new file mode 100644 index 0000000000..ab55e8003d --- /dev/null +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/ResultsFileWriterTest.java @@ -0,0 +1,85 @@ +/* + * 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.disttest; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.Arrays; + +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.results.aggregation.TestResultAggregator; +import org.apache.qpid.disttest.results.formatting.CSVFormatter; +import org.apache.qpid.test.utils.QpidTestCase; +import org.apache.qpid.test.utils.TestFileUtils; +import org.apache.qpid.util.FileUtils; + +public class ResultsFileWriterTest extends QpidTestCase +{ + private CSVFormatter _csvFormater = mock(CSVFormatter.class); + private TestResultAggregator _testResultAggregator = mock(TestResultAggregator.class); + + private File _outputDir = TestFileUtils.createTestDirectory(); + + private ResultsFileWriter _resultsFileWriter = new ResultsFileWriter(_outputDir); + + @Override + public void setUp() + { + _resultsFileWriter.setCsvFormater(_csvFormater); + _resultsFileWriter.setTestResultAggregator(_testResultAggregator); + } + + public void testWriteResultsToFile() + { + ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class); + + String expectedCsvContents = "expected-csv-contents"; + when(_csvFormater.format(resultsForAllTests)).thenReturn(expectedCsvContents); + + _resultsFileWriter.writeResultsToFile(resultsForAllTests, "config.json"); + + File resultsFile = new File(_outputDir, "config.csv"); + + assertEquals(expectedCsvContents, FileUtils.readFileAsString(resultsFile)); + } + + public void testWriteResultsSummary() + { + ResultsForAllTests results1 = mock(ResultsForAllTests.class); + ResultsForAllTests results2 = mock(ResultsForAllTests.class); + ResultsForAllTests summaryResults = mock(ResultsForAllTests.class); + + when(_testResultAggregator.aggregateTestResults(Arrays.asList(results1, results2))) + .thenReturn(summaryResults); + + String expectedSummaryFileContents = "expected-summary-file"; + + when(_csvFormater.format(summaryResults)) + .thenReturn(expectedSummaryFileContents); + + _resultsFileWriter.writeResultsSummary(Arrays.asList(results1, results2)); + + File summaryFile = new File(_outputDir, ResultsFileWriter.TEST_SUMMARY_FILE_NAME); + + assertEquals(expectedSummaryFileContents, FileUtils.readFileAsString(summaryFile)); + } + +} diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java index 320e7d8c9d..09f7da4efb 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/VisitorTest.java @@ -19,12 +19,11 @@ */ package org.apache.qpid.disttest; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.Command; +import org.apache.qpid.test.utils.QpidTestCase; -public class VisitorTest extends TestCase +public class VisitorTest extends QpidTestCase { public void testStringVisited() throws Exception diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java index 4a82f6719f..2b29471558 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientCommandVisitorTest.java @@ -21,7 +21,6 @@ package org.apache.qpid.disttest.client; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import junit.framework.TestCase; import org.apache.qpid.disttest.jms.ClientJmsDelegate; import org.apache.qpid.disttest.message.CreateConnectionCommand; @@ -32,8 +31,9 @@ import org.apache.qpid.disttest.message.CreateSessionCommand; import org.apache.qpid.disttest.message.StartTestCommand; import org.apache.qpid.disttest.message.StopClientCommand; import org.apache.qpid.disttest.message.TearDownTestCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class ClientCommandVisitorTest extends TestCase +public class ClientCommandVisitorTest extends QpidTestCase { private Client _client; private ClientCommandVisitor _visitor; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java index dd50766918..8139961fa4 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ClientTest.java @@ -29,17 +29,16 @@ import java.util.Collections; import java.util.Timer; import java.util.TimerTask; -import junit.framework.TestCase; - import org.apache.qpid.disttest.jms.ClientJmsDelegate; import org.apache.qpid.disttest.message.Command; import org.apache.qpid.disttest.message.ParticipantResult; import org.apache.qpid.disttest.message.Response; import org.apache.qpid.disttest.message.StopClientCommand; +import org.apache.qpid.test.utils.QpidTestCase; import org.mockito.InOrder; import org.mockito.Mockito; -public class ClientTest extends TestCase +public class ClientTest extends QpidTestCase { private Client _client; private ClientJmsDelegate _delegate; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java index 58589d36f4..f75415a2bf 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ConsumerParticipantTest.java @@ -34,16 +34,15 @@ import java.util.Collection; import javax.jms.Message; import javax.jms.Session; -import junit.framework.TestCase; - import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.jms.ClientJmsDelegate; import org.apache.qpid.disttest.message.ConsumerParticipantResult; import org.apache.qpid.disttest.message.CreateConsumerCommand; import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.test.utils.QpidTestCase; import org.mockito.InOrder; -public class ConsumerParticipantTest extends TestCase +public class ConsumerParticipantTest extends QpidTestCase { private static final String SESSION_NAME1 = "SESSION1"; private static final String PARTICIPANT_NAME1 = "PARTICIPANT_NAME1"; @@ -114,7 +113,7 @@ public class ConsumerParticipantTest extends TestCase _inOrder.verify(_delegate).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT); _inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage); - _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + _inOrder.verify(_delegate).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage); } public void testReceiveMessagesForDurationSynch() throws Exception @@ -129,7 +128,7 @@ public class ConsumerParticipantTest extends TestCase verify(_delegate, atLeastOnce()).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT); verify(_delegate, atLeastOnce()).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, atLeastOnce()).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, atLeastOnce()).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage); } public void testReceiveMessagesBatchedSynch() throws Exception @@ -147,7 +146,7 @@ public class ConsumerParticipantTest extends TestCase verify(_delegate, times(numberOfMessages)).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT); verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, times(4)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, times(4)).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage); } public void testReceiveMessagesWithVaryingPayloadSize() throws Exception @@ -171,7 +170,7 @@ public class ConsumerParticipantTest extends TestCase verify(_delegate, times(numberOfMessages)).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT); verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, times(numberOfMessages)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, times(numberOfMessages)).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage); } public void testReleaseResources() @@ -194,7 +193,7 @@ public class ConsumerParticipantTest extends TestCase _inOrder.verify(_delegate).consumeMessage(PARTICIPANT_NAME1, RECEIVE_TIMEOUT); _inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage); - _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + _inOrder.verify(_delegate).commitOrAcknowledgeMessageIfNecessary(SESSION_NAME1, _mockMessage); assertTrue("Unexpected consuemr results", result instanceof ConsumerParticipantResult); Collection<Long> latencies = ((ConsumerParticipantResult)result).getMessageLatencies(); assertNotNull("Message latency is not cllected", latencies); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java index 1ff8d3e5d7..8863e0f289 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/MessageProviderTest.java @@ -33,14 +33,13 @@ import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; -import junit.framework.TestCase; - import org.apache.qpid.disttest.client.property.ListPropertyValue; import org.apache.qpid.disttest.client.property.PropertyValue; import org.apache.qpid.disttest.client.property.SimplePropertyValue; import org.apache.qpid.disttest.message.CreateProducerCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class MessageProviderTest extends TestCase +public class MessageProviderTest extends QpidTestCase { private Session _session; private TextMessage _message; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java index f30e4664ff..6720047cd1 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantExecutorTest.java @@ -20,6 +20,7 @@ package org.apache.qpid.disttest.client; import static org.mockito.Matchers.argThat; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -28,14 +29,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import junit.framework.TestCase; - import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.test.utils.QpidTestCase; import org.mockito.ArgumentMatcher; import org.mockito.InOrder; -public class ParticipantExecutorTest extends TestCase +public class ParticipantExecutorTest extends QpidTestCase { private static final ResultHasError HAS_ERROR = new ResultHasError(); private static final String CLIENT_NAME = "CLIENT_NAME"; @@ -69,8 +69,8 @@ public class ParticipantExecutorTest extends TestCase InOrder inOrder = inOrder(_participant, _client); inOrder.verify(_participant).doIt(CLIENT_NAME); - inOrder.verify(_client).sendResults(_mockResult); inOrder.verify(_participant).releaseResources(); + inOrder.verify(_client).sendResults(_mockResult); } public void testParticipantThrowsException() throws Exception @@ -82,13 +82,28 @@ public class ParticipantExecutorTest extends TestCase InOrder inOrder = inOrder(_participant, _client); inOrder.verify(_participant).doIt(CLIENT_NAME); + inOrder.verify(_participant).releaseResources(); inOrder.verify(_client).sendResults(argThat(HAS_ERROR)); + } + + public void testReleaseResourcesThrowsException() throws Exception + { + when(_participant.doIt(CLIENT_NAME)).thenReturn(_mockResult); + doThrow(DistributedTestException.class).when(_participant).releaseResources(); + + _participantExecutor.start(_client); + + InOrder inOrder = inOrder(_participant, _client); + + inOrder.verify(_participant).doIt(CLIENT_NAME); inOrder.verify(_participant).releaseResources(); + + // check that sendResults is called even though releaseResources threw an exception + inOrder.verify(_client).sendResults(_mockResult); } public void testThreadNameAndDaemonness() throws Exception { - ThreadPropertyReportingParticipant participant = new ThreadPropertyReportingParticipant(PARTICIPANT_NAME); _participantExecutor = new ParticipantExecutor(participant); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java index bd0d5a39c8..5cc8d2f30a 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantRegistryTest.java @@ -20,9 +20,10 @@ package org.apache.qpid.disttest.client; import static org.mockito.Mockito.mock; -import junit.framework.TestCase; -public class ParticipantRegistryTest extends TestCase +import org.apache.qpid.test.utils.QpidTestCase; + +public class ParticipantRegistryTest extends QpidTestCase { private ParticipantExecutorRegistry _participantRegistry = new ParticipantExecutorRegistry(); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java index 3b21834a5c..9eab459443 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ParticipantResultFactoryTest.java @@ -22,16 +22,15 @@ import java.util.Date; import javax.jms.DeliveryMode; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.ConsumerParticipantResult; import org.apache.qpid.disttest.message.CreateConsumerCommand; import org.apache.qpid.disttest.message.CreateParticpantCommand; import org.apache.qpid.disttest.message.CreateProducerCommand; import org.apache.qpid.disttest.message.ParticipantResult; import org.apache.qpid.disttest.message.ProducerParticipantResult; +import org.apache.qpid.test.utils.QpidTestCase; -public class ParticipantResultFactoryTest extends TestCase +public class ParticipantResultFactoryTest extends QpidTestCase { private static final String PARTICIPANT_NAME = "participantName"; private static final String REGISTERED_CLIENT_NAME = "registeredClientName"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java index a3ac11b756..08ee8715fd 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/ProducerParticipantTest.java @@ -31,15 +31,14 @@ import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.Session; -import junit.framework.TestCase; - import org.apache.qpid.disttest.DistributedTestException; 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.test.utils.QpidTestCase; import org.mockito.InOrder; -public class ProducerParticipantTest extends TestCase +public class ProducerParticipantTest extends QpidTestCase { private ProducerParticipant _producer; @@ -127,13 +126,13 @@ public class ProducerParticipantTest extends TestCase _inOrder.verify(_delegate).sendNextMessage(isA(CreateProducerCommand.class)); _inOrder.verify(_delegate).calculatePayloadSizeFrom(_mockMessage); - _inOrder.verify(_delegate).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + _inOrder.verify(_delegate).commitIfNecessary(SESSION_NAME1); } public void testSendMessagesForDuration() throws Exception { - final long duration = 100; + final long duration = 1000; _command.setMaximumDuration(duration); ParticipantResult result = _producer.doIt(CLIENT_NAME); @@ -142,7 +141,24 @@ public class ProducerParticipantTest extends TestCase verify(_delegate, atLeastOnce()).sendNextMessage(isA(CreateProducerCommand.class)); verify(_delegate, atLeastOnce()).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, atLeastOnce()).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, atLeastOnce()).commitIfNecessary(SESSION_NAME1); + } + + public void testSendMessagesForDurationWithDelayExceedingDuration() throws Exception + { + final long duration = 100; + _command.setMaximumDuration(duration); + _command.setStartDelay(150); + + try + { + _producer.doIt(CLIENT_NAME); + fail("Exception should be thrown indicating configuration error"); + } + catch(DistributedTestException e) + { + assertEquals("Start delay must be less than maximum test duration", e.getMessage()); + } } public void testSendMessageBatches() throws Exception @@ -161,7 +177,7 @@ public class ProducerParticipantTest extends TestCase verify(_delegate, times(numberOfMessages)).sendNextMessage(isA(CreateProducerCommand.class)); verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, times(expectedNumberOfCommits)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, times(expectedNumberOfCommits)).commitIfNecessary(SESSION_NAME1); } public void testSendMessageWithPublishInterval() throws Exception @@ -183,7 +199,7 @@ public class ProducerParticipantTest extends TestCase verify(_delegate, times(numberOfMessages)).sendNextMessage(isA(CreateProducerCommand.class)); verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, times(4)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, times(4)).commitIfNecessary(SESSION_NAME1); } public void testSendMessageWithVaryingPayloadSize() throws Exception @@ -208,7 +224,7 @@ public class ProducerParticipantTest extends TestCase verify(_delegate, times(numberOfMessages)).sendNextMessage(isA(CreateProducerCommand.class)); verify(_delegate, times(numberOfMessages)).calculatePayloadSizeFrom(_mockMessage); - verify(_delegate, times(numberOfMessages)).commitOrAcknowledgeMessage(_mockMessage, SESSION_NAME1); + verify(_delegate, times(numberOfMessages)).commitIfNecessary(SESSION_NAME1); } public void testReleaseResources() diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java index c54355bc76..3172eb07ed 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/ListPropertyValueTest.java @@ -21,13 +21,9 @@ package org.apache.qpid.disttest.client.property; import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.disttest.client.property.ListPropertyValue; -import org.apache.qpid.disttest.client.property.PropertyValue; -import org.apache.qpid.disttest.client.property.SimplePropertyValue; - -public class ListPropertyValueTest extends TestCase +public class ListPropertyValueTest extends QpidTestCase { private ListPropertyValue _generator; private List<PropertyValue> _items; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java index 17397db5b8..eba1bcc435 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/PropertyValueFactoryTest.java @@ -18,9 +18,9 @@ */ package org.apache.qpid.disttest.client.property; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class PropertyValueFactoryTest extends TestCase +public class PropertyValueFactoryTest extends QpidTestCase { private PropertyValueFactory _factory; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java index 878141895c..9651dd95ce 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RandomPropertyValueTest.java @@ -18,11 +18,9 @@ */ package org.apache.qpid.disttest.client.property; -import org.apache.qpid.disttest.client.property.RandomPropertyValue; +import org.apache.qpid.test.utils.QpidTestCase; -import junit.framework.TestCase; - -public class RandomPropertyValueTest extends TestCase +public class RandomPropertyValueTest extends QpidTestCase { private RandomPropertyValue _generator; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java index 6932919bed..b0649a49ae 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/RangePropertyValueTest.java @@ -18,11 +18,9 @@ */ package org.apache.qpid.disttest.client.property; -import org.apache.qpid.disttest.client.property.RangePropertyValue; +import org.apache.qpid.test.utils.QpidTestCase; -import junit.framework.TestCase; - -public class RangePropertyValueTest extends TestCase +public class RangePropertyValueTest extends QpidTestCase { private RangePropertyValue _generator; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java index a347d866c7..f1977015fe 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/property/SimplePropertyValueTest.java @@ -18,9 +18,9 @@ */ package org.apache.qpid.disttest.client.property; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class SimplePropertyValueTest extends TestCase +public class SimplePropertyValueTest extends QpidTestCase { public void testGetValue() { diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java index 37820d2582..0880512333 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithNoLimitsTest.java @@ -25,9 +25,9 @@ import static org.mockito.Mockito.when; import java.util.concurrent.Callable; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class ExecutorWithNoLimitsTest extends TestCase +public class ExecutorWithNoLimitsTest extends QpidTestCase { private final static Object RESULT = new Object(); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java index a201a7bacf..2abdba2446 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/client/utils/ExecutorWithTimeLimitTest.java @@ -20,16 +20,16 @@ package org.apache.qpid.disttest.client.utils; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.never; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class ExecutorWithTimeLimitTest extends TestCase +public class ExecutorWithTimeLimitTest extends QpidTestCase { private static final int TIMEOUT = 500; private static final Object RESULT = new Object(); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java index cc969e1ef2..c07d9fcb81 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ClientRegistryTest.java @@ -21,14 +21,15 @@ package org.apache.qpid.disttest.controller; import java.util.Timer; import java.util.TimerTask; -import junit.framework.TestCase; - import org.apache.qpid.disttest.DistributedTestException; +import org.apache.qpid.test.utils.QpidTestCase; -public class ClientRegistryTest extends TestCase +public class ClientRegistryTest extends QpidTestCase { private static final String CLIENT1_REGISTERED_NAME = "CLIENT1_REGISTERED_NAME"; private static final String CLIENT2_REGISTERED_NAME = "CLIENT2_REGISTERED_NAME"; + private static final String CLIENT3_REGISTERED_NAME = "CLIENT3_REGISTERED_NAME"; + private static final int AWAIT_DELAY = 100; private ClientRegistry _clientRegistry = new ClientRegistry(); @@ -70,7 +71,7 @@ public class ClientRegistryTest extends TestCase assertEquals(0, numberOfClientsAbsent); } - public void testAwaitTwoClientWhenClientRegistersWhilstWaiting() + public void testAwaitTwoClientsWhenClientRegistersWhilstWaiting() { _clientRegistry.registerClient(CLIENT1_REGISTERED_NAME); registerClientLater(CLIENT2_REGISTERED_NAME, 50); @@ -79,6 +80,41 @@ public class ClientRegistryTest extends TestCase assertEquals(0, numberOfClientsAbsent); } + public void testAwaitTimeoutForPromptRegistrations() + { + registerClientsLaterAndAssertResult("Clients registering every 100ms should be within 600ms timeout", + new int[] {300, 400, 500}, + 600, + 0); + } + + public void testAwaitTimeoutForWhenThirdRegistrationIsLate() + { + registerClientsLaterAndAssertResult("Third client registering tardily should exceed timeout", + new int[] {300, 400, 1500}, + 600, + 1); + } + + public void testAwaitTimeoutWhenSecondAndThirdRegistrationsAreLate() + { + registerClientsLaterAndAssertResult("Second and third clients registering tardily should exceed timeout", + new int[] {300, 1500, 1500}, + 600, + 2); + } + + private void registerClientsLaterAndAssertResult(String message, int[] registrationDelays, int timeout, int expectedNumberOfAbsentees) + { + registerClientLater(CLIENT1_REGISTERED_NAME, registrationDelays[0]); + registerClientLater(CLIENT2_REGISTERED_NAME, registrationDelays[1]); + registerClientLater(CLIENT3_REGISTERED_NAME, registrationDelays[2]); + + int numberOfClientsAbsent = _clientRegistry.awaitClients(3, timeout); + + assertEquals(message, expectedNumberOfAbsentees, numberOfClientsAbsent); + } + private void registerClientLater(final String clientName, long delayInMillis) { doLater(new TimerTask() diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java index bc58ea41c5..f773c727a1 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ControllerTest.java @@ -19,6 +19,8 @@ */ package org.apache.qpid.disttest.controller; +import static org.apache.qpid.systest.disttest.SystemTestConstants.COMMAND_RESPONSE_TIMEOUT; +import static org.apache.qpid.systest.disttest.SystemTestConstants.REGISTRATION_TIMEOUT; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; @@ -31,8 +33,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import junit.framework.TestCase; - import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.controller.config.Config; import org.apache.qpid.disttest.controller.config.TestInstance; @@ -42,16 +42,14 @@ 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.disttest.results.aggregation.ITestResult; +import org.apache.qpid.test.utils.QpidTestCase; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -public class ControllerTest extends TestCase +public class ControllerTest extends QpidTestCase { private static final String CLIENT1_REGISTERED_NAME = "client-uid1"; - private static final long COMMAND_RESPONSE_TIMEOUT = 1000; - private static final long REGISTRATION_TIMEOUT = 1000; - private Controller _controller; private ControllerJmsDelegate _respondingJmsDelegate; private TestRunner _testRunner; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java index 284db38f44..da180f328f 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/ParticipatingClientsTest.java @@ -25,9 +25,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class ParticipatingClientsTest extends TestCase +public class ParticipatingClientsTest extends QpidTestCase { private static final String CLIENT1_CONFIGURED_NAME = "CLIENT1_CONFIGURED_NAME"; private static final String CLIENT2_CONFIGURED_NAME = "CLIENT2_CONFIGURED_NAME"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java index 983da299b9..d8b25e76fa 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/TestRunnerTest.java @@ -32,8 +32,6 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; -import junit.framework.TestCase; - import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.controller.config.QueueConfig; import org.apache.qpid.disttest.controller.config.TestInstance; @@ -45,10 +43,11 @@ import org.apache.qpid.disttest.message.ParticipantResult; 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.test.utils.QpidTestCase; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -public class TestRunnerTest extends TestCase +public class TestRunnerTest extends QpidTestCase { private static final String TEST_NAME = "TEST_NAME"; private static final String PARTICIPANT_NAME = "TEST_PARTICIPANT_NAME"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java index d4af439dea..4bf4307eaf 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ClientConfigTest.java @@ -29,16 +29,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import junit.framework.TestCase; - import org.apache.qpid.disttest.client.property.PropertyValue; import org.apache.qpid.disttest.client.property.SimplePropertyValue; import org.apache.qpid.disttest.controller.CommandForClient; import org.apache.qpid.disttest.message.Command; import org.apache.qpid.disttest.message.CreateMessageProviderCommand; import org.apache.qpid.disttest.message.NoOpCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class ClientConfigTest extends TestCase +public class ClientConfigTest extends QpidTestCase { private static final String CLIENT1 = "client1"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js index 07f8bf9d92..527300eff4 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest-test-config.js @@ -1,3 +1,23 @@ +/* + * + * 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. + * + */ jsonObject = { "_tests": QPID.iterations( { "__ACK_MODE": [ 0, 1 ] }, @@ -31,4 +51,4 @@ jsonObject = { ) }) -}
\ No newline at end of file +} diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java index 257f139849..e208945901 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java @@ -23,12 +23,12 @@ import java.io.Reader; import java.util.List; import java.util.Map; -import junit.framework.TestCase; - import org.apache.qpid.disttest.ConfigFileTestHelper; import org.apache.qpid.disttest.client.property.PropertyValue; +import org.apache.qpid.test.utils.QpidTestCase; +import org.apache.qpid.test.utils.TestFileUtils; -public class ConfigReaderTest extends TestCase +public class ConfigReaderTest extends QpidTestCase { private Config _config; @@ -111,8 +111,9 @@ public class ConfigReaderTest extends TestCase public void testReadsJS() throws Exception { ConfigReader configReader = new ConfigReader(); - String path = getClass().getResource("ConfigReaderTest-test-config.js").toURI().getPath(); + String path = TestFileUtils.createTempFileFromResource(this, "ConfigReaderTest-test-config.js").getAbsolutePath(); _config = configReader.getConfigFromFile(path); + List<TestConfig> testConfigs = _config.getTestConfigs(); assertEquals("Unexpected number of tests", 2, testConfigs.size()); TestConfig testConfig1 = _config.getTestConfigs().get(0); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java index 88750b9737..291ce2af78 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java @@ -24,9 +24,9 @@ import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.List; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class ConfigTest extends TestCase +public class ConfigTest extends QpidTestCase { public void testGetTestsForTestWithIteratingMessageSizes() { diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java index 7c839ed462..0eee80e425 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java @@ -27,13 +27,12 @@ import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.List; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.Command; import org.apache.qpid.disttest.message.CreateConnectionCommand; import org.apache.qpid.disttest.message.NoOpCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class ConnectionConfigTest extends TestCase +public class ConnectionConfigTest extends QpidTestCase { private static final String CONNECTION_FACTORY_NAME = "ConnectionFactoryName"; private static final String CONNECTION_NAME = "ConnectionName"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java index c011ff4711..0aa05a176e 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java @@ -19,11 +19,10 @@ */ package org.apache.qpid.disttest.controller.config; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.CreateConsumerCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class ConsumerConfigTest extends TestCase +public class ConsumerConfigTest extends QpidTestCase { public void testConsumerHasZeroArgConstructorForGson() { diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js index f64af82feb..eab98e8bd7 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest-test-config.js @@ -1,3 +1,23 @@ +/* + * + * 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. + * + */ jsonObject = { "_countries": QPID.iterations( { "__ITERATING_VALUE": [ 0, 1 ] }, @@ -20,4 +40,4 @@ jsonObject = { ) }) -}
\ No newline at end of file +} diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java index eb4063888b..55c1d4a7bd 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java @@ -25,15 +25,16 @@ import static org.apache.commons.beanutils.PropertyUtils.getProperty; import java.util.List; import java.util.TreeMap; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; +import org.apache.qpid.test.utils.TestFileUtils; import com.google.gson.Gson; -public class JavaScriptConfigEvaluatorTest extends TestCase +public class JavaScriptConfigEvaluatorTest extends QpidTestCase { public void testEvaluateJavaScript() throws Exception { - String jsFilePath = getClass().getResource("JavaScriptConfigEvaluatorTest-test-config.js").toURI().getPath(); + String jsFilePath = TestFileUtils.createTempFileFromResource(this, "JavaScriptConfigEvaluatorTest-test-config.js").getAbsolutePath(); String rawConfig = new JavaScriptConfigEvaluator().evaluateJavaScript(jsFilePath); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java index a3b367a4b4..148c07b1ca 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java @@ -21,13 +21,12 @@ package org.apache.qpid.disttest.controller.config; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; - 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.test.utils.QpidTestCase; -public class MessageProviderConfigTest extends TestCase +public class MessageProviderConfigTest extends QpidTestCase { public void testCreateCommandsForMessageProvider() { diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java index f58cc628a4..b6efd68cbd 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ParticipantConfigTest.java @@ -32,7 +32,7 @@ public class ParticipantConfigTest extends QpidTestCase setTestSystemProperty(ParticipantConfig.DURATION_OVERRIDE_SYSTEM_PROPERTY, String.valueOf(overriddenDuration)); CreateParticpantCommand createParticipantCommand = mock(CreateParticpantCommand.class); - ParticipantConfig participantConfig = new ParticipantConfig("name", "destinationName", 1, 2, 5000) + ParticipantConfig participantConfig = new ParticipantConfig("name", "destinationName", false, 1, 2, 5000) { }; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java index b9e591f113..44fca4bb7c 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java @@ -22,11 +22,10 @@ package org.apache.qpid.disttest.controller.config; import javax.jms.DeliveryMode; import javax.jms.Message; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.CreateProducerCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class ProducerConfigTest extends TestCase +public class ProducerConfigTest extends QpidTestCase { public void testProducerHasZeroArgConstructorForGson() { diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java index 8775e4064d..02cdbb8fca 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java @@ -29,14 +29,13 @@ import java.util.List; import javax.jms.Session; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.Command; 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.test.utils.QpidTestCase; -public class SessionConfigTest extends TestCase +public class SessionConfigTest extends QpidTestCase { private static final String CONNECTION_NAME = "conn1"; private static final String SESSION = "session1"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java index 1212a57606..be7c7a7c8c 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java @@ -26,12 +26,11 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; - import org.apache.qpid.disttest.controller.CommandForClient; import org.apache.qpid.disttest.message.NoOpCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class TestConfigTest extends TestCase +public class TestConfigTest extends QpidTestCase { private static final QueueConfig[] EMPTY_QUEUES_ARRAY = new QueueConfig[0]; private static final String CLIENT1 = "client1"; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java index 928fbe58cf..187b57c399 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java @@ -26,14 +26,13 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import junit.framework.TestCase; - import org.apache.qpid.disttest.controller.CommandForClient; import org.apache.qpid.disttest.message.CreateConsumerCommand; import org.apache.qpid.disttest.message.CreateProducerCommand; import org.apache.qpid.disttest.message.NoOpCommand; +import org.apache.qpid.test.utils.QpidTestCase; -public class TestInstanceTest extends TestCase +public class TestInstanceTest extends QpidTestCase { private static final String CLIENT_NAME = "CLIENT_NAME"; private static final int ITERATION_NUMBER = 0; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java new file mode 100644 index 0000000000..abc6b44493 --- /dev/null +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java @@ -0,0 +1,158 @@ +/* + * 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.disttest.db; + +import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT; +import static org.apache.qpid.test.utils.TestFileUtils.createTestDirectory; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.sql.Connection; +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.Hashtable; +import java.util.TimeZone; + +import javax.naming.Context; +import javax.naming.NamingException; + +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.db.ResultsDbWriter.Clock; +import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.disttest.results.ResultsTestFixture; +import org.apache.qpid.test.utils.QpidTestCase; +import org.apache.qpid.util.FileUtils; + +public class ResultsDbWriterTest extends QpidTestCase +{ + private static final long _dummyTimestamp = 1234; + + private File _tempDbDirectory; + private Clock _clock = mock(Clock.class); + private ResultsTestFixture _resultsTestFixture = new ResultsTestFixture(); + + @Override + protected void setUp() throws Exception + { + super.setUp(); + _tempDbDirectory = createTestDirectory(); + when(_clock.currentTimeMillis()).thenReturn(_dummyTimestamp); + } + + + @Override + protected void tearDown() throws Exception + { + try + { + FileUtils.deleteDirectory(_tempDbDirectory.getAbsolutePath()); + } + finally + { + super.tearDown(); + } + } + + + public void testWriteResults() throws Exception + { + Context context = getContext(); + ResultsForAllTests results = _resultsTestFixture.createResultsForAllTests(); + String runId = "myRunId"; + + ResultsDbWriter resultsDbWriter = new ResultsDbWriter(context, runId, _clock); + resultsDbWriter.createResultsTableIfNecessary(); + + resultsDbWriter.writeResults(results); + + ParticipantResult expectedResult = _resultsTestFixture.getFirstParticipantResult(results); + assertResultsAreInDb(context, expectedResult, runId); + } + + public void testDefaultRunId() throws Exception + { + TimeZone defaultTimeZone = TimeZone.getDefault(); + try + { + // set non-GMT timezone to make the test more rigorous. + TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00")); + ResultsDbWriter resultsDbWriter = new ResultsDbWriter(getContext(), null, _clock); + String runId = resultsDbWriter.getRunId(); + assertEquals( + "Default run id '" + runId + "' should correspond to dummy timestamp " + _clock.currentTimeMillis(), + "run 1970-01-01 00:00:01.234", + runId); + } + finally + { + TimeZone.setDefault(defaultTimeZone); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private Context getContext() throws NamingException + { + Context context = mock(Context.class); + Hashtable environment = new Hashtable(); + + environment.put(ResultsDbWriter.DRIVER_NAME, "org.apache.derby.jdbc.EmbeddedDriver"); + environment.put(ResultsDbWriter.URL, "jdbc:derby:" + _tempDbDirectory + "perftestResultsDb;create=true"); + + when(context.getEnvironment()).thenReturn(environment); + return context; + } + + @SuppressWarnings("unchecked") + private void assertResultsAreInDb(Context context, ParticipantResult participantResult, String expectedRunId) throws Exception + { + String driverName = (String) context.getEnvironment().get(ResultsDbWriter.DRIVER_NAME); + Class<? extends Driver> driverClass = (Class<? extends Driver>) Class.forName(driverName); + driverClass.newInstance(); + String url = (String) context.getEnvironment().get(ResultsDbWriter.URL); + + Connection connection = DriverManager.getConnection(url); + Statement statement = connection.createStatement(); + ResultSet rs = statement.executeQuery( + "SELECT * FROM results WHERE testName='" + participantResult.getTestName() + + "' AND runId='" + expectedRunId + "'"); + + try + { + rs.next(); + assertEquals(participantResult.getTestName(), rs.getString(TEST_NAME.getDisplayName())); + assertEquals(participantResult.getIterationNumber(), rs.getInt(ITERATION_NUMBER.getDisplayName())); + assertEquals(participantResult.getParticipantName(), rs.getString(PARTICIPANT_NAME.getDisplayName())); + assertEquals(participantResult.getThroughput(), rs.getDouble(THROUGHPUT.getDisplayName())); + assertEquals(expectedRunId, rs.getString(ResultsDbWriter.RUN_ID)); + assertEquals(new Timestamp(_dummyTimestamp), rs.getTimestamp(ResultsDbWriter.INSERTED_TIMESTAMP)); + } + finally + { + connection.close(); + } + } +} diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java index ab0f52263b..d4f0cb1f22 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java @@ -18,12 +18,11 @@ */ package org.apache.qpid.disttest.jms; -import junit.framework.TestCase; - import org.apache.qpid.disttest.message.Command; import org.apache.qpid.disttest.message.CommandType; +import org.apache.qpid.test.utils.QpidTestCase; -public class JmsMessageAdaptorTest extends TestCase +public class JmsMessageAdaptorTest extends QpidTestCase { public void testCheckAllCommandTypes() diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java index 4a56fff8fe..2e0c2e1ecd 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java @@ -24,14 +24,13 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import junit.framework.TestCase; - import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.qpid.disttest.client.property.ListPropertyValue; import org.apache.qpid.disttest.client.property.PropertyValue; import org.apache.qpid.disttest.json.JsonHandler; +import org.apache.qpid.test.utils.QpidTestCase; -public class JsonHandlerTest extends TestCase +public class JsonHandlerTest extends QpidTestCase { private JsonHandler _jsonHandler = null; private SendChristmasCards _testCommand = null; diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java index 34727a7b8d..e9d444d59c 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java @@ -18,7 +18,8 @@ */ package org.apache.qpid.disttest.message; -import static org.apache.qpid.disttest.message.ParticipantAttribute.*; +import static org.apache.qpid.disttest.message.ParticipantAttribute.ACKNOWLEDGE_MODE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE; import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME; import static org.apache.qpid.disttest.message.ParticipantAttribute.DELIVERY_MODE; import static org.apache.qpid.disttest.message.ParticipantAttribute.ERROR_MESSAGE; @@ -30,23 +31,25 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SYNCHRONO import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_TOPIC; import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER; import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION; -import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE; import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED; import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME; +import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE; import static org.apache.qpid.disttest.message.ParticipantAttribute.PRIORITY; import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_INTERVAL; import static org.apache.qpid.disttest.message.ParticipantAttribute.PRODUCER_START_DELAY; import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME; import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TAKEN; import static org.apache.qpid.disttest.message.ParticipantAttribute.TIME_TO_LIVE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_CONSUMERS; +import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_NUMBER_OF_PRODUCERS; import java.util.Date; import javax.jms.DeliveryMode; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class ParticipantResultTest extends TestCase +public class ParticipantResultTest extends QpidTestCase { public void testSharedParticipantResultAttributes() throws Exception diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsTestFixture.java index 565f59d25b..1edef031bf 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormaterTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsTestFixture.java @@ -15,12 +15,15 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * */ -package org.apache.qpid.disttest.results.formatting; +package org.apache.qpid.disttest.results; +import static org.apache.qpid.disttest.message.ParticipantAttribute.ACKNOWLEDGE_MODE; +import static org.apache.qpid.disttest.message.ParticipantAttribute.AVERAGE_LATENCY; import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE; import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME; -import static org.apache.qpid.disttest.message.ParticipantAttribute.*; +import static org.apache.qpid.disttest.message.ParticipantAttribute.DELIVERY_MODE; import static org.apache.qpid.disttest.message.ParticipantAttribute.ERROR_MESSAGE; import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_BROWSING_SUBSCRIPTION; import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_DURABLE_SUBSCRIPTION; @@ -29,7 +32,11 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SELECTOR; import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_SYNCHRONOUS_CONSUMER; import static org.apache.qpid.disttest.message.ParticipantAttribute.IS_TOPIC; import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER; +import static org.apache.qpid.disttest.message.ParticipantAttribute.LATENCY_STANDARD_DEVIATION; import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MAX_LATENCY; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MESSAGE_THROUGHPUT; +import static org.apache.qpid.disttest.message.ParticipantAttribute.MIN_LATENCY; import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED; import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME; import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE; @@ -46,46 +53,41 @@ import static org.apache.qpid.disttest.message.ParticipantAttribute.TOTAL_PAYLOA import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.HashMap; +import java.util.List; import java.util.Map; -import junit.framework.TestCase; - import org.apache.qpid.disttest.controller.ResultsForAllTests; import org.apache.qpid.disttest.controller.TestResult; import org.apache.qpid.disttest.message.ParticipantAttribute; import org.apache.qpid.disttest.message.ParticipantResult; +import org.apache.qpid.disttest.results.aggregation.ITestResult; -public class CSVFormaterTest extends TestCase +public class ResultsTestFixture { + public static final double THROUGHPUT_VALUE = 2048.49; + private static final String TEST1 = "TEST1"; private static final String PARTICIPANT = "PARTICIPANT"; private static final String CONFIGURED_CLIENT1 = "CONFIGURED_CLIENT1"; - private CSVFormater _formatter = new CSVFormater(); - - public void testResultsFileWithWithOneRow() throws Exception + public ResultsForAllTests createResultsForAllTests() { ParticipantResult participantResult = mock(ParticipantResult.class); Map<ParticipantAttribute, Object> participantAttributes = getParticipantAttributes(); when(participantResult.getAttributes()).thenReturn(participantAttributes); when(participantResult.getParticipantName()).thenReturn(PARTICIPANT); + when(participantResult.getTestName()).thenReturn(TEST1); + when(participantResult.getIterationNumber()).thenReturn(0); + when(participantResult.getThroughput()).thenReturn(THROUGHPUT_VALUE); TestResult testResult = new TestResult(TEST1); testResult.addParticipantResult(participantResult); ResultsForAllTests resultsForAllTests = new ResultsForAllTests(); resultsForAllTests.add(testResult); - - String output = _formatter.format(resultsForAllTests); - - String expectedOutput = readCsvOutputFileAsString("expectedOutput.csv"); - - assertEquals(expectedOutput, output); + return resultsForAllTests; } private Map<ParticipantAttribute, Object> getParticipantAttributes() @@ -96,7 +98,7 @@ public class CSVFormaterTest extends TestCase participantAttributes.put(ITERATION_NUMBER, 0); participantAttributes.put(CONFIGURED_CLIENT_NAME, CONFIGURED_CLIENT1); participantAttributes.put(PARTICIPANT_NAME, PARTICIPANT); - participantAttributes.put(NUMBER_OF_MESSAGES_PROCESSED, 0); + participantAttributes.put(NUMBER_OF_MESSAGES_PROCESSED, 2); participantAttributes.put(PAYLOAD_SIZE, 1); participantAttributes.put(PRIORITY, 2); participantAttributes.put(TIME_TO_LIVE, 3); @@ -115,32 +117,22 @@ public class CSVFormaterTest extends TestCase participantAttributes.put(TOTAL_NUMBER_OF_CONSUMERS, 1); participantAttributes.put(TOTAL_NUMBER_OF_PRODUCERS, 2); participantAttributes.put(TOTAL_PAYLOAD_PROCESSED, 1024); - participantAttributes.put(THROUGHPUT, 2048); + participantAttributes.put(THROUGHPUT, THROUGHPUT_VALUE); participantAttributes.put(TIME_TAKEN, 1000); participantAttributes.put(ERROR_MESSAGE, "error"); participantAttributes.put(MIN_LATENCY, 2l); participantAttributes.put(MAX_LATENCY, 9l); - participantAttributes.put(AVERAGE_LATENCY, 5.0f); + participantAttributes.put(AVERAGE_LATENCY, 4.6f); participantAttributes.put(LATENCY_STANDARD_DEVIATION, 2.0f); + participantAttributes.put(MESSAGE_THROUGHPUT, 2); return participantAttributes; } - private String readCsvOutputFileAsString(String filename) throws Exception + public ParticipantResult getFirstParticipantResult(ResultsForAllTests results) { - InputStream is = getClass().getResourceAsStream(filename); - assertNotNull(is); - - StringBuilder output = new StringBuilder(); - - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - String line = null; - while((line = br.readLine()) != null) - { - output.append(line); - output.append("\n"); - } - - return output.toString(); + List<ITestResult> testResults = results.getTestResults(); + ITestResult testResult = testResults.iterator().next(); + List<ParticipantResult> participantResults = testResult.getParticipantResults(); + return participantResults.iterator().next(); } - } diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java index 393837b4d5..011eb4e68b 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java @@ -24,11 +24,10 @@ import static org.mockito.Mockito.when; import java.util.Arrays; -import junit.framework.TestCase; - import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.test.utils.QpidTestCase; -public class AggregatorTest extends TestCase +public class AggregatorTest extends QpidTestCase { private Aggregator _aggregator = new Aggregator(); private TestResultAggregator _testResultAggregator = mock(TestResultAggregator.class); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java index 72743be1d1..41da1edb33 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java @@ -24,11 +24,9 @@ import java.util.Date; import javax.jms.Session; import org.apache.qpid.disttest.message.ParticipantResult; -import org.apache.qpid.disttest.results.aggregation.ParticipantResultAggregator; +import org.apache.qpid.test.utils.QpidTestCase; -import junit.framework.TestCase; - -public class ParticipantResultAggregatorTest extends TestCase +public class ParticipantResultAggregatorTest extends QpidTestCase { private ParticipantResultAggregator _aggregator = new ParticipantResultAggregator(ParticipantResult.class, AGGREGATED_RESULT_NAME); @@ -39,15 +37,19 @@ public class ParticipantResultAggregatorTest extends TestCase private static final long PARTICIPANT1_STARTDATE = 50; private static final long PARTICIPANT1_ENDDATE = 20000; private static final long PARTICIPANT1_TOTAL_PROCESSED = 1024; + private static final int PARTICIPANT1_NUMBER_OF_MESSAGES_PROCESSED = 20000; private static final long PARTICIPANT2_STARTDATE = 100; private static final long PARTICIPANT2_ENDDATE = 21000; private static final long PARTICIPANT2_TOTAL_PROCESSED = 2048; + private static final int PARTICIPANT2_NUMBER_OF_MESSAGES_PROCESSED = 950; private static final long OVERALL_PROCESSED = PARTICIPANT1_TOTAL_PROCESSED + PARTICIPANT2_TOTAL_PROCESSED; private static final double OVERALL_TIMETAKEN = PARTICIPANT2_ENDDATE - PARTICIPANT1_STARTDATE; + private static final long OVERALL_NUMBER_OF_MESSAGES_PROCESSED = PARTICIPANT1_NUMBER_OF_MESSAGES_PROCESSED + PARTICIPANT2_NUMBER_OF_MESSAGES_PROCESSED; private static final double EXPECTED_AGGREGATED_ALL_THROUGHPUT = ((OVERALL_PROCESSED)/1024)/((OVERALL_TIMETAKEN)/1000); + private static final int EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT = (int)(OVERALL_NUMBER_OF_MESSAGES_PROCESSED * 1000.0d/OVERALL_TIMETAKEN); public void testStartAndEndDateForOneParticipantResult() { @@ -128,6 +130,26 @@ public class ParticipantResultAggregatorTest extends TestCase assertEquals(EXPECTED_AGGREGATED_ALL_THROUGHPUT, aggregratedResult.getThroughput(), 0.1); } + public void testComputeMessageThroughput() + { + ParticipantResult result1 = new ParticipantResult(); + result1.setStartDate(new Date(PARTICIPANT1_STARTDATE)); + result1.setEndDate(new Date(PARTICIPANT1_ENDDATE)); + result1.setNumberOfMessagesProcessed(PARTICIPANT1_NUMBER_OF_MESSAGES_PROCESSED); + + ParticipantResult result2 = new ParticipantResult(); + result2.setStartDate(new Date(PARTICIPANT2_STARTDATE)); + result2.setEndDate(new Date(PARTICIPANT2_ENDDATE)); + result2.setNumberOfMessagesProcessed(PARTICIPANT2_NUMBER_OF_MESSAGES_PROCESSED); + + _aggregator.aggregate(result1); + _aggregator.aggregate(result2); + + ParticipantResult aggregratedResult = _aggregator.getAggregatedResult(); + assertEquals(EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT, aggregratedResult.getMessageThroughput()); + + } + public void testConstantTestNameAndIterationNumberRolledUp() throws Exception { ParticipantResult result1 = new ParticipantResult(); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java index ec8da8418f..7417dddc4f 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java @@ -23,9 +23,9 @@ package org.apache.qpid.disttest.results.aggregation; import java.util.Arrays; import java.util.Collection; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class SeriesStatisticsTest extends TestCase +public class SeriesStatisticsTest extends QpidTestCase { public static Collection<Long> SERIES = Arrays.asList(new Long[] { 2l, 4l, 4l, 4l, 5l, 5l, 7l, 9l, 5l }); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java index 9c00e7cf1c..b254a0e3bf 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/TestResultAggregatorTest.java @@ -18,29 +18,30 @@ */ package org.apache.qpid.disttest.results.aggregation; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Arrays; import java.util.Date; import java.util.List; -import junit.framework.TestCase; - +import org.apache.qpid.disttest.controller.ResultsForAllTests; import org.apache.qpid.disttest.controller.TestResult; 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.test.utils.QpidTestCase; -public class TestResultAggregatorTest extends TestCase +public class TestResultAggregatorTest extends QpidTestCase { - private static final String TEST1_NAME = "TEST1_NAME"; private static final int TEST1_ITERATION_NUMBER = 1; - private static final String CONSUMER_PARTICIPANT_NAME1 = "CONSUMER_PARTICIPANT_NAME1"; private static final String CONSUMER_PARTICIPANT_NAME2 = "CONSUMER_PARTICIPANT_NAME2"; private static final String PRODUCER_PARTICIPANT_NAME = "PRODUCER_PARTICIPANT_NAME"; - private static final long CONSUMER1_STARTDATE = 50; private static final long CONSUMER1_ENDDATE = 20000; @@ -64,6 +65,33 @@ public class TestResultAggregatorTest extends TestCase private TestResultAggregator _aggregator = new TestResultAggregator(); + public void testAggregateTestResults() + { + ResultsForAllTests resultsForAllTests1 = mock(ResultsForAllTests.class); + ResultsForAllTests resultsForAllTests2 = mock(ResultsForAllTests.class); + + ResultsForAllTests summaryResult1 = mock(ResultsForAllTests.class); + ResultsForAllTests summaryResult2 = mock(ResultsForAllTests.class); + + when(resultsForAllTests1.getAllParticipantsResult()).thenReturn(summaryResult1); + when(resultsForAllTests2.getAllParticipantsResult()).thenReturn(summaryResult2); + + ITestResult testResult1 = mock(ITestResult.class); + ITestResult testResult2 = mock(ITestResult.class); + + when(summaryResult1.getTestResults()).thenReturn(Arrays.asList(testResult1)); + when(summaryResult2.getTestResults()).thenReturn(Arrays.asList(testResult2)); + + ResultsForAllTests actualSummaryResults = _aggregator.aggregateTestResults(Arrays.asList( + resultsForAllTests1, + resultsForAllTests2)); + + assertEquals( + "Summary results should contain the all the 'all participants' test results", + Arrays.asList(testResult1, testResult2), + actualSummaryResults.getTestResults()); + } + public void testAggregateResultsForTwoConsumerAndOneProducer() throws Exception { TestResult originalTestResult = createResultsFromTest(); @@ -141,6 +169,10 @@ public class TestResultAggregatorTest extends TestCase aggregatedTestResult.getAllParticipantResult(), TEST1_NAME, TEST1_ITERATION_NUMBER, BATCH_SIZE, NUMBER_OF_MESSAGES_CONSUMED_IN_TOTAL, 2, 1); + + int expectedThroughtput = (int)Math.round(NUMBER_OF_MESSAGES_PRODUCED * 1000.0d /(CONSUMER2_ENDDATE - PRODUCER_STARTDATE)); + ParticipantResult result = aggregatedTestResult.getAllParticipantResult(); + assertEquals("Unexpected message throughtput", expectedThroughtput, result.getMessageThroughput()); } private void assertLatencyAggregatedResults(ParticipantResult allConsumerParticipantResult) @@ -197,4 +229,5 @@ public class TestResultAggregatorTest extends TestCase participantResult.setEndDate(new Date(end)); participantResult.setBatchSize(batchSize); } + } diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java new file mode 100644 index 0000000000..bbf73b23d2 --- /dev/null +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVFormatterTest.java @@ -0,0 +1,62 @@ +/* + * 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.disttest.results.formatting; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.apache.qpid.disttest.controller.ResultsForAllTests; +import org.apache.qpid.disttest.results.ResultsTestFixture; +import org.apache.qpid.test.utils.QpidTestCase; + +public class CSVFormatterTest extends QpidTestCase +{ + private CSVFormatter _formatter = new CSVFormatter(); + + public void testResultsFileWithWithOneRow() throws Exception + { + ResultsTestFixture resultsTestFixture = new ResultsTestFixture(); + ResultsForAllTests resultsForAllTests = resultsTestFixture.createResultsForAllTests(); + + String output = _formatter.format(resultsForAllTests); + + String expectedOutput = readCsvOutputFileAsString("expectedOutput.csv"); + + assertEquals(expectedOutput, output); + } + + private String readCsvOutputFileAsString(String filename) throws Exception + { + InputStream is = getClass().getResourceAsStream(filename); + assertNotNull(is); + + StringBuilder output = new StringBuilder(); + + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line = null; + while((line = br.readLine()) != null) + { + output.append(line); + output.append("\n"); + } + + return output.toString(); + } +} diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java index 6cec4b5245..ed109a2e27 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/CSVOrderParticipantResultComparatorTest.java @@ -19,15 +19,13 @@ package org.apache.qpid.disttest.results.formatting; -import junit.framework.TestCase; - 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.TestResultAggregator; -import org.apache.qpid.disttest.results.formatting.CSVOrderParticipantResultComparator; +import org.apache.qpid.test.utils.QpidTestCase; -public class CSVOrderParticipantResultComparatorTest extends TestCase +public class CSVOrderParticipantResultComparatorTest extends QpidTestCase { CSVOrderParticipantResultComparator _comparator = new CSVOrderParticipantResultComparator(); diff --git a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv index ada2303d46..02ea67d56d 100644 --- a/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv +++ b/java/perftests/src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv @@ -1,2 +1,2 @@ -testName,iterationNumber,clientName,participantName,numberOfMessages,payloadSizeB,priority,timeToLiveMs,acknowledgeMode,deliveryMode,batchSize,maximumDurationMs,producerStartDelayMs,producerIntervalMs,isTopic,isDurableSubscription,isBrowsingSubscription,isSelector,isNoLocal,isSynchronousConsumer,totalNumberOfConsumers,totalNumberOfProducers,totalPayloadProcessedB,throughputKbPerS,timeTakenMs,errorMessage,minLatency,maxLatency,averageLatency,latencyStandardDeviation -TEST1,0,CONFIGURED_CLIENT1,PARTICIPANT,0,1,2,3,4,5,6,7,8,9,true,false,true,false,true,false,1,2,1024,2048,1000,error,2,9,5.0,2.0 +testName,iterationNumber,throughputKbPerS,averageLatency,clientName,participantName,numberOfMessages,payloadSizeB,priority,timeToLiveMs,acknowledgeMode,deliveryMode,batchSize,maximumDurationMs,producerStartDelayMs,producerIntervalMs,isTopic,isDurableSubscription,isBrowsingSubscription,isSelector,isNoLocal,isSynchronousConsumer,totalNumberOfConsumers,totalNumberOfProducers,totalPayloadProcessedB,timeTakenMs,errorMessage,minLatency,maxLatency,latencyStandardDeviation,throughputMessagesPerS +TEST1,0,2048,5,CONFIGURED_CLIENT1,PARTICIPANT,2,1,2,3,4,5,6,7,8,9,true,false,true,false,true,false,1,2,1024,1000,error,2,9,2.0,2 diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java index 784e43469e..59396d46c0 100644 --- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/QpidQueueCreatorTest.java @@ -29,7 +29,6 @@ import javax.jms.Session; import org.apache.qpid.client.AMQDestination; import org.apache.qpid.client.AMQSession; -import org.apache.qpid.disttest.DistributedTestException; import org.apache.qpid.disttest.controller.config.QueueConfig; import org.apache.qpid.disttest.jms.QpidQueueCreator; @@ -37,6 +36,9 @@ public class QpidQueueCreatorTest extends DistributedTestSystemTestBase { private static final Map<String, Object> EMPTY_ATTRIBUTES = Collections.emptyMap(); + private static final boolean QUEUE_DURABILITY = true; + + private Connection _connection; private QpidQueueCreator _creator; private Session _session; private List<QueueConfig> _configs; @@ -46,20 +48,20 @@ public class QpidQueueCreatorTest extends DistributedTestSystemTestBase public void setUp() throws Exception { super.setUp(); - Connection connection = getConnection(); - _session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + _connection = getConnection(); + _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); _creator = new QpidQueueCreator(); _configs = new ArrayList<QueueConfig>(); - _queueName = "direct://amq.direct//" + getTestQueueName(); + _queueName = "direct://amq.direct//" + getTestQueueName() + "?durable='" + QUEUE_DURABILITY + "'"; } public void testCreateQueueWithoutAttributes() throws Exception { - _configs.add(new QueueConfig(_queueName, true, EMPTY_ATTRIBUTES)); + _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES)); assertQueueBound(_queueName, false); - _creator.createQueues(_session, _configs); + _creator.createQueues(_connection, _session, _configs); assertQueueBound(_queueName, true); } @@ -68,46 +70,28 @@ public class QpidQueueCreatorTest extends DistributedTestSystemTestBase { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("x-qpid-priorities", Integer.valueOf(5)); - _configs.add(new QueueConfig(_queueName, true, attributes)); + _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, attributes)); assertQueueBound(_queueName, false); - _creator.createQueues(_session, _configs); + _creator.createQueues(_connection, _session, _configs); assertQueueBound(_queueName, true); } public void testDeleteQueues() throws Exception { - _configs.add(new QueueConfig(_queueName, true, EMPTY_ATTRIBUTES)); + _configs.add(new QueueConfig(_queueName, QUEUE_DURABILITY, EMPTY_ATTRIBUTES)); assertQueueBound(_queueName, false); - _creator.createQueues(_session, _configs); + _creator.createQueues(_connection, _session, _configs); assertQueueBound(_queueName, true); - _creator.deleteQueues(_session, _configs); + _creator.deleteQueues(_connection, _session, _configs); assertQueueBound(_queueName, false); } - public void testDeleteQueueThatDoesNotExist() throws Exception - { - String queueThatDoesNotExist = _queueName; - List<QueueConfig> configs = new ArrayList<QueueConfig>(); - Map<String, Object> attributes = Collections.emptyMap(); - configs.add(new QueueConfig(queueThatDoesNotExist, true, attributes)); - - try - { - _creator.deleteQueues(_session, configs); - fail("Exception not thrown"); - } - catch (DistributedTestException e) - { - // PASS - } - } - private void assertQueueBound(String queueName, boolean isBound) throws Exception { AMQDestination destination = (AMQDestination)_session.createQueue(queueName); diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java index 808b428bc9..b06ab0c735 100644 --- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java +++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/SystemTestConstants.java @@ -21,8 +21,8 @@ package org.apache.qpid.systest.disttest; public abstract class SystemTestConstants { - public static final long REGISTRATION_TIMEOUT = 5000; - public static final long COMMAND_RESPONSE_TIMEOUT = 10000; - public static final long TEST_RESULT_TIMEOUT = 5000; + 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/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java index 7e58e1b5b1..a0c2a4b342 100644 --- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java +++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/endtoend/EndToEndTest.java @@ -20,7 +20,9 @@ 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; @@ -36,6 +38,7 @@ 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 { @@ -44,6 +47,8 @@ public class EndToEndTest extends QpidBrokerTestCase 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); @@ -76,10 +81,10 @@ public class EndToEndTest extends QpidBrokerTestCase 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[0]); - assertEquals("Unexpected client name in CSV line " + csvLine, clientName, cells[2]); - assertEquals("Unexpected participant name in CSV line " + csvLine, participantName, cells[3]); - assertEquals("Unexpected number of messages processed in CSV line " + csvLine, String.valueOf(expectedNumberOfMessagesProcessed), cells[4]); + 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()]); } diff --git a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties index b5d053227c..149e632048 100644 --- a/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties +++ b/java/perftests/src/test/java/org/apache/qpid/systest/disttest/perftests.systests.properties @@ -24,3 +24,6 @@ java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextF 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/java/perftests/visualisation-jfc/build.xml b/java/perftests/visualisation-jfc/build.xml index 02c9f5dcbd..04deb39d36 100644 --- a/java/perftests/visualisation-jfc/build.xml +++ b/java/perftests/visualisation-jfc/build.xml @@ -17,8 +17,8 @@ - under the License. --> <project name="visualisation-jfc" xmlns:ivy="antlib:org.apache.ivy.ant" default="build"> - <property name="module.depends" value="common perftests" /> - <property name="module.test.depends" value="test common/test" /> + <property name="module.depends" value="perftests" /> + <property name="module.test.depends" value="common common/tests" /> <property name="module.manifest" value="true" /> diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java index ed09f4a77e..5a77f22148 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java @@ -21,5 +21,5 @@ package org.apache.qpid.disttest.charting; public enum ChartType { - LINE, LINE3D, BAR, BAR3D, XYLINE, STATISTICAL_BAR + LINE, LINE3D, BAR, BAR3D, XYLINE, TIMELINE, STATISTICAL_BAR } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java index e00859855e..91eafe324b 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java @@ -30,7 +30,8 @@ import org.apache.qpid.disttest.charting.chartbuilder.ChartBuilder; import org.apache.qpid.disttest.charting.chartbuilder.ChartBuilderFactory; import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator; -import org.apache.qpid.disttest.charting.seriesbuilder.JdbcCsvSeriesBuilder; +import org.apache.qpid.disttest.charting.seriesbuilder.JdbcSeriesBuilder; +import org.apache.qpid.disttest.charting.seriesbuilder.JdbcUrlGenerator; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; import org.apache.qpid.disttest.charting.writer.ChartWriter; import org.jfree.chart.JFreeChart; @@ -44,24 +45,46 @@ import org.slf4j.LoggerFactory; * The following arguments are understood: * </p> * <ol> - * <li>chart-defs=<i>directory contain chartdef file(s)</i></li> - * <li>output-dir=<i>directory in which to produce the PNGs</i></li> + * <li>{@link #OUTPUT_DIR_PROP}</li> + * <li>{@link #CHART_DEFINITIONS_PROP}</li> + * <li>{@link #SUMMARY_TITLE_PROP}</li> + * <li>{@link #JDBC_DRIVER_NAME_PROP}</li> + * <li>{@link #JDBC_URL_PROP}</li> * </ol> + * Default values are indicated by the similarly named constants in this class. */ public class ChartingUtil { private static final Logger LOGGER = LoggerFactory.getLogger(ChartingUtil.class); + /** directory in which to produce the PNGs */ public static final String OUTPUT_DIR_PROP = "outputdir"; public static final String OUTPUT_DIR_DEFAULT = "."; + /** the path to the directory containing the chart definition files */ public static final String CHART_DEFINITIONS_PROP = "chart-defs"; public static final String CHART_DEFINITIONS_DEFAULT = "."; + public static final String SUMMARY_TITLE_PROP = "summary-title"; + public static final String SUMMARY_TITLE_DEFAULT = "Performance Charts"; + + /** the class name of the JDBC driver to use for reading the chart data */ + public static final String JDBC_DRIVER_NAME_PROP = "jdbcDriverClass"; + public static final String JDBC_DRIVER_NAME_DEFAULT = JdbcUrlGenerator.DEFAULT_JDBC_DRIVER_NAME; + + /** the JDBC URL of the data to be charted */ + public static final String JDBC_URL_PROP = "jdbcUrl"; + public static final String JDBC_URL_DEFAULT = null; + + private Map<String,String> _cliOptions = new HashMap<String, String>(); + { _cliOptions.put(OUTPUT_DIR_PROP, OUTPUT_DIR_DEFAULT); _cliOptions.put(CHART_DEFINITIONS_PROP, CHART_DEFINITIONS_DEFAULT); + _cliOptions.put(SUMMARY_TITLE_PROP, SUMMARY_TITLE_DEFAULT); + _cliOptions.put(JDBC_DRIVER_NAME_PROP, JDBC_DRIVER_NAME_DEFAULT); + _cliOptions.put(JDBC_URL_PROP, JDBC_URL_DEFAULT); } public static void main(String[] args) throws Exception @@ -82,26 +105,38 @@ public class ChartingUtil private void produceAllCharts() { - final String chartingDefsDir = _cliOptions.get(CHART_DEFINITIONS_PROP); - final File chartDirectory = new File(_cliOptions.get(OUTPUT_DIR_PROP)); - LOGGER.info("Chart chartdef directory/file: {} output directory : {}", chartingDefsDir, chartDirectory); - - List<ChartingDefinition> definitions = loadChartDefinitions(chartingDefsDir); - - LOGGER.info("There are {} chart(s) to produce", definitions.size()); final ChartWriter writer = new ChartWriter(); - writer.setOutputDirectory(chartDirectory); + writer.setOutputDirectory(new File(_cliOptions.get(OUTPUT_DIR_PROP))); + + SeriesBuilder seriesBuilder = new JdbcSeriesBuilder( + _cliOptions.get(JDBC_DRIVER_NAME_PROP), + _cliOptions.get(JDBC_URL_PROP)); - final SeriesBuilder seriesBuilder = new JdbcCsvSeriesBuilder(); - for (ChartingDefinition chartingDefinition : definitions) + for (ChartingDefinition chartingDefinition : loadChartDefinitions()) { - ChartBuilder chartBuilder = ChartBuilderFactory.createChartBuilder(chartingDefinition.getChartType(), seriesBuilder); + ChartBuilder chartBuilder = ChartBuilderFactory.createChartBuilder( + chartingDefinition.getChartType(), + seriesBuilder); + JFreeChart chart = chartBuilder.buildChart(chartingDefinition); - writer.writeChartToFileSystem(chart, chartingDefinition.getChartStemName()); + writer.writeChartToFileSystem(chart, chartingDefinition); } - writer.writeHtmlSummaryToFileSystem(); + final String summaryChartTitle = _cliOptions.get(SUMMARY_TITLE_PROP); + writer.writeHtmlSummaryToFileSystem(summaryChartTitle); + } + + private List<ChartingDefinition> loadChartDefinitions() + { + final String chartingDefsDir = _cliOptions.get(CHART_DEFINITIONS_PROP); + + LOGGER.info("Chart chartdef directory/file: {}", chartingDefsDir); + + List<ChartingDefinition> definitions = loadChartDefinitions(chartingDefsDir); + + LOGGER.info("There are {} chart(s) to produce", definitions.size()); + return definitions; } private List<ChartingDefinition> loadChartDefinitions(String chartingDefsDir) diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java index 491bb1c67d..b10fd477ed 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java @@ -36,7 +36,7 @@ public class BarChart3DBuilder extends CategoryDataSetBasedChartBuilder } @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, + protected JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java index b5c6a38067..7705ef5d3a 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java @@ -35,7 +35,7 @@ public class BarChartBuilder extends CategoryDataSetBasedChartBuilder } @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, + protected JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java index def87f5840..9cadf0ec3c 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java @@ -23,6 +23,9 @@ import java.awt.Color; import java.awt.GradientPaint; import org.apache.qpid.disttest.charting.definition.ChartingDefinition; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.title.ShortTextTitle; @@ -30,12 +33,67 @@ import org.jfree.data.general.Dataset; public abstract class BaseChartBuilder implements ChartBuilder { - private static final GradientPaint BLUE_GRADIENT = new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue); + static final GradientPaint BLUE_GRADIENT = new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue); - public void addCommonChartAttributes(JFreeChart chart, ChartingDefinition chartingDefinition) + private SeriesPainter _seriesPainter = new SeriesPainter(); + + private final SeriesBuilder _seriesBuilder; + + protected BaseChartBuilder(SeriesBuilder seriesBuilder) + { + _seriesBuilder = seriesBuilder; + } + + @Override + public JFreeChart buildChart(ChartingDefinition chartingDefinition) + { + _seriesBuilder.setDatasetHolder(newDatasetHolder()); + Dataset dataset = _seriesBuilder.build(chartingDefinition.getSeriesDefinitions()); + + JFreeChart chart = createChart(chartingDefinition, dataset); + return chart; + } + + + /** + * return a holder of an empty dataset suitable for use with the chart type + * returned by {@link #createChartImpl(String, String, String, Dataset, PlotOrientation, boolean, boolean, boolean)}. + */ + protected abstract DatasetHolder newDatasetHolder(); + + /** + * Create a chart with the supplied parameters. + * + * For ease of implementation, the signature is intentionally similar + * to {@link ChartFactory}'s factory methods. + */ + protected abstract JFreeChart createChartImpl( + String title, String xAxisTitle, String yAxisTitle, + final Dataset dataset, + PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls); + + /** + * Create a {@link SeriesStrokeAndPaintApplier} that will be used to format a chart + */ + protected abstract SeriesStrokeAndPaintApplier newStrokeAndPaintApplier(); + + + private JFreeChart createChart(ChartingDefinition chartingDefinition, final Dataset dataset) { + String title = chartingDefinition.getChartTitle(); + String xAxisTitle = chartingDefinition.getXAxisTitle(); + String yAxisTitle = chartingDefinition.getYAxisTitle(); + + final JFreeChart chart = createChartImpl( + title, xAxisTitle, yAxisTitle, + dataset, + PLOT_ORIENTATION, SHOW_LEGEND, SHOW_TOOL_TIPS, SHOW_URLS); + addSubtitle(chart, chartingDefinition); - setBackgroundColour(chart); + chart.setBackgroundPaint(BLUE_GRADIENT); + _seriesPainter.applySeriesAppearance(chart, chartingDefinition.getSeriesDefinitions(), newStrokeAndPaintApplier()); + + return chart; } private void addSubtitle(JFreeChart chart, ChartingDefinition chartingDefinition) @@ -46,13 +104,9 @@ public abstract class BaseChartBuilder implements ChartBuilder } } - private void setBackgroundColour(JFreeChart chart) + void setSeriesPainter(SeriesPainter seriesPainter) { - chart.setBackgroundPaint(BLUE_GRADIENT); + _seriesPainter = seriesPainter; } - public abstract JFreeChart createChartImpl(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, - boolean showUrls); - } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java index a6c63f4560..0d08fd8ad1 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java @@ -20,40 +20,36 @@ package org.apache.qpid.disttest.charting.chartbuilder; -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilderCallback; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryLabelPositions; +import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.general.Dataset; public abstract class CategoryDataSetBasedChartBuilder extends BaseChartBuilder { - private final SeriesBuilder _seriesBuilder; - public CategoryDataSetBasedChartBuilder(SeriesBuilder seriesBuilder) { - _seriesBuilder = seriesBuilder; + super(seriesBuilder); } @Override - public JFreeChart buildChart(ChartingDefinition chartingDefinition) + protected DatasetHolder newDatasetHolder() { - String title = chartingDefinition.getChartTitle(); - String xAxisTitle = chartingDefinition.getXAxisTitle(); - String yAxisTitle = chartingDefinition.getYAxisTitle(); - - final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - - _seriesBuilder.setSeriesBuilderCallback(new SeriesBuilderCallback() + return new DatasetHolder() { + final private DefaultCategoryDataset _dataset = new DefaultCategoryDataset(); + @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, Object[] row) + public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) { - String x = String.valueOf(row[0]); - double y = Double.parseDouble(row[1].toString()); - dataset.addValue( y, seriesDefinition.getSeriesLegend(), x); + String x = row.dimensionAsString(0); + double y = row.dimensionAsDouble(1); + _dataset.addValue(y, seriesDefinition.getSeriesLegend(), x); } @Override @@ -68,17 +64,33 @@ public abstract class CategoryDataSetBasedChartBuilder extends BaseChartBuilder // unused } - }); + @Override + public int getNumberOfDimensions() + { + return 2; + } - _seriesBuilder.build(chartingDefinition.getSeries()); + @Override + public Dataset getPopulatedDataset() + { + return _dataset; + } + }; + } - JFreeChart chart = createChartImpl(title, xAxisTitle, yAxisTitle, - dataset, PLOT_ORIENTATION, SHOW_LEGEND, SHOW_TOOL_TIPS, SHOW_URLS); + @Override + protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() + { + return new CategoryStrokeAndPaintApplier(); + } + @Override + protected final JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) + { + JFreeChart chart = createCategoryChart(title, xAxisTitle, yAxisTitle, dataset, plotOrientation, showLegend, showToolTips, showUrls); chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); - - addCommonChartAttributes(chart, chartingDefinition); - return chart; } + + protected abstract JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls); } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryStrokeAndPaintApplier.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryStrokeAndPaintApplier.java new file mode 100644 index 0000000000..cbf5cbe515 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryStrokeAndPaintApplier.java @@ -0,0 +1,41 @@ +/* + * + * 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.disttest.charting.chartbuilder; + +import java.awt.Color; +import java.awt.Stroke; + +import org.jfree.chart.JFreeChart; + +class CategoryStrokeAndPaintApplier implements SeriesStrokeAndPaintApplier +{ + @Override + public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) + { + targetChart.getCategoryPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); + } + + @Override + public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) + { + targetChart.getCategoryPlot().getRenderer().setSeriesPaint(seriesIndex, colour); + } +}
\ No newline at end of file diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java index f4e11a2c4d..63a0573676 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java @@ -39,8 +39,10 @@ public class ChartBuilderFactory return new BarChart3DBuilder(seriesBuilder); case XYLINE: return new XYLineChartBuilder(seriesBuilder); + case TIMELINE: + return new TimeSeriesLineChartBuilder(seriesBuilder); case STATISTICAL_BAR: - return new StatisticalBarCharBuilder(seriesBuilder); + return new StatisticalBarChartBuilder(seriesBuilder); default: throw new IllegalArgumentException("Unknown chart type " + chartType); } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java new file mode 100644 index 0000000000..49d777c506 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java @@ -0,0 +1,66 @@ +/* + * 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.disttest.charting.chartbuilder; + +import java.awt.Color; + +public class ColorFactory +{ + /** + * Converts a colour name known to the JDK into a {@link Color} instance. Additionally, + * if the work dark_ is prepended to the colour, a darker shade of the same colour is + * produced. + * + * @param colourName + * @return colour instance + */ + public static Color toColour(String colourName) + { + boolean darkVersion = false; + if (colourName.toLowerCase().startsWith("dark_")) + { + colourName = colourName.replaceFirst("(?i)dark_", ""); + darkVersion = true; + } + + Color colour = getColourFromStaticField(colourName); + if (darkVersion) + { + return colour.darker(); + } + else + { + return colour; + } + } + + private static Color getColourFromStaticField(String colourName) + { + try + { + return (Color) Color.class.getField(colourName.toLowerCase()).get(null); + } + catch (Exception e) + { + throw new RuntimeException("Could not find colour for " + colourName, e); + } + } + +} diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java index 27fff12da0..b92a25f5ac 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java @@ -34,7 +34,7 @@ public class LineChart3DBuilder extends CategoryDataSetBasedChartBuilder } @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, + protected JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java index 40f3a09b6b..3f5b18acda 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java @@ -35,7 +35,7 @@ public class LineChartBuilder extends CategoryDataSetBasedChartBuilder } @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, + protected JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesPainter.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesPainter.java new file mode 100644 index 0000000000..854635dc87 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesPainter.java @@ -0,0 +1,63 @@ +/* + * 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.disttest.charting.chartbuilder; + +import java.awt.BasicStroke; +import java.util.List; + +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.jfree.chart.JFreeChart; + +public class SeriesPainter +{ + public void applySeriesAppearance(JFreeChart chart, List<SeriesDefinition> seriesDefinitions, SeriesStrokeAndPaintApplier strokeAndPaintApplier) + { + for (int i = 0; i < seriesDefinitions.size(); i++) + { + SeriesDefinition seriesDefinition = seriesDefinitions.get(i); + if (seriesDefinition.getSeriesColourName() != null) + { + strokeAndPaintApplier.setSeriesPaint(i, ColorFactory.toColour(seriesDefinition.getSeriesColourName()), chart); + } + if (seriesDefinition.getStrokeWidth() != null) + { + // Negative width used to signify dashed + boolean dashed = seriesDefinition.getStrokeWidth() < 0; + float width = Math.abs(seriesDefinition.getStrokeWidth()); + BasicStroke stroke = buildStrokeOfWidth(width, dashed); + strokeAndPaintApplier.setSeriesStroke(i, stroke, chart); + } + } + } + + private BasicStroke buildStrokeOfWidth(float width, boolean dashed) + { + final BasicStroke stroke; + if (dashed) + { + stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {5.0f, 3.0f}, 0.0f); + } + else + { + stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + } + return stroke; + } +} diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java new file mode 100644 index 0000000000..4d6c37a9f4 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java @@ -0,0 +1,35 @@ +/* + * 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.disttest.charting.chartbuilder; + +import java.awt.Color; +import java.awt.Stroke; + +import org.jfree.chart.JFreeChart; + +/** + * Applies the supplied stroke and color to a series in the target chart. + * Multiple implementations exist to because of the various chart types. + */ +public interface SeriesStrokeAndPaintApplier +{ + void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart); + void setSeriesPaint(int seriesIndex, Color color, JFreeChart targetChart); +} diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarChartBuilder.java index 86c3f62e09..c5ad2d7dad 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarCharBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarChartBuilder.java @@ -22,10 +22,10 @@ package org.apache.qpid.disttest.charting.chartbuilder; import java.awt.Font; -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilderCallback; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; @@ -39,33 +39,27 @@ import org.jfree.data.general.Dataset; import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; import org.jfree.data.statistics.StatisticalCategoryDataset; -public class StatisticalBarCharBuilder extends BaseChartBuilder +public class StatisticalBarChartBuilder extends BaseChartBuilder { - private final SeriesBuilder _seriesBuilder; - - public StatisticalBarCharBuilder(SeriesBuilder seriesBuilder) + public StatisticalBarChartBuilder(SeriesBuilder seriesBuilder) { - _seriesBuilder = seriesBuilder; + super(seriesBuilder); } @Override - public JFreeChart buildChart(ChartingDefinition chartingDefinition) + protected DatasetHolder newDatasetHolder() { - String title = chartingDefinition.getChartTitle(); - String xAxisTitle = chartingDefinition.getXAxisTitle(); - String yAxisTitle = chartingDefinition.getYAxisTitle(); - - final DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); - - _seriesBuilder.setSeriesBuilderCallback(new SeriesBuilderCallback() + return new DatasetHolder() { + private final DefaultStatisticalCategoryDataset _dataset = new DefaultStatisticalCategoryDataset(); + @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, Object[] row) + public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) { - String x = String.valueOf(row[0]); - double mean = Double.parseDouble(row[1].toString()); - double stdDev = Double.parseDouble(row[2].toString()); - dataset.add(mean, stdDev, seriesDefinition.getSeriesLegend(), x); + String x = row.dimensionAsString(0); + double mean = row.dimensionAsDouble(1); + double stdDev = row.dimensionAsDouble(2); + _dataset.add(mean, stdDev, seriesDefinition.getSeriesLegend(), x); } @Override @@ -80,18 +74,24 @@ public class StatisticalBarCharBuilder extends BaseChartBuilder // unused } - }); - - _seriesBuilder.build(chartingDefinition.getSeries()); - - JFreeChart chart = createChartImpl(title, xAxisTitle, yAxisTitle, dataset, PLOT_ORIENTATION, SHOW_LEGEND, - SHOW_TOOL_TIPS, SHOW_URLS); - - chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); + @Override + public int getNumberOfDimensions() + { + return 3; + } - addCommonChartAttributes(chart, chartingDefinition); + @Override + public Dataset getPopulatedDataset() + { + return _dataset; + } + }; + } - return chart; + @Override + protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() + { + return new CategoryStrokeAndPaintApplier(); } @Override @@ -105,6 +105,9 @@ public class StatisticalBarCharBuilder extends BaseChartBuilder CategoryPlot plot = new CategoryPlot((StatisticalCategoryDataset) dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, new Font("Arial", Font.PLAIN, 10), plot, true); + + chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); + return chart; } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesHolder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesHolder.java new file mode 100644 index 0000000000..803a098dfa --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesHolder.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.disttest.charting.chartbuilder; + +import java.util.Date; + +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; +import org.jfree.data.general.Dataset; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; + +class TimeSeriesHolder implements DatasetHolder +{ + private final TimeSeriesCollection _timeSeriesCollection = new TimeSeriesCollection(); + private TimeSeries _timeSeries; + + @Override + public void beginSeries(SeriesDefinition seriesDefinition) + { + _timeSeries = new TimeSeries(seriesDefinition.getSeriesLegend()); + } + + @Override + public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) + { + Date x = row.dimensionAsDate(0); + double y = row.dimensionAsDouble(1); + RegularTimePeriod jfreeChartDate = new Millisecond(x); + _timeSeries.add(jfreeChartDate, y); + } + + @Override + public void endSeries(SeriesDefinition seriesDefinition) + { + _timeSeriesCollection.addSeries(_timeSeries); + } + + @Override + public int getNumberOfDimensions() + { + return 2; + } + + @Override + public Dataset getPopulatedDataset() + { + return _timeSeriesCollection; + } +}
\ No newline at end of file diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesLineChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesLineChartBuilder.java new file mode 100644 index 0000000000..7249ae6332 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesLineChartBuilder.java @@ -0,0 +1,59 @@ +/* + * 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.disttest.charting.chartbuilder; + +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.general.Dataset; +import org.jfree.data.xy.XYDataset; + +public class TimeSeriesLineChartBuilder extends XYDataSetBasedChartBuilder +{ + public TimeSeriesLineChartBuilder(SeriesBuilder seriesBuilder) + { + super(seriesBuilder); + } + + @Override + protected DatasetHolder newDatasetHolder() + { + return new TimeSeriesHolder(); + } + + @Override + public JFreeChart createChartImpl(String title, String xAxisTitle, + String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, + boolean showLegend, boolean showToolTips, boolean showUrls) + { + JFreeChart chart = ChartFactory.createTimeSeriesChart( + title, + xAxisTitle, + yAxisTitle, + (XYDataset)dataset, + showLegend, + showToolTips, + showUrls); + + return chart; + } +} diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java index 87d61ca2ee..575712f06c 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java @@ -19,38 +19,34 @@ */ package org.apache.qpid.disttest.charting.chartbuilder; +import java.awt.Color; +import java.awt.Stroke; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilderCallback; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.CategoryLabelPositions; +import org.jfree.data.general.Dataset; import org.jfree.data.xy.DefaultXYDataset; public abstract class XYDataSetBasedChartBuilder extends BaseChartBuilder { - private final SeriesBuilder _seriesBuilder; - public XYDataSetBasedChartBuilder(SeriesBuilder seriesBuilder) { - this._seriesBuilder = seriesBuilder; + super(seriesBuilder); } @Override - public JFreeChart buildChart(ChartingDefinition chartingDefinition) + protected DatasetHolder newDatasetHolder() { - String title = chartingDefinition.getChartTitle(); - String xAxisTitle = chartingDefinition.getXAxisTitle(); - String yAxisTitle = chartingDefinition.getYAxisTitle(); - - final DefaultXYDataset dataset = new DefaultXYDataset(); - _seriesBuilder.setSeriesBuilderCallback(new SeriesBuilderCallback() + return new DatasetHolder() { + private final DefaultXYDataset _dataset = new DefaultXYDataset(); private List<Double[]> _xyPairs = null; @Override @@ -60,20 +56,24 @@ public abstract class XYDataSetBasedChartBuilder extends BaseChartBuilder } @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, - Object[] row) + public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) { - double x = Double.parseDouble(row[0].toString()); - double y = Double.parseDouble(row[1].toString()); + double x = row.dimensionAsDouble(0); + double y = row.dimensionAsDouble(1); _xyPairs.add(new Double[] {x, y}); } - @Override public void endSeries(SeriesDefinition seriesDefinition) { double[][] seriesData = listToSeriesDataArray(); - dataset.addSeries(seriesDefinition.getSeriesLegend(), seriesData); + _dataset.addSeries(seriesDefinition.getSeriesLegend(), seriesData); + } + + @Override + public int getNumberOfDimensions() + { + return 2; } private double[][] listToSeriesDataArray() @@ -86,18 +86,34 @@ public abstract class XYDataSetBasedChartBuilder extends BaseChartBuilder seriesData[0][i] = xyPair[0]; seriesData[1][i] = xyPair[1]; i++; - } + } return seriesData; } - }); - - _seriesBuilder.build(chartingDefinition.getSeries()); - JFreeChart chart = createChartImpl(title, xAxisTitle, yAxisTitle, - dataset, PLOT_ORIENTATION, SHOW_LEGEND, SHOW_TOOL_TIPS, SHOW_URLS); + @Override + public Dataset getPopulatedDataset() + { + return _dataset; + } + }; + } - addCommonChartAttributes(chart, chartingDefinition); + @Override + protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() + { + return new SeriesStrokeAndPaintApplier() + { + @Override + public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) + { + targetChart.getXYPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); + } - return chart; + @Override + public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) + { + targetChart.getXYPlot().getRenderer().setSeriesPaint(seriesIndex, colour); + } + }; } } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java index 04b3f7ed3b..bfe47e598e 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java @@ -30,6 +30,7 @@ public class ChartingDefinition private final ChartType _chartType; private final String _chartTitle; private final String _chartSubtitle; + private final String _chartDescription; private final String _xaxisTitle; private final String _yaxisTitle; private final List<SeriesDefinition> _seriesDefinitions; @@ -39,12 +40,14 @@ public class ChartingDefinition final ChartType chartType, final String chartTitle, final String chartSubtitle, + final String chartDescription, final String xaxisTitle, final String yaxisTitle, List<SeriesDefinition> seriesDefinitions) { _chartStemName = chartStemName; _chartType = chartType; _chartTitle = chartTitle; _chartSubtitle = chartSubtitle; + _chartDescription = chartDescription; _xaxisTitle = xaxisTitle; _yaxisTitle = yaxisTitle; _seriesDefinitions = seriesDefinitions; @@ -65,6 +68,10 @@ public class ChartingDefinition return _chartSubtitle; } + public String getChartDescription() + { + return _chartDescription; + } public String getXAxisTitle() { @@ -77,17 +84,14 @@ public class ChartingDefinition return _yaxisTitle; } - - public ChartType getChartType() { return _chartType; } - public List<SeriesDefinition> getSeries() + public List<SeriesDefinition> getSeriesDefinitions() { return Collections.unmodifiableList(_seriesDefinitions); } - } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java index 4cbc9318a9..1988f561b6 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java @@ -39,6 +39,7 @@ public class ChartingDefinitionCreator public static final String CHART_TYPE_KEY = "chartType"; public static final String CHART_TITLE_KEY = "chartTitle"; public static final String CHART_SUBTITLE_KEY = "chartSubtitle"; + public static final String CHART_DESCRIPTION_KEY = "chartDescription"; public static final String XAXIS_TITLE_KEY = "xAxisTitle"; public static final String YAXIS_TITLE_KEY = "yAxisTitle"; @@ -82,6 +83,7 @@ public class ChartingDefinitionCreator final ChartType chartType = ChartType.valueOf(props.getProperty(CHART_TYPE_KEY)); final String chartTitle = props.getProperty(CHART_TITLE_KEY); final String chartSubtitle = props.getProperty(CHART_SUBTITLE_KEY); + final String chartDescription = props.getProperty(CHART_DESCRIPTION_KEY); final String xAxisTitle = props.getProperty(XAXIS_TITLE_KEY); final String yAxisTitle = props.getProperty(YAXIS_TITLE_KEY); @@ -91,8 +93,8 @@ public class ChartingDefinitionCreator chartType, chartTitle, chartSubtitle, - xAxisTitle, - yAxisTitle, seriesDefinitions); + chartDescription, + xAxisTitle, yAxisTitle, seriesDefinitions); return chartDefinition; } catch (IOException e) diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java index a39e906957..d89ff855e2 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java @@ -19,17 +19,24 @@ */ package org.apache.qpid.disttest.charting.definition; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + public class SeriesDefinition { private final String _seriesStatement; private final String _seriesLegend; private final String _seriesDirectory; + private final String _seriesColourName; + private final Integer _seriesStrokeWidth; - public SeriesDefinition(String seriesStatement, String seriesLegend, String seriesDirectory) + public SeriesDefinition(String seriesStatement, String seriesLegend, String seriesDirectory, String seriesColourName, Integer seriesStrokeWidth) { _seriesStatement = seriesStatement; _seriesLegend = seriesLegend; _seriesDirectory = seriesDirectory; + _seriesColourName = seriesColourName; + _seriesStrokeWidth = seriesStrokeWidth; } public String getSeriesStatement() @@ -47,4 +54,22 @@ public class SeriesDefinition return _seriesDirectory; } + public String getSeriesColourName() + { + return _seriesColourName; + } + + public Integer getStrokeWidth() + { + return _seriesStrokeWidth; + } + + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("seriesLegend", _seriesLegend) + .append("seriesStatement", _seriesStatement) + .append("seriesDirectory", _seriesDirectory).toString(); + } } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java index fcc11807c8..d47e7488e1 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java @@ -30,6 +30,8 @@ public class SeriesDefinitionCreator public static final String SERIES_STATEMENT_KEY_FORMAT = "series.%d.statement"; public static final String SERIES_LEGEND_KEY_FORMAT = "series.%d.legend"; public static final String SERIES_DIRECTORY_KEY_FORMAT = "series.%d.dir"; + public static final String SERIES_COLOUR_NAME_FORMAT = "series.%d.colourName"; + public static final String SERIES_STROKE_WIDTH_FORMAT = "series.%d.strokeWidth"; public List<SeriesDefinition> createFromProperties(Properties properties) { @@ -42,10 +44,13 @@ public class SeriesDefinitionCreator String seriesStatement = properties.getProperty(String.format(SERIES_STATEMENT_KEY_FORMAT, index)); String seriesLegend = properties.getProperty(String.format(SERIES_LEGEND_KEY_FORMAT, index)); String seriesDir = StrSubstitutor.replaceSystemProperties(properties.getProperty(String.format(SERIES_DIRECTORY_KEY_FORMAT, index))); + String seriesColourName = properties.getProperty(String.format(SERIES_COLOUR_NAME_FORMAT, index)); + Integer seriesStrokeWidth = properties.getProperty(String.format(SERIES_STROKE_WIDTH_FORMAT, index)) == null + ? null : Integer.parseInt(properties.getProperty(String.format(SERIES_STROKE_WIDTH_FORMAT, index))); if (seriesStatement != null) { - final SeriesDefinition seriesDefinition = new SeriesDefinition(seriesStatement, seriesLegend, seriesDir); + final SeriesDefinition seriesDefinition = new SeriesDefinition(seriesStatement, seriesLegend, seriesDir, seriesColourName, seriesStrokeWidth); seriesDefinitions.add(seriesDefinition); } else diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilderCallback.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/DatasetHolder.java index 7e23953fdb..14fd50facc 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilderCallback.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/DatasetHolder.java @@ -20,11 +20,18 @@ package org.apache.qpid.disttest.charting.seriesbuilder; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.jfree.data.general.Dataset; -public interface SeriesBuilderCallback +/** + * Accepts data in the form of {@link SeriesDefinition}s and {@link SeriesRow}s, + * and returns it as a {@link Dataset} for use by a JFreeChart chart. + */ +public interface DatasetHolder { - public void beginSeries(SeriesDefinition seriesDefinition); - public void addDataPointToSeries(SeriesDefinition seriesDefinition, Object[] row); - public void endSeries(SeriesDefinition seriesDefinition); + int getNumberOfDimensions(); + void beginSeries(SeriesDefinition seriesDefinition); + void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row); + void endSeries(SeriesDefinition seriesDefinition); + Dataset getPopulatedDataset(); } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcCsvSeriesBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java index a9adce0afc..180aa54c6d 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcCsvSeriesBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java @@ -19,7 +19,6 @@ */ package org.apache.qpid.disttest.charting.seriesbuilder; -import java.io.File; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -28,33 +27,52 @@ import java.sql.Statement; import java.util.Iterator; import java.util.List; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; import org.apache.qpid.disttest.charting.ChartingException; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.jfree.data.general.Dataset; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class JdbcCsvSeriesBuilder implements SeriesBuilder +/** + * A {@link SeriesBuilder} that uses JDBC to read series data. + * The actual JDBC URL used is determined by my {@link JdbcUrlGenerator}. + */ +public class JdbcSeriesBuilder implements SeriesBuilder { + private static final Logger LOGGER = LoggerFactory.getLogger(JdbcSeriesBuilder.class); + + private DatasetHolder _datasetHolder; - static + private final JdbcUrlGenerator _jdbcUrlGenerator; + + /** + * @param providedJdbcUrl the JDBC URL. Provide null if the value should be + * inferred by {@link #_jdbcUrlGenerator}. + */ + public JdbcSeriesBuilder(String jdbcDriverClass, String providedJdbcUrl) { - registerCsvDriver(); + registerDriver(jdbcDriverClass); + _jdbcUrlGenerator = new JdbcUrlGenerator(providedJdbcUrl); + LOGGER.info("Created: " + this); } - private SeriesBuilderCallback _callback; - @Override - public void setSeriesBuilderCallback(SeriesBuilderCallback callback) + public void setDatasetHolder(DatasetHolder callback) { - this._callback = callback; + _datasetHolder = callback; } @Override - public void build(List<SeriesDefinition> seriesDefinitions) + public Dataset build(List<SeriesDefinition> seriesDefinitions) { for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext();) { SeriesDefinition series = iterator.next(); buildDataSetForSingleSeries(series); } + return _datasetHolder.getPopulatedDataset(); } private void buildDataSetForSingleSeries(SeriesDefinition seriesDefinition) @@ -63,16 +81,15 @@ public class JdbcCsvSeriesBuilder implements SeriesBuilder Statement stmt = null; try { - File seriesDir = getValidatedSeriesDirectory(seriesDefinition); - - conn = DriverManager.getConnection("jdbc:relique:csv:" + seriesDir.getAbsolutePath()); + String jdbcUrl = _jdbcUrlGenerator.getJdbcUrl(seriesDefinition); + conn = DriverManager.getConnection(jdbcUrl); final String seriesStatement = seriesDefinition.getSeriesStatement(); stmt = conn.createStatement(); ResultSet results = stmt.executeQuery(seriesStatement); int columnCount = results.getMetaData().getColumnCount(); - _callback.beginSeries(seriesDefinition); + _datasetHolder.beginSeries(seriesDefinition); while (results.next()) { Object[] row = new Object[columnCount]; @@ -81,9 +98,10 @@ public class JdbcCsvSeriesBuilder implements SeriesBuilder row[i] = results.getObject(i+1); } - _callback.addDataPointToSeries(seriesDefinition, row); + SeriesRow seriesRow = SeriesRow.createValidSeriesRow(_datasetHolder.getNumberOfDimensions(), row); + _datasetHolder.addDataPointToSeries(seriesDefinition, seriesRow); } - _callback.endSeries(seriesDefinition); + _datasetHolder.endSeries(seriesDefinition); } catch (SQLException e) { @@ -116,26 +134,24 @@ public class JdbcCsvSeriesBuilder implements SeriesBuilder } } - private File getValidatedSeriesDirectory(SeriesDefinition series) - { - File seriesDir = new File(series.getSeriesDirectory()); - if (!seriesDir.isDirectory()) - { - throw new ChartingException("seriesDirectory must be a directory : " + seriesDir); - } - return seriesDir; - } - - private static void registerCsvDriver() throws ExceptionInInitializerError + private void registerDriver(String driverClassName) throws ExceptionInInitializerError { try { - Class.forName("org.relique.jdbc.csv.CsvDriver"); + Class.forName(driverClassName); + LOGGER.info("Loaded JDBC driver class " + driverClassName); } catch (ClassNotFoundException e) { - throw new RuntimeException("Could not load CSV/JDBC driver", e); + throw new RuntimeException("Could not load JDBC driver " + driverClassName, e); } } + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("jdbcUrlGenerator", _jdbcUrlGenerator) + .toString(); + } } diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java new file mode 100644 index 0000000000..77f367b0f1 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java @@ -0,0 +1,81 @@ +/* + * 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.disttest.charting.seriesbuilder; + +import static org.apache.commons.lang.StringUtils.isBlank; +import static org.apache.commons.lang.StringUtils.isNotBlank; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; + +public class JdbcUrlGenerator +{ + private String _providedJdbdUrl; + + public static final String DEFAULT_JDBC_DRIVER_NAME = "org.relique.jdbc.csv.CsvDriver"; + + /** + * Used to create the JDBC URL if one has not been passed in. + */ + private static final String CSV_JDBC_URL_BASE = "jdbc:relique:csv:"; + + /** + * @param providedJdbcUrl the JDBC URL. Provide null if the value should be + * inferred. + */ + public JdbcUrlGenerator(String providedJdbcUrl) + { + _providedJdbdUrl = providedJdbcUrl; + } + + /** + * Returns either the provided value ({@link #_providedJdbdUrl}) + * or a CSV JDBC URL pointing at {@link SeriesDefinition#getSeriesDirectory()} value. + */ + public String getJdbcUrl(SeriesDefinition seriesDefinition) + { + String seriesDir = seriesDefinition.getSeriesDirectory(); + + if(_providedJdbdUrl == null) + { + if(isBlank(seriesDir)) + { + throw new IllegalArgumentException("Neither a series directory nor a JDBC url have been specified. Series definition: " + seriesDefinition); + } + return CSV_JDBC_URL_BASE + seriesDir; + } + else + { + if(isNotBlank(seriesDir)) + { + throw new IllegalArgumentException("Both a series directory '" + seriesDir + "' and a JDBC url have been specified. Series definition: " + seriesDefinition); + } + return _providedJdbdUrl; + } + } + + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("providedJdbdUrl", _providedJdbdUrl) + .toString(); + } +}
\ No newline at end of file diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java index 86e471efaf..a865c838c6 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java @@ -22,11 +22,20 @@ package org.apache.qpid.disttest.charting.seriesbuilder; import java.util.List; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.jfree.data.general.Dataset; public interface SeriesBuilder { - void build(List<SeriesDefinition> seriesDefinitions); - - void setSeriesBuilderCallback(SeriesBuilderCallback seriesBuilderCallback); + /** + * Uses the supplied {@link SeriesDefinition}s to read the series data + * and pass it to the dataset holder set up in {@link #setDatasetHolder(DatasetHolder)}. + * + * @return the populated dataset + */ + Dataset build(List<SeriesDefinition> seriesDefinitions); + /** + * Stores the supplied dataset holder so it can be populated in {@link #build(List)}. + */ + void setDatasetHolder(DatasetHolder datasetHolder); }
\ No newline at end of file diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRow.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRow.java new file mode 100644 index 0000000000..9c16866939 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRow.java @@ -0,0 +1,98 @@ +/* + * 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.disttest.charting.seriesbuilder; + +import java.util.Arrays; +import java.util.Date; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +/** + * A data point in a chart. Thinly wraps an array to provide a convenient place to validate the number of dimensions, + * and to access dimensions in a typesafe manner. + */ +public class SeriesRow +{ + private final Object[] _dimensions; + + public static SeriesRow createValidSeriesRow(int expectedNumberOfDimensions, Object[] dimensions) + { + int actualNumberOfDimensions = dimensions.length; + if(expectedNumberOfDimensions != actualNumberOfDimensions) + { + throw new IllegalArgumentException("Expected " + expectedNumberOfDimensions + + " dimensions but found " + actualNumberOfDimensions + + " in: " + Arrays.asList(dimensions)); + } + return new SeriesRow(dimensions); + } + + public SeriesRow(Object... dimensions) + { + _dimensions = dimensions; + } + + public Object dimension(int dimension) + { + return _dimensions[dimension]; + } + + public String dimensionAsString(int dimension) + { + return String.valueOf(dimension(dimension)); + } + + public double dimensionAsDouble(int dimension) + { + return Double.parseDouble(dimensionAsString(dimension)); + } + + public Date dimensionAsDate(int dimension) + { + return (Date) dimension(dimension); + } + + @Override + public int hashCode() + { + return new HashCodeBuilder().append(_dimensions).toHashCode(); + } + + @Override + public boolean equals(Object obj) + { + if (obj == null) + { + return false; + } + if (obj == this) + { + return true; + } + if (obj.getClass() != getClass()) + { + return false; + } + SeriesRow rhs = (SeriesRow) obj; + return new EqualsBuilder().append(_dimensions, rhs._dimensions).isEquals(); + } + + +}
\ No newline at end of file diff --git a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java index 5d4a9b6b7e..341f01ccd1 100644 --- a/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java +++ b/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java @@ -26,10 +26,11 @@ import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.SortedMap; +import java.util.TreeMap; import org.apache.qpid.disttest.charting.ChartingException; +import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.slf4j.Logger; @@ -42,19 +43,19 @@ public class ChartWriter static final String SUMMARY_FILE_NAME = "chart-summary.html"; private File _chartDirectory = new File("."); - private SortedSet<File> _chartFiles = new TreeSet<File>(); + private SortedMap<File,ChartingDefinition> _chartFilesToChartDef = new TreeMap<File, ChartingDefinition>(); - public void writeChartToFileSystem(JFreeChart chart, String chartStemName) + public void writeChartToFileSystem(JFreeChart chart, ChartingDefinition chartDef) { OutputStream pngOutputStream = null; try { - File pngFile = new File(_chartDirectory, chartStemName + ".png"); + File pngFile = new File(_chartDirectory, chartDef.getChartStemName() + ".png"); pngOutputStream = new BufferedOutputStream(new FileOutputStream(pngFile)); ChartUtilities.writeChartAsPNG(pngOutputStream, chart, 600, 400, true, 0); pngOutputStream.close(); - _chartFiles.add(pngFile); + _chartFilesToChartDef.put(pngFile, chartDef); LOGGER.info("Written {} chart", pngFile); } @@ -78,20 +79,21 @@ public class ChartWriter } } - public void writeHtmlSummaryToFileSystem() + public void writeHtmlSummaryToFileSystem(String summaryPageTitle) { - if(_chartFiles.size() < 2) + if(_chartFilesToChartDef.size() < 2) { - LOGGER.info("Only " + _chartFiles.size() + " chart image(s) have been written so no HTML summary file will be produced"); + LOGGER.info("Only {} chart image(s) have been written so no HTML summary file will be produced", _chartFilesToChartDef.size()); return; } - String htmlHeader = + String htmlHeader = String.format( "<html>\n" + " <head>\n" + - " <title>Performance Charts</title>\n" + + " <title>%s</title>\n" + + " <style type='text/css'>figure { float: left; display: table; width: 87px;}</style>\n" + " </head>\n" + - " <body>\n"; + " <body>\n", summaryPageTitle); String htmlFooter = " </body>\n" + @@ -101,22 +103,29 @@ public class ChartWriter try { File summaryFile = new File(_chartDirectory, SUMMARY_FILE_NAME); - LOGGER.debug("About to produce HTML summary file " + summaryFile.getAbsolutePath() + " from charts " + _chartFiles); + LOGGER.debug("About to produce HTML summary file " + summaryFile.getAbsolutePath() + " from charts " + _chartFilesToChartDef); writer = new BufferedWriter(new FileWriter(summaryFile)); writer.write(htmlHeader); writer.write(" <ul>\n"); - for (File chartFile : _chartFiles) + for (File chartFile : _chartFilesToChartDef.keySet()) { writer.write(" <li><a href='#"+ chartFile.getName() +"'>" + chartFile.getName() + "</a></li>\n"); } writer.write(" </ul>\n"); - for (File chartFile : _chartFiles) + for (File chartFile : _chartFilesToChartDef.keySet()) { - writer.write(" <a name='" + chartFile.getName() + "'/>\n"); - writer.write(" <img src='" + chartFile.getName() + "'/>\n"); + ChartingDefinition def = _chartFilesToChartDef.get(chartFile); + writer.write(" <figure>\n"); + writer.write(" <a name='" + chartFile.getName() + "'/>\n"); + writer.write(" <img src='" + chartFile.getName() + "'/>\n"); + if (def.getChartDescription() != null) + { + writer.write(" <figcaption>" + def.getChartDescription() + "</figcaption>\n"); + } + writer.write(" </figure>\n"); } writer.write(htmlFooter); writer.close(); @@ -144,5 +153,6 @@ public class ChartWriter public void setOutputDirectory(final File chartDirectory) { _chartDirectory = chartDirectory; + LOGGER.info("Set chart directory: {}", chartDirectory); } } diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilderTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilderTest.java new file mode 100644 index 0000000000..c8a98aafa0 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilderTest.java @@ -0,0 +1,125 @@ +/* + * 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.disttest.charting.chartbuilder; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; + +import org.apache.qpid.disttest.charting.definition.ChartingDefinition; +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.apache.qpid.test.utils.QpidTestCase; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.general.Dataset; + +public class BaseChartBuilderTest extends QpidTestCase +{ + private static final String CHART_TITLE = "CHART_TITLE"; + private static final String CHART_SUB_TITLE = "CHART_SUB_TITLE"; + private static final String X_TITLE = "X_TITLE"; + private static final String Y_TITLE = "Y_TITLE"; + + @SuppressWarnings("unchecked") + private List<SeriesDefinition> _seriesDefinitions = mock(List.class); + + private ChartingDefinition _chartingDefinition = mock(ChartingDefinition.class); + private SeriesStrokeAndPaintApplier _strokeAndPaintApplier = mock(SeriesStrokeAndPaintApplier.class); + private DatasetHolder _datasetHolder = mock(DatasetHolder.class); + private SeriesPainter _seriesPainter = mock(SeriesPainter.class); + + private SeriesBuilder _seriesBuilder = mock(SeriesBuilder.class); + + private JFreeChart _jFreeChart; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + Plot plot = new CategoryPlot(); + _jFreeChart = new JFreeChart(plot); + + when(_chartingDefinition.getChartTitle()).thenReturn(CHART_TITLE); + when(_chartingDefinition.getChartSubtitle()).thenReturn(CHART_SUB_TITLE); + when(_chartingDefinition.getXAxisTitle()).thenReturn(X_TITLE); + when(_chartingDefinition.getYAxisTitle()).thenReturn(Y_TITLE); + when(_chartingDefinition.getSeriesDefinitions()).thenReturn(_seriesDefinitions ); + } + + public void testBuildChart() + { + BaseChartBuilder chartBuilder = new ChartBuilder(_seriesBuilder, _strokeAndPaintApplier, _datasetHolder) + { + @Override + protected JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) + { + assertEquals(CHART_TITLE, title); + assertEquals(X_TITLE, xAxisTitle); + assertEquals(Y_TITLE, yAxisTitle); + + return _jFreeChart; + } + }; + + JFreeChart chart = chartBuilder.buildChart(_chartingDefinition); + + assertEquals(BaseChartBuilder.BLUE_GRADIENT, chart.getBackgroundPaint()); + assertEquals("The *second* subtitle of the generated chart should have the text from the chart definition", + CHART_SUB_TITLE, ((TextTitle)chart.getSubtitle(1)).getText()); + verify(_seriesPainter).applySeriesAppearance(_jFreeChart, _seriesDefinitions, _strokeAndPaintApplier); + } + + /** + * Extends BaseChartBuilder to allow us to plug in in mock dependencies + */ + private abstract class ChartBuilder extends BaseChartBuilder + { + private SeriesStrokeAndPaintApplier _seriesStrokeAndPaintApplier; + private DatasetHolder _datasetHolder; + + private ChartBuilder(SeriesBuilder seriesBuilder, SeriesStrokeAndPaintApplier seriesStrokeAndPaintApplier, DatasetHolder datasetHolder) + { + super(seriesBuilder); + _seriesStrokeAndPaintApplier = seriesStrokeAndPaintApplier; + _datasetHolder = datasetHolder; + setSeriesPainter(_seriesPainter); + } + + @Override + protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() + { + return _seriesStrokeAndPaintApplier; + } + + @Override + protected DatasetHolder newDatasetHolder() + { + return _datasetHolder; + } + } +} diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java index e735fb58c6..14f81566a6 100644 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java @@ -19,14 +19,13 @@ */ package org.apache.qpid.disttest.charting.chartbuilder; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; import org.apache.qpid.disttest.charting.ChartType; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.apache.qpid.test.utils.QpidTestCase; -import junit.framework.TestCase; - -public class ChartBuilderFactoryTest extends TestCase +public class ChartBuilderFactoryTest extends QpidTestCase { private SeriesBuilder _seriesBuilder = mock(SeriesBuilder.class); @@ -59,4 +58,10 @@ public class ChartBuilderFactoryTest extends TestCase ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.XYLINE, _seriesBuilder); assertTrue(builder instanceof XYLineChartBuilder); } + + public void testTimeSeriesLineChart() + { + ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.TIMELINE, _seriesBuilder); + assertTrue(builder instanceof TimeSeriesLineChartBuilder); + } } diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java index 2744e17404..7af3a6b35e 100644 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java @@ -19,33 +19,35 @@ */ package org.apache.qpid.disttest.charting.chartbuilder; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.io.File; import java.util.Collections; +import java.util.Date; import java.util.Iterator; import java.util.List; import org.apache.qpid.disttest.charting.ChartType; import org.apache.qpid.disttest.charting.definition.ChartingDefinition; import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilderCallback; +import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; import org.apache.qpid.disttest.charting.writer.ChartWriter; +import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.test.utils.TestFileUtils; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.title.ShortTextTitle; - -import junit.framework.TestCase; +import org.jfree.data.general.Dataset; /** * Tests the production of the different chart types. To manually * verify the generated output, set the system property {@link #RETAIN_TEST_CHARTS} * to prevent the automatic deletion of the test chart directory. - * */ -public class ChartProductionTest extends TestCase +public class ChartProductionTest extends QpidTestCase { private static final String TEST_CHARTTITLE = "TEST_CHARTTITLE"; private static final String TEST_CHARTSUBTITLE = "TEST_CHARTSUBTITLE"; @@ -54,6 +56,16 @@ public class ChartProductionTest extends TestCase private static final String TEST_SERIESLEGEND = "TEST_SERIESLEGEND"; + private static final SeriesRow[] SIMPLE_SERIES_ROWS = new SeriesRow[] + { + new SeriesRow(1d, 1d), + new SeriesRow(2d, 2d), + new SeriesRow(3d, 3d), + new SeriesRow(4d, 4d), + new SeriesRow(5d, 5d), + new SeriesRow(6d, 6d), + }; + private static final String RETAIN_TEST_CHARTS = "retainTestCharts"; private SeriesDefinition _seriesDefinition = mock(SeriesDefinition.class); @@ -66,12 +78,15 @@ public class ChartProductionTest extends TestCase super.setUp(); when(_seriesDefinition.getSeriesLegend()).thenReturn(TEST_SERIESLEGEND); + when(_seriesDefinition.getStrokeWidth()).thenReturn(null); + when(_seriesDefinition.getSeriesColourName()).thenReturn(null); + when(_chartingDefinition.getChartStemName()).thenReturn(getName()); when(_chartingDefinition.getChartTitle()).thenReturn(TEST_CHARTTITLE); when(_chartingDefinition.getChartSubtitle()).thenReturn(TEST_CHARTSUBTITLE); when(_chartingDefinition.getXAxisTitle()).thenReturn(TEST_XAXIS); when(_chartingDefinition.getYAxisTitle()).thenReturn(TEST_YAXIS); - when(_chartingDefinition.getSeries()).thenReturn(Collections.singletonList(_seriesDefinition)); + when(_chartingDefinition.getSeriesDefinitions()).thenReturn(Collections.singletonList(_seriesDefinition)); File chartDir = TestFileUtils.createTestDirectory("charts", false); if (!System.getProperties().containsKey(RETAIN_TEST_CHARTS)) @@ -88,7 +103,7 @@ public class ChartProductionTest extends TestCase public void testBarChart() throws Exception { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR, new SampleSeriesBuilder()); + ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR, new SampleSeriesBuilder(SIMPLE_SERIES_ROWS)); assertChartTitlesAndWriteToFile(builder); } @@ -116,36 +131,47 @@ public class ChartProductionTest extends TestCase assertChartTitlesAndWriteToFile(builder); } - public void testStatiscticalBarChart() throws Exception + public void testXYLineChartWithColourAndWidth() throws Exception + { + when(_seriesDefinition.getStrokeWidth()).thenReturn(3); + when(_seriesDefinition.getSeriesColourName()).thenReturn("dark_orange"); + + ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.XYLINE, new SampleSeriesBuilder()); + assertChartTitlesAndWriteToFile(builder); + } + + public void testTimeSeriesLineChart() throws Exception { + SeriesRow[] timelineSeriesRows = new SeriesRow[] + { + new SeriesRow(new Date(1), 1d), + new SeriesRow(new Date(2), 2d), + new SeriesRow(new Date(3), 3d), + new SeriesRow(new Date(4), 4d), + new SeriesRow(new Date(5), 5d), + new SeriesRow(new Date(6), 6d), + }; + ChartBuilder builder = ChartBuilderFactory.createChartBuilder( + ChartType.TIMELINE, + new SampleSeriesBuilder(timelineSeriesRows)); + + assertChartTitlesAndWriteToFile(builder); + } + + public void testStatisticalBarChart() throws Exception + { + SeriesRow[] statisticalSeriesRows = new SeriesRow[] + { + new SeriesRow(1d, 1d, 0.5d), + new SeriesRow(2d, 2d, 0.4d), + new SeriesRow(4d, 4d, 0.3d), + new SeriesRow(5d, 5d, 0.2d), + new SeriesRow(6d, 6d, 0.1d) + }; + ChartBuilder builder = ChartBuilderFactory.createChartBuilder( ChartType.STATISTICAL_BAR, - new SeriesBuilder() - { - private SeriesBuilderCallback _dataPointCallback; - - @Override - public void build(List<SeriesDefinition> seriesDefinitions) - { - for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext();) - { - SeriesDefinition seriesDefinition = iterator.next(); - _dataPointCallback.beginSeries(seriesDefinition); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{1d, 1d, 0.5d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{2d, 2d, 0.4d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{4d, 4d, 0.3d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{5d, 5d, 0.2d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{6d, 3d, 0.1d}); - _dataPointCallback.endSeries(seriesDefinition); - } - } - - @Override - public void setSeriesBuilderCallback(SeriesBuilderCallback dataPointCallback) - { - _dataPointCallback = dataPointCallback; - } - }); + new SampleSeriesBuilder(statisticalSeriesRows)); assertChartTitlesAndWriteToFile(builder); } @@ -166,33 +192,43 @@ public class ChartProductionTest extends TestCase assertEquals(1, chart.getCategoryPlot().getDatasetCount()); } - _writer.writeChartToFileSystem(chart, getName()); + _writer.writeChartToFileSystem(chart, _chartingDefinition); } private class SampleSeriesBuilder implements SeriesBuilder { - private SeriesBuilderCallback _dataPointCallback; + private DatasetHolder _datasetHolder; + private SeriesRow[] _sampleSeriesRows = SIMPLE_SERIES_ROWS; + + public SampleSeriesBuilder() + { + } + + public SampleSeriesBuilder(SeriesRow[] sampleSeriesRows) + { + _sampleSeriesRows = sampleSeriesRows; + } @Override - public void build(List<SeriesDefinition> seriesDefinitions) + public Dataset build(List<SeriesDefinition> seriesDefinitions) { for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext();) { SeriesDefinition seriesDefinition = iterator.next(); - _dataPointCallback.beginSeries(seriesDefinition); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{1d, 1d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{2d, 2d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{4d, 4d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{5d, 5d}); - _dataPointCallback.addDataPointToSeries(seriesDefinition, new Object[]{6d, 3d}); - _dataPointCallback.endSeries(seriesDefinition); + _datasetHolder.beginSeries(seriesDefinition); + for(SeriesRow seriesRow : _sampleSeriesRows) + { + _datasetHolder.addDataPointToSeries(seriesDefinition, seriesRow); + } + _datasetHolder.endSeries(seriesDefinition); } + return _datasetHolder.getPopulatedDataset(); } @Override - public void setSeriesBuilderCallback(SeriesBuilderCallback dataPointCallback) + public void setDatasetHolder(DatasetHolder dataPointCallback) { - _dataPointCallback = dataPointCallback; + _datasetHolder = dataPointCallback; } } } diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactoryTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactoryTest.java new file mode 100644 index 0000000000..2656c780bb --- /dev/null +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactoryTest.java @@ -0,0 +1,42 @@ +/* + * 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.disttest.charting.chartbuilder; + +import java.awt.Color; + +import org.apache.qpid.test.utils.QpidTestCase; + +public class ColorFactoryTest extends QpidTestCase +{ + public void testBlue() + { + assertEquals(Color.blue, ColorFactory.toColour("blue")); + assertEquals(Color.blue, ColorFactory.toColour("BLUE")); + assertEquals(Color.blue, ColorFactory.toColour("Blue")); + } + + public void testDarkBlue() + { + assertEquals(Color.blue.darker(), ColorFactory.toColour("dark_blue")); + assertEquals(Color.blue.darker(), ColorFactory.toColour("DARK_BLUE")); + assertEquals(Color.blue.darker(), ColorFactory.toColour("Dark_Blue")); + } + +}
\ No newline at end of file diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesBuilderCallbackTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesBuilderCallbackTest.java new file mode 100644 index 0000000000..cb89511389 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesBuilderCallbackTest.java @@ -0,0 +1,72 @@ +package org.apache.qpid.disttest.charting.chartbuilder; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; +import org.apache.qpid.test.utils.QpidTestCase; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.time.TimeSeriesDataItem; + +public class TimeSeriesBuilderCallbackTest extends QpidTestCase +{ + private static final String SERIES_LEGEND = "mySeriesLegend"; + + private static final int NUMBER_OF_DATA_POINTS = 3; + + private Date[] _dates; + private double[] _values; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); + + calendar.set(2013, Calendar.JANUARY, 1); + Date jan1 = calendar.getTime(); + + calendar.set(2013, Calendar.JANUARY, 2); + Date jan2 = calendar.getTime(); + + calendar.set(2013, Calendar.JANUARY, 3); + Date jan3 = calendar.getTime(); + + _dates = new Date[] {jan1, jan2, jan3}; + _values = new double[] {2.0, 4.0, 8.0}; + } + + + public void testAddPointToSeries() + { + TimeSeriesHolder timeSeriesHolder = new TimeSeriesHolder(); + + SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); + when(seriesDefinition.getSeriesLegend()).thenReturn(SERIES_LEGEND); + + timeSeriesHolder.beginSeries(seriesDefinition); + + timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[0], _values[0])); + timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[1], _values[1])); + timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[2], _values[2])); + + timeSeriesHolder.endSeries(seriesDefinition); + + TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) timeSeriesHolder.getPopulatedDataset(); + + TimeSeries actualTimeSeries = timeSeriesCollection.getSeries(SERIES_LEGEND); + for(int i = 0; i < NUMBER_OF_DATA_POINTS; i++) + { + TimeSeriesDataItem dataItem0 = actualTimeSeries.getDataItem(i); + assertEquals(_dates[i].getTime(), dataItem0.getPeriod().getMiddleMillisecond()); + assertEquals(_values[i], dataItem0.getValue()); + } + } + +} diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java index 5371f3df45..e4b4d4d272 100644 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java @@ -19,8 +19,9 @@ */ package org.apache.qpid.disttest.charting.definition; -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_TITLE_KEY; +import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_DESCRIPTION_KEY; import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_SUBTITLE_KEY; +import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_TITLE_KEY; import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_TYPE_KEY; import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.XAXIS_TITLE_KEY; import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.YAXIS_TITLE_KEY; @@ -31,15 +32,15 @@ import java.io.FileWriter; import java.util.List; import java.util.Properties; -import junit.framework.TestCase; - import org.apache.qpid.disttest.charting.ChartType; import org.apache.qpid.disttest.charting.ChartingException; +import org.apache.qpid.test.utils.QpidTestCase; -public class ChartingDefinitionCreatorTest extends TestCase +public class ChartingDefinitionCreatorTest extends QpidTestCase { private static final String TEST_CHART_TITLE = "CHART_TITLE"; private static final String TEST_CHART_SUBTITLE = "CHART_SUBTITLE"; + private static final String TEST_CHART_DESCRIPTION = "CHART_DESCRIPTION"; private static final String TEST_XAXIS_TITLE = "XAXIS_TITLE"; private static final String TEST_YAXIS_TITLE = "YAXIS_TITLE"; private static final ChartType TEST_CHART_TYPE = ChartType.LINE; @@ -86,6 +87,7 @@ public class ChartingDefinitionCreatorTest extends TestCase ChartingDefinition definition1 = definitions.get(0); assertEquals(TEST_CHART_TITLE, definition1.getChartTitle()); assertEquals(TEST_CHART_SUBTITLE, definition1.getChartSubtitle()); + assertEquals(TEST_CHART_DESCRIPTION, definition1.getChartDescription()); assertEquals(TEST_XAXIS_TITLE, definition1.getXAxisTitle()); assertEquals(TEST_YAXIS_TITLE, definition1.getYAxisTitle()); assertEquals(TEST_CHART_TYPE, definition1.getChartType()); @@ -93,7 +95,7 @@ public class ChartingDefinitionCreatorTest extends TestCase String stemOnly = testDefFile.getName().replaceFirst("\\.chartdef", ""); assertEquals(stemOnly, definition1.getChartStemName()); - final List<SeriesDefinition> seriesDefinitions = definition1.getSeries(); + final List<SeriesDefinition> seriesDefinitions = definition1.getSeriesDefinitions(); assertEquals(1, seriesDefinitions.size()); SeriesDefinition seriesDefinition = seriesDefinitions.get(0); assertEquals(TEST_SERIES_SELECT_STATEMENT, seriesDefinition.getSeriesStatement()); @@ -125,6 +127,7 @@ public class ChartingDefinitionCreatorTest extends TestCase props.setProperty(CHART_TYPE_KEY, TEST_CHART_TYPE.name()); props.setProperty(CHART_TITLE_KEY, TEST_CHART_TITLE); props.setProperty(CHART_SUBTITLE_KEY, TEST_CHART_SUBTITLE); + props.setProperty(CHART_DESCRIPTION_KEY, TEST_CHART_DESCRIPTION); props.setProperty(XAXIS_TITLE_KEY, TEST_XAXIS_TITLE); props.setProperty(YAXIS_TITLE_KEY, TEST_YAXIS_TITLE); diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java index 2187793c53..ef605024cc 100644 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java @@ -19,20 +19,24 @@ */ package org.apache.qpid.disttest.charting.definition; +import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_COLOUR_NAME_FORMAT; import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_DIRECTORY_KEY_FORMAT; import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_LEGEND_KEY_FORMAT; import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_STATEMENT_KEY_FORMAT; +import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_STROKE_WIDTH_FORMAT; import java.util.List; import java.util.Properties; -import junit.framework.TestCase; +import org.apache.qpid.test.utils.QpidTestCase; -public class SeriesDefinitionCreatorTest extends TestCase +public class SeriesDefinitionCreatorTest extends QpidTestCase { private static final String TEST_SERIES_1_SELECT_STATEMENT = "SERIES_1_SELECT_STATEMENT"; private static final String TEST_SERIES_1_LEGEND = "SERIES_1_LEGEND"; private static final String TEST_SERIES_1_DIR = "SERIES_1_DIR"; + private static final String TEST_SERIES_1_COLOUR_NAME = "seriesColourName"; + private static final Integer TEST_SERIES_1_STROKE_WIDTH = 1;; private static final String TEST_SERIES_1_DIR_WITH_SYSPROP = "${java.io.tmpdir}/mydir"; @@ -52,7 +56,7 @@ public class SeriesDefinitionCreatorTest extends TestCase public void testOneSeriesDefinition() throws Exception { - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR); + createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR, TEST_SERIES_1_COLOUR_NAME, TEST_SERIES_1_STROKE_WIDTH); List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); assertEquals(1, definitions.size()); @@ -61,12 +65,14 @@ public class SeriesDefinitionCreatorTest extends TestCase assertEquals(TEST_SERIES_1_SELECT_STATEMENT, definition.getSeriesStatement()); assertEquals(TEST_SERIES_1_LEGEND, definition.getSeriesLegend()); assertEquals(TEST_SERIES_1_DIR, definition.getSeriesDirectory()); + assertEquals(TEST_SERIES_1_COLOUR_NAME, definition.getSeriesColourName()); + assertEquals(TEST_SERIES_1_STROKE_WIDTH, definition.getStrokeWidth()); } public void testTwoSeriesDefinitions() throws Exception { - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR); - createTestProperties(2, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR); + createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR, TEST_SERIES_1_COLOUR_NAME, TEST_SERIES_1_STROKE_WIDTH); + createTestProperties(2, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR, null, null); List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); assertEquals(2, definitions.size()); @@ -84,8 +90,8 @@ public class SeriesDefinitionCreatorTest extends TestCase public void testNonSequentialSeriesDefinitionsIgnored() throws Exception { - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR); - createTestProperties(3, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR); + createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR, TEST_SERIES_1_COLOUR_NAME, TEST_SERIES_1_STROKE_WIDTH); + createTestProperties(3, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR, null, null); List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); assertEquals(1, definitions.size()); @@ -94,7 +100,7 @@ public class SeriesDefinitionCreatorTest extends TestCase public void testSeriesDirectorySubstitution() throws Exception { final String tmpDir = System.getProperty("java.io.tmpdir"); - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR_WITH_SYSPROP); + createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR_WITH_SYSPROP, null, null); List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); assertEquals(1, definitions.size()); @@ -103,11 +109,19 @@ public class SeriesDefinitionCreatorTest extends TestCase assertTrue(seriesDefinition1.getSeriesDirectory().startsWith(tmpDir)); } - private void createTestProperties(int index, String selectStatement, String seriesLegend, String seriesDir) throws Exception + private void createTestProperties(int index, String selectStatement, String seriesLegend, String seriesDir, String seriesColourName, Integer seriesStrokeWidth) throws Exception { _properties.setProperty(String.format(SERIES_STATEMENT_KEY_FORMAT, index), selectStatement); _properties.setProperty(String.format(SERIES_LEGEND_KEY_FORMAT, index), seriesLegend); _properties.setProperty(String.format(SERIES_DIRECTORY_KEY_FORMAT, index), seriesDir); + if (seriesColourName != null) + { + _properties.setProperty(String.format(SERIES_COLOUR_NAME_FORMAT, index), seriesColourName); + } + if (seriesStrokeWidth != null) + { + _properties.setProperty(String.format(SERIES_STROKE_WIDTH_FORMAT, index), seriesStrokeWidth.toString()); + } } } diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcCsvSeriesBuilderTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilderTest.java index 5148a25bec..b6b4dbe56b 100644 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcCsvSeriesBuilderTest.java +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilderTest.java @@ -21,6 +21,7 @@ package org.apache.qpid.disttest.charting.seriesbuilder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.BufferedWriter; import java.io.File; @@ -28,18 +29,17 @@ import java.io.FileWriter; import java.io.PrintWriter; import java.util.Collections; -import junit.framework.TestCase; - import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.JdbcCsvSeriesBuilder; +import org.apache.qpid.test.utils.QpidTestCase; -public class JdbcCsvSeriesBuilderTest extends TestCase +public class JdbcSeriesBuilderTest extends QpidTestCase { private static final String TEST_SERIES_1_SELECT_STATEMENT = "SELECT A, B FROM test"; private static final String TEST_SERIES_1_LEGEND = "SERIES_1_LEGEND"; + private static final String TEST_SERIES1_COLOUR_NAME = "blue"; + private static final Integer TEST_SERIES1_STROKE_WIDTH = 3; - private SeriesBuilderCallback _seriesWalkerCallback = mock(SeriesBuilderCallback.class); - private JdbcCsvSeriesBuilder _seriesBuilder = new JdbcCsvSeriesBuilder(); + private DatasetHolder _seriesWalkerCallback = mock(DatasetHolder.class); private File _testTempDir; @@ -47,21 +47,25 @@ public class JdbcCsvSeriesBuilderTest extends TestCase protected void setUp() throws Exception { super.setUp(); - _seriesBuilder.setSeriesBuilderCallback(_seriesWalkerCallback); + when(_seriesWalkerCallback.getNumberOfDimensions()).thenReturn(2); _testTempDir = createTestTemporaryDirectory(); + createTestCsvIn(_testTempDir); } public void testBuildOneSeries() throws Exception { - createTestCsvIn(_testTempDir); SeriesDefinition seriesDefinition = createTestSeriesDefinition(); - _seriesBuilder.build(Collections.singletonList(seriesDefinition)); + JdbcSeriesBuilder seriesBuilder = new JdbcSeriesBuilder("org.relique.jdbc.csv.CsvDriver", null); + + seriesBuilder.setDatasetHolder(_seriesWalkerCallback); + + seriesBuilder.build(Collections.singletonList(seriesDefinition)); verify(_seriesWalkerCallback).beginSeries(seriesDefinition); - verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new Object[]{"elephant", "2"}); - verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new Object[]{"lion", "3"}); - verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new Object[]{"tiger", "4"}); + verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("elephant", "2")); + verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("lion", "3")); + verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("tiger", "4")); verify(_seriesWalkerCallback).endSeries(seriesDefinition); } @@ -79,7 +83,12 @@ public class JdbcCsvSeriesBuilderTest extends TestCase private SeriesDefinition createTestSeriesDefinition() { - SeriesDefinition definition = new SeriesDefinition(TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, _testTempDir.getAbsolutePath()); + SeriesDefinition definition = new SeriesDefinition( + TEST_SERIES_1_SELECT_STATEMENT, + TEST_SERIES_1_LEGEND, + _testTempDir.getAbsolutePath(), + TEST_SERIES1_COLOUR_NAME, + TEST_SERIES1_STROKE_WIDTH); return definition; } diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGeneratorTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGeneratorTest.java new file mode 100644 index 0000000000..d53d0ccfe1 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGeneratorTest.java @@ -0,0 +1,85 @@ +/* + * 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.disttest.charting.seriesbuilder; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.qpid.disttest.charting.definition.SeriesDefinition; +import org.apache.qpid.test.utils.QpidTestCase; + +public class JdbcUrlGeneratorTest extends QpidTestCase +{ + public void testGetJdbcUrlWithoutProvidingAUrlReturnsCsvUrlWithCorrectDirectory() + { + JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(null); + SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); + when(seriesDefinition.getSeriesDirectory()).thenReturn("mydir"); + + String jdbcUrl = jdbcUrlGenerator.getJdbcUrl(seriesDefinition); + + assertEquals("jdbc:relique:csv:mydir", jdbcUrl); + } + + public void testGetJdbcUrlReturnsProvidedUrl() + { + String urlTemplate = "urlTemplate"; + JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(urlTemplate); + SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); + + String jdbcUrl = jdbcUrlGenerator.getJdbcUrl(seriesDefinition); + + assertEquals(urlTemplate, jdbcUrl); + } + + public void testGetJdbcUrlThrowsExceptionIfUrlProvidedAndSeriesDirectorySpecified() + { + String urlTemplate = "urlTemplate"; + JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(urlTemplate); + SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); + when(seriesDefinition.getSeriesDirectory()).thenReturn("mydir"); + + try + { + jdbcUrlGenerator.getJdbcUrl(seriesDefinition); + fail("Expected exception not thrown"); + } + catch (IllegalArgumentException e) + { + // pass + } + } + + public void testGetJdbcUrlThrowsExceptionWithoutAProvidedUrlOrSeriesDirectory() + { + JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(null); + SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); + when(seriesDefinition.getSeriesDirectory()).thenReturn(null); + + try + { + jdbcUrlGenerator.getJdbcUrl(seriesDefinition); + fail("Expected exception not thrown"); + } + catch (IllegalArgumentException e) + { + // pass + } + } +} diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRowTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRowTest.java new file mode 100644 index 0000000000..064971aa35 --- /dev/null +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRowTest.java @@ -0,0 +1,64 @@ +/* + * 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.disttest.charting.seriesbuilder; + +import org.apache.qpid.test.utils.QpidTestCase; + +public class SeriesRowTest extends QpidTestCase +{ + private static final Integer[] PAIR = new Integer[] {10, 11}; + + public void testValidSeriesRow() + { + assertEquals(11, SeriesRow.createValidSeriesRow(2, PAIR).dimension(1)); + } + + public void testValidSeriesRowThrowsExceptionIfArrayTooSmall() + { + try + { + SeriesRow.createValidSeriesRow(1, PAIR); + fail("Expected exception not thrown"); + } + catch(IllegalArgumentException e) + { + // pass + } + } + + public void testDimension() + { + SeriesRow seriesRow = new SeriesRow(10, 11); + assertEquals(10, seriesRow.dimension(0)); + assertEquals(11, seriesRow.dimension(1)); + } + + public void testDimensionAsString() + { + SeriesRow seriesRow = new SeriesRow(10); + assertEquals("10", seriesRow.dimensionAsString(0)); + } + + public void testDimensionAsDouble() + { + SeriesRow seriesRow = new SeriesRow(10.1); + assertEquals(10.1, seriesRow.dimensionAsDouble(0), 0.0); + } + +} diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java index 0e176d326b..9703c66e1f 100644 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java @@ -20,20 +20,23 @@ */ package org.apache.qpid.disttest.charting.writer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.File; import java.io.FileWriter; import java.io.InputStream; import java.util.Scanner; -import junit.framework.TestCase; - +import org.apache.qpid.disttest.charting.definition.ChartingDefinition; +import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.test.utils.TestFileUtils; import org.apache.qpid.util.FileUtils; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.data.general.DefaultPieDataset; -public class ChartWriterTest extends TestCase +public class ChartWriterTest extends QpidTestCase { private JFreeChart _chart1; private JFreeChart _chart2; @@ -59,24 +62,34 @@ public class ChartWriterTest extends TestCase public void testWriteChartToFileSystem() { + ChartingDefinition chartDef1 = mock(ChartingDefinition.class); + when(chartDef1.getChartStemName()).thenReturn("chart1"); + File chart1File = new File(_chartDir, "chart1.png"); assertFalse("chart1 png should not exist yet", chart1File.exists()); - _writer.writeChartToFileSystem(_chart1, "chart1"); + _writer.writeChartToFileSystem(_chart1, chartDef1); assertTrue("chart1 png does not exist", chart1File.exists()); } public void testWriteHtmlSummaryToFileSystemOverwritingExistingFile() throws Exception { + ChartingDefinition chartDef1 = mock(ChartingDefinition.class); + when(chartDef1.getChartStemName()).thenReturn("chart1"); + when(chartDef1.getChartDescription()).thenReturn("chart description1"); + + ChartingDefinition chartDef2 = mock(ChartingDefinition.class); + when(chartDef2.getChartStemName()).thenReturn("chart2"); + File summaryFile = new File(_chartDir, ChartWriter.SUMMARY_FILE_NAME); writeDummyContentToSummaryFileToEnsureItGetsOverwritten(summaryFile); - _writer.writeChartToFileSystem(_chart2, "chart2"); - _writer.writeChartToFileSystem(_chart1, "chart1"); + _writer.writeChartToFileSystem(_chart2, chartDef2); + _writer.writeChartToFileSystem(_chart1, chartDef1); - _writer.writeHtmlSummaryToFileSystem(); + _writer.writeHtmlSummaryToFileSystem("Performance Charts"); InputStream expectedSummaryFileInputStream = getClass().getResourceAsStream("expected-chart-summary.html"); String expectedSummaryContent = new Scanner(expectedSummaryFileInputStream).useDelimiter("\\A").next(); @@ -87,11 +100,15 @@ public class ChartWriterTest extends TestCase public void testWriteHtmlSummaryToFileSystemDoesNothingIfLessThanTwoCharts() { + ChartingDefinition chartDef1 = mock(ChartingDefinition.class); + when(chartDef1.getChartStemName()).thenReturn("chart1"); + when(chartDef1.getChartDescription()).thenReturn("chart description1"); + File summaryFile = new File(_chartDir, ChartWriter.SUMMARY_FILE_NAME); - _writer.writeChartToFileSystem(_chart1, "chart1"); + _writer.writeChartToFileSystem(_chart1, chartDef1); - _writer.writeHtmlSummaryToFileSystem(); + _writer.writeHtmlSummaryToFileSystem("Performance Charts"); assertFalse("Only one chart generated so no summary file should have been written", summaryFile.exists()); diff --git a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html index 89c508a77e..e7dadcb05b 100755 --- a/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html +++ b/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html @@ -1,15 +1,21 @@ <html> <head> <title>Performance Charts</title> + <style type='text/css'>figure { float: left; display: table; width: 87px;}</style> </head> <body> <ul> <li><a href='#chart1.png'>chart1.png</a></li> <li><a href='#chart2.png'>chart2.png</a></li> </ul> - <a name='chart1.png'/> - <img src='chart1.png'/> - <a name='chart2.png'/> - <img src='chart2.png'/> + <figure> + <a name='chart1.png'/> + <img src='chart1.png'/> + <figcaption>chart description1</figcaption> + </figure> + <figure> + <a name='chart2.png'/> + <img src='chart2.png'/> + </figure> </body> </html>
\ No newline at end of file |