summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/perftest.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-12-14 19:33:48 +0000
committerAlan Conway <aconway@apache.org>2007-12-14 19:33:48 +0000
commit2ee74442edb38a7b2bd400f098de78f820249f87 (patch)
tree5326606517e548b72c719517a646e2cbc2eea5c1 /qpid/cpp/src/tests/perftest.cpp
parent56b5b5df1b49ed1cdc5460a88b4ac613aaaeafca (diff)
downloadqpid-python-2ee74442edb38a7b2bd400f098de78f820249f87.tar.gz
Fix sequence numbers and sequence checks in perftest.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@604272 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/perftest.cpp')
-rw-r--r--qpid/cpp/src/tests/perftest.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/qpid/cpp/src/tests/perftest.cpp b/qpid/cpp/src/tests/perftest.cpp
index f844e9bb19..e15cb33164 100644
--- a/qpid/cpp/src/tests/perftest.cpp
+++ b/qpid/cpp/src/tests/perftest.cpp
@@ -383,8 +383,7 @@ struct PublishThread : public Client {
for (size_t i=0; i<opts.count; i++) {
// Stamp the iteration into the message data, avoid
// any heap allocation.
- char* data = const_cast<char*>(msg.getData().data());
- *reinterpret_cast<uint32_t*>(data) = i;
+ const_cast<std::string&>(msg.getData()).replace(0, sizeof(uint32_t), reinterpret_cast<const char*>(&i), sizeof(uint32_t));
completion = session.messageTransfer(
arg::destination=destination,
arg::content=msg,
@@ -425,7 +424,17 @@ struct SubscribeThread : public Client {
arg::exchange=ex,
arg::routingKey=key);
}
-
+
+ void verify(bool cond, const char* test, uint32_t expect, uint32_t actual) {
+ if (!cond) {
+ Message error(
+ QPID_MSG("Sequence error: expected n" << test << expect << " but got " << actual),
+ "sub_done");
+ session.messageTransfer(arg::content=error);
+ throw Exception(error.getData());
+ }
+ }
+
void run() { // Subscribe
try {
SubscriptionManager subs(session);
@@ -439,29 +448,21 @@ struct SubscribeThread : public Client {
Message msg;
AbsTime start=now();
- size_t lastMsg=0;
+ size_t expect=0;
for (size_t i = 0; i < opts.subQuota; ++i) {
msg=lq.pop();
// TODO aconway 2007-11-23: check message order for.
- // multiple publishers. Need an array of counters,
+ // multiple publishers. Need an acorray of counters,
// one per publisher and a publisher ID in the
// message. Careful not to introduce a lot of overhead
// here, e.g. no std::map, std::string etc.
//
// For now verify order only for a single publisher.
+ size_t n = *reinterpret_cast<const uint32_t*>(msg.getData().data());
if (opts.pubs == 1) {
- char* data = const_cast<char*>(msg.getData().data());
- size_t n = *reinterpret_cast<uint32_t*>(data);
- if (n < lastMsg) {
- // Report to control.
- Message error(
- QPID_MSG("Out-of-sequence messages, expected n>="
- << lastMsg << " got " << n),
- "sub_done");
- session.messageTransfer(arg::content=error);
- return;
- }
- lastMsg=n;
+ if (opts.subs == 1 || opts.mode == FANOUT) verify(n==expect, "==", expect, n);
+ else verify(n>=expect, ">=", expect, n);
+ expect = n+1;
}
}
if (opts.ack !=0)