Author: kpvdr
Date: 2008-10-10 10:39:37 -0400 (Fri, 10 Oct 2008)
New Revision: 2617
Modified:
store/trunk/cpp/tests/jrnl/_st_basic.cpp
store/trunk/cpp/tests/jrnl/_ut_lfmgr.cpp
Log:
Fix for over-agressive _ut_lfmgr.random_tests which would occasionally fail because it
allowed too many inserted files to accumulate and exceeded the file handle limit. Also
added some additional basic tests for file overwrite - ie which test the journal after the
files have been completely overwritten.
Modified: store/trunk/cpp/tests/jrnl/_st_basic.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_basic.cpp 2008-10-10 13:29:27 UTC (rev 2616)
+++ store/trunk/cpp/tests/jrnl/_st_basic.cpp 2008-10-10 14:39:37 UTC (rev 2617)
@@ -396,6 +396,121 @@
cout << "ok" << endl;
}
+QPID_AUTO_TEST_CASE(file_cycle_block)
+{
+ string test_name = get_test_name(test_filename, "file_cycle_block");
+ try
+ {
+ string msg;
+
+ test_jrnl jc(test_name, test_dir, test_name);
+ jc.initialize(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
+
+ // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+ u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS *
JRNL_SBLK_SIZE,
+ LARGE_MSG_REC_SIZE_DBLKS)/2;
+ for (unsigned i=0; i<5; i++)
+ {
+ for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+ enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+ for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+ deq_msg(jc, m);
+ }
+ }
+ catch(const exception& e) { BOOST_FAIL(e.what()); }
+ cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(file_cycle_interleaved)
+{
+ string test_name = get_test_name(test_filename, "file_cycle_interleaved");
+ try
+ {
+ string msg;
+
+ test_jrnl jc(test_name, test_dir, test_name);
+ jc.initialize(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
+
+ // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+ u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS *
JRNL_SBLK_SIZE,
+ LARGE_MSG_REC_SIZE_DBLKS)/2;
+ for (unsigned m=0; m<5*2*t; m+=2)
+ {
+ enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+ deq_msg(jc, m);
+ }
+ }
+ catch(const exception& e) { BOOST_FAIL(e.what()); }
+ cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(recover_file_cycle_block)
+{
+ string test_name = get_test_name(test_filename,
"recover_file_cycle_block");
+ try
+ {
+ string msg;
+ u_int64_t hrid;
+
+ // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+ u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS *
JRNL_SBLK_SIZE,
+ LARGE_MSG_REC_SIZE_DBLKS)/2;
+ for (unsigned i=0; i<5; i++)
+ {
+ test_jrnl jc(test_name, test_dir, test_name);
+ if (i)
+ {
+ jc.recover(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS, 0, hrid);
+ BOOST_CHECK_EQUAL(hrid, u_int64_t(2*i*t - 1));
+ jc.recover_complete();
+ }
+ else
+ jc.initialize(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
+
+ for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+ enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+ for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+ deq_msg(jc, m);
+ }
+ }
+ catch(const exception& e) { BOOST_FAIL(e.what()); }
+ cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(recover_file_cycle_interleaved)
+{
+ string test_name = get_test_name(test_filename,
"recover_file_cycle_interleaved");
+ try
+ {
+ string msg;
+ u_int64_t hrid;
+
+ // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+ u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS *
JRNL_SBLK_SIZE,
+ LARGE_MSG_REC_SIZE_DBLKS)/2;
+ for (unsigned i=0; i<5; i++)
+ {
+ test_jrnl jc(test_name, test_dir, test_name);
+ if (i)
+ {
+ jc.recover(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS, 0, hrid);
+ BOOST_CHECK_EQUAL(hrid, u_int64_t(2*i*t - 1));
+ jc.recover_complete();
+ }
+ else
+ jc.initialize(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
+
+ for (unsigned m=2*i*t; m<2*(i+1)*t; m+=2)
+ {
+ enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+ deq_msg(jc, m);
+ }
+ }
+ }
+ catch(const exception& e) { BOOST_FAIL(e.what()); }
+ cout << "ok" << endl;
+}
+
QPID_AUTO_TEST_CASE(double_dequeue)
{
string test_name = get_test_name(test_filename, "double_dequeue");
Modified: store/trunk/cpp/tests/jrnl/_ut_lfmgr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_lfmgr.cpp 2008-10-10 13:29:27 UTC (rev 2616)
+++ store/trunk/cpp/tests/jrnl/_ut_lfmgr.cpp 2008-10-10 14:39:37 UTC (rev 2617)
@@ -617,7 +617,8 @@
test_jrnl jc(test_name, test_dir, test_name);
lfmgr lm;
- const bool recover_flag = test_num > 0 ? 2.0 * ::drand48() < 1.0 : false;
// 50% chance except first run
+ // 50% chance of recovery except first run and if >= 800 journal files
+ const bool recover_flag = test_num > 0 && m.size() < 800 ? 2.0 *
::drand48() < 1.0 : false;
if (recover_flag)
{
// Recover from previous iteration
@@ -630,14 +631,14 @@
else
{
// Initialize from scratch
- const u_int16_t num_jfiles = 4 + u_int16_t(96.0 * ::drand48()); // size: 4 -
100
+ const u_int16_t num_jfiles = 4 + u_int16_t(21.0 * ::drand48()); // size: 4 -
25 files
lm.initialize(num_jfiles, &jc, &jc.new_fcntl);
map_init(m, num_jfiles);
check_linear_fids_lids(lm, num_jfiles);
}
// Loop to insert fids
- const int num_inserts = 1 + int(m.size()/5.0 * ::drand48());
+ const int num_inserts = 1 + int(m.size()/10.0 * ::drand48());
for (int i = 0; i < num_inserts; i++)
{
const u_int16_t size = lm.size();