Author: gordonsim
Date: 2007-09-07 06:27:55 -0400 (Fri, 07 Sep 2007)
New Revision: 912
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/tests/persistence.py
Log:
Fixes to get tests working again:
- on store buffer needs to be sized for the full message, not just the header
- change for XA_OK value
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-06 13:10:59 UTC (rev 911)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-07 10:27:55 UTC (rev 912)
@@ -613,13 +613,14 @@
void BdbMessageStore::store(DbTxn* txn, Dbt& messageId, PersistableMessage&
message)
{
u_int32_t headerSize = message.encodedHeaderSize();
- char* buff = static_cast<char*>(::alloca(headerSize + sizeof(u_int32_t)/*header
length*/));
+ u_int32_t totalSize = message.encodedSize();
+ char* buff = static_cast<char*>(::alloca(totalSize + sizeof(u_int32_t)/*header
length*/));
Buffer buffer(buff, headerSize + sizeof(u_int32_t));
buffer.putLong(headerSize);
message.encode(buffer);
//buffer.flip();
- Dbt data(buff, headerSize + sizeof(u_int32_t));
+ Dbt data(buff, totalSize + sizeof(u_int32_t));
try {
/// cct message db
Modified: store/trunk/cpp/tests/persistence.py
===================================================================
--- store/trunk/cpp/tests/persistence.py 2007-09-06 13:10:59 UTC (rev 911)
+++ store/trunk/cpp/tests/persistence.py 2007-09-07 10:27:55 UTC (rev 912)
@@ -30,6 +30,10 @@
class PersistenceTest(qpid.testlib.TestBase):
+ XA_RBROLLBACK = 1
+ XA_RBTIMEOUT = 2
+ XA_OK = 0
+
def phase1(self):
channel = self.channel
@@ -190,10 +194,10 @@
for q in queues:
self.assertEqual(0, channel.queue_query(queue=q).message_count, "Bad
count for %s" % (q))
- self.assertEqual(8, channel.dtx_coordination_commit(xid=txa,
one_phase=True).status)
- self.assertEqual(8, channel.dtx_coordination_rollback(xid=txb).status)
- self.assertEqual(8, channel.dtx_coordination_prepare(xid=txc).status)
- self.assertEqual(8, channel.dtx_coordination_prepare(xid=txd).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_commit(xid=txa,
one_phase=True).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_rollback(xid=txb).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_prepare(xid=txc).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_prepare(xid=txd).status)
#further checks
not_empty = ["queue-a2", "queue-b1"]
@@ -243,8 +247,8 @@
self.assertEqual(0, channel.queue_query(queue=q).message_count, "Bad
count for %s" % (q))
#complete the prepared transactions
- self.assertEqual(8, channel.dtx_coordination_commit(xid=txc).status)
- self.assertEqual(8, channel.dtx_coordination_rollback(xid=txd).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_commit(xid=txc).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_rollback(xid=txd).status)
not_empty.append("queue-c2")
not_empty.append("queue-d1")
@@ -259,13 +263,13 @@
return pack('LBB', 0, len(txid), len(branchqual)) + txid + branchqual
def txswap(self, src, dest, tx):
- self.assertEqual(8, self.channel.dtx_demarcation_start(xid=tx).status)
+ self.assertEqual(self.XA_OK, self.channel.dtx_demarcation_start(xid=tx).status)
self.channel.message_get(destination="temp-swap", queue=src)
msg = self.client.queue("temp-swap").get(timeout=1)
self.channel.message_transfer(content=Content(properties={'routing_key':dest,
'message_id':msg.content['message_id'], 'delivery_mode':2},
body=msg.content.body))
msg.complete();
- self.assertEqual(8, self.channel.dtx_demarcation_end(xid=tx).status)
+ self.assertEqual(self.XA_OK, self.channel.dtx_demarcation_end(xid=tx).status)
def assertEmptyQueue(self, name):
self.assertEqual(0, self.channel.queue_query(queue=name).message_count)