Author: kpvdr
Date: 2007-08-30 17:42:58 -0400 (Thu, 30 Aug 2007)
New Revision: 902
Modified:
store/trunk/cpp/lib/Makefile.am
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/jtest.hpp
store/trunk/cpp/tests/jrnl/msg_consumer.cpp
store/trunk/cpp/tests/jrnl/msg_consumer.hpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.hpp
Log:
More tests added
Modified: store/trunk/cpp/lib/Makefile.am
===================================================================
--- store/trunk/cpp/lib/Makefile.am 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/lib/Makefile.am 2007-08-30 21:42:58 UTC (rev 902)
@@ -1,4 +1,5 @@
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS)
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS) \
+ -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
lib_LTLIBRARIES = libbdbstore.la
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -80,6 +80,15 @@
// Prepare journal dir, journal files and file handles
_jdir.clear_dir();
+ // TODO - place this in a finalize() fn? - see ~jcntl()...
+ if (_datafh)
+ {
+ for (u_int32_t i=0; i<JRNL_NUM_FILES; i++)
+ if (_datafh[i])
+ ::delete _datafh[i];
+ ::delete[] _datafh;
+ }
+
_datafh = ::new lfh*[JRNL_NUM_FILES];
// NOTE: We NULL the pointer array prior to setting the pointers because exceptions
// can be thrown during pointer initialization, and the clean() fn that will be
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/Makefile.am 2007-08-30 21:42:58 UTC (rev 902)
@@ -2,7 +2,7 @@
abs_srcdir=@abs_srcdir@
AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS) \
- $(CPPUNIT_CXXFLAGS)
+ $(CPPUNIT_CXXFLAGS)
INCLUDES=-I../lib
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -37,19 +37,198 @@
class JournalTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(JournalTest);
+ CPPUNIT_TEST(Test_000);
CPPUNIT_TEST(Test_001);
+ CPPUNIT_TEST(Test_002);
+ CPPUNIT_TEST(Test_003);
+ CPPUNIT_TEST(Test_004);
+ CPPUNIT_TEST(Test_005);
+ CPPUNIT_TEST(Test_006);
+ CPPUNIT_TEST(Test_007);
+ CPPUNIT_TEST(Test_008);
+ CPPUNIT_TEST(Test_009);
+ CPPUNIT_TEST(Test_010);
+ CPPUNIT_TEST(Test_011);
+ CPPUNIT_TEST(Test_012);
+ CPPUNIT_TEST(Test_013);
+ CPPUNIT_TEST(Test_014);
+ CPPUNIT_TEST(Test_015);
+ CPPUNIT_TEST(Test_016);
+ CPPUNIT_TEST(Test_017);
+ CPPUNIT_TEST(Test_018);
+ CPPUNIT_TEST(Test_019);
+ CPPUNIT_TEST(Test_020);
+ CPPUNIT_TEST(Test_021);
+ CPPUNIT_TEST(Test_022);
+ CPPUNIT_TEST(Test_023);
+ CPPUNIT_TEST(Test_024);
+ CPPUNIT_TEST(Test_025);
+ CPPUNIT_TEST(Test_026);
CPPUNIT_TEST_SUITE_END();
+ jtest t;
+
+ void runJournalTest(const unsigned num_msgs, const unsigned min_msg_size,
+ const unsigned max_msg_szie, const bool auto_deq, const unsigned iterations,
+ const char* test_descr)
+ {
+ std::cout << " " << test_descr << " "
<< std::flush;
+ jtest::targs ta(num_msgs, min_msg_size, max_msg_szie, auto_deq, test_descr);
+ for (unsigned i=0; i<iterations; i++)
+ {
+ std::cout << "." << std::flush;
+ try
+ {
+ t.initialize(ta);
+ t.run();
+ }
+ catch (rhm::journal::jexception e)
+ {
+ t.finalize();
+ std::cout << e << std::endl;
+ std::cout << std::hex << std::setfill('0');
+ std::cerr << "*** jtest failed with code 0x" <<
std::setw(4) << e.err_code() << " ***" << std::endl <<
std::flush;
+ throw e;
+ }
+ t.finalize();
+ }
+ }
+
public:
+ void Test_000()
+ {
+ runJournalTest(0, 0, 0, false, 2, "Empty journal");
+ }
+
void Test_001()
{
- jtest::targs ta(1, 10, 10, false, "Test 1");
- jtest t;
- t.initialize(ta);
- t.run();
- t.report();
- t.finalize();
+ runJournalTest(1, 10, 10, false, 5, "1*(10 bytes)");
}
+
+ void Test_002()
+ {
+ runJournalTest(1, 10, 10, true, 5, "1*(10 bytes), auto-deq");
+ }
+
+ void Test_003()
+ {
+ runJournalTest(10, 10, 10, false, 5, "10*(10 bytes)");
+ }
+
+ void Test_004()
+ {
+ runJournalTest(10, 10, 10, true, 5, "10*(10 bytes), auto-deq");
+ }
+
+ void Test_005()
+ {
+ runJournalTest(10, 92, 92, false, 5, "10*(1 dblk exact fit)");
+ }
+
+ void Test_006()
+ {
+ runJournalTest(10, 92, 92, true, 5, "10*(1 dblk exact fit),
auto-deq");
+ }
+
+ void Test_007()
+ {
+ runJournalTest(10, 93, 93, false, 5, "10*(1 dblk + 1 byte)");
+ }
+
+ void Test_008()
+ {
+ runJournalTest(10, 93, 93, true, 5, "10*(1 dblk + 1 byte), auto-deq");
+ }
+
+ void Test_009()
+ {
+ runJournalTest(10, 476, 476, false, 5, "10*(1 sblk exact fit)");
+ }
+
+ void Test_010()
+ {
+ runJournalTest(10, 476, 476, true, 5, "10*(1 sblk exact fit),
auto-deq");
+ }
+
+ void Test_011()
+ {
+ runJournalTest(10, 477, 477, false, 5, "10*(1 sblk + 1 byte)");
+ }
+
+ void Test_012()
+ {
+ runJournalTest(10, 477, 477, true, 5, "10*(1 sblk + 1 byte),
auto-deq");
+ }
+
+ void Test_013()
+ {
+ runJournalTest(8, 4060, 4060, false, 5, "8*(1/8 page)");
+ }
+
+ void Test_014()
+ {
+ runJournalTest(9, 4060, 4060, false, 5, "9*(1/8 page)");
+ }
+
+ void Test_015()
+ {
+ runJournalTest(8, 4061, 4061, false, 5, "8*(1/8 page + 1 byte)");
+ }
+
+ void Test_016()
+ {
+ runJournalTest(8, 3932, 3932, true, 5, "8*(1/8 page - 1 dblk for deq
record), auto-deq");
+ }
+
+ void Test_017()
+ {
+ runJournalTest(9, 3932, 3932, true, 5, "9*(1/8 page - 1 dblk for deq
record), auto-deq");
+ }
+
+ void Test_018()
+ {
+ runJournalTest(8, 3933, 3933, true, 5, "8*(1/8 page - 1 dblk for deq record
+ 1 byte), auto-deq");
+ }
+
+ void Test_019()
+ {
+ runJournalTest(32, 32732, 32732, false, 5, "32*(1 page exact fit)");
+ }
+
+ void Test_020()
+ {
+ runJournalTest(33, 32732, 32732, false, 5, "33*(1 page exact fit)");
+ }
+
+ void Test_021()
+ {
+ runJournalTest(22, 49116, 49116, false, 5, "22*(1.5 pages)");
+ }
+
+ void Test_022()
+ {
+ runJournalTest(22, 48988, 48988, true, 5, "22*(1.5 pages - 1 dblk for deq
record), auto-deq");
+ }
+
+ void Test_023()
+ {
+ runJournalTest(48, 32732, 32732, false, 5, "48*(1 page exact fit)");
+ }
+
+ void Test_024()
+ {
+ runJournalTest(49, 32732, 32732, false, 5, "49*(1 page exact fit)");
+ }
+
+ void Test_025()
+ {
+ runJournalTest(20, 81884, 81884, false, 5, "20*(2.5 pages)");
+ }
+
+ void Test_026()
+ {
+ runJournalTest(20, 81756, 81756, true, 5, "20*(2.5 pages - 1 dblk for deq
record), auto-deq");
+ }
};
// Make this test suite a plugin.
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 21:42:58 UTC (rev 902)
@@ -1,6 +1,6 @@
abs_builddir=@abs_builddir@
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread -DRHM_CLEAN -DRHM_WRONLY
-DRHM_TESTVALS
INCLUDES=-I../../lib
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -85,7 +85,7 @@
_comment(comment)
{}
-jtest::jtest() throw (rhm::journal::jexception):
+jtest::jtest():
_start_time(new timeval),
_end_time(new timeval),
_tz_ptr(NULL)
@@ -118,7 +118,7 @@
void
jtest::initialize(const targs& ta) throw (rhm::journal::jexception)
{
- gettimeofday(_start_time, _tz_ptr);
+// gettimeofday(_start_time, _tz_ptr);
p_args = new msg_producer::_p_args(_jc, ta._num_msgs, ta._min_msg_size,
ta._max_msg_size,
ta._auto_deq);
@@ -127,9 +127,9 @@
_mc.initialize(c_args);
_jc.initialize(&_mc.aio_dtokl(), NULL, &_mp.aio_dtokl(), &mp_aio_cb);
- gettimeofday(_end_time, _tz_ptr);
- string str;
- cout << "initialize(): " << report_time(str) << endl;
+// gettimeofday(_end_time, _tz_ptr);
+// string str;
+// cout << "initialize(): " << report_time(str) << endl;
}
void
@@ -145,7 +145,7 @@
#ifndef RHM_RDONLY
produce(p_args);
#ifndef RHM_WRONLY
- std::cout << "-----" << std::endl;
+// std::cout << "-----" << std::endl;
usleep(500000); // 0.5 sec
#endif
#endif
@@ -170,7 +170,7 @@
gettimeofday(_end_time, _tz_ptr);
string str;
- cout << "run(): " << report_time(str) << endl;
+// cout << "run(): " << report_time(str) << endl;
}
void
@@ -179,7 +179,10 @@
void
jtest::finalize() throw (rhm::journal::jexception)
-{}
+{
+ _mp.finalize();
+ _mc.finalize();
+}
string&
jtest::report_time(string& str) const
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -62,7 +62,6 @@
};
private:
-// static msg_producer::_p_args p_arg_arr[NUM_TESTS];
static msg_producer::_p_args* p_args;
static msg_consumer::_c_args* c_args;
static rhm::journal::jcntl _jc;
@@ -74,7 +73,7 @@
pthread_t _c_thread;
public:
- jtest() throw (rhm::journal::jexception);
+ jtest();
~jtest();
static void proc_args(int argc, char** argv, char** test_file_name, int* test_num)
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -47,8 +47,8 @@
{}
msg_consumer::msg_consumer():
- _tot_blks(0),
- _tot_msize(0)
+ _tot_dblks(0),
+ _tot_dsize(0)
{
instCnt++;
}
@@ -83,6 +83,20 @@
initialize(args->_num_msgs);
}
+void
+msg_consumer::finalize()
+{
+ _tot_dblks = 0;
+ _tot_dsize = 0;
+ _aio_cmpl_dtok_list.clear();
+ for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
+ _dtok_master_list.clear();
+}
+
u_int32_t
msg_consumer::consume(rhm::journal::jcntl& _jcntl, const u_int32_t num_msgs,
const size_t min_msg_size, const size_t max_msg_size) throw
(rhm::journal::jexception)
@@ -110,8 +124,8 @@
data_size = dtokp->dsize();
_msg_buff[data_size] = 0; // Make msg into a c-string
read = true;
- _tot_blks += dtokp->dblocks_proc();
- _tot_msize += data_size;
+ _tot_dblks += dtokp->dblocks_proc();
+ _tot_dsize += data_size;
// Comment out these for performance checks/measurements
check_msg(msgCntr, data_size, min_msg_size, max_msg_size, true,
_msg_buff);
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -62,8 +62,8 @@
u_int32_t _num_msgs;
std::deque<rhm::journal::data_tok*> _dtok_master_list; // One dtok per msg to
be received
std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from
completed AIOs go here
- u_int64_t _tot_blks;
- u_int64_t _tot_msize;
+ u_int64_t _tot_dblks;
+ u_int64_t _tot_dsize;
public:
msg_consumer();
@@ -71,14 +71,15 @@
void initialize(const u_int32_t numMsgs);
void initialize(_c_args* args);
+ void finalize();
u_int32_t consume(rhm::journal::jcntl& _jcntl, const u_int32_t numMsgs,
const size_t min_msg_size, const size_t max_msg_size) throw
(rhm::journal::jexception);
u_int32_t consume(_c_args* args) throw (rhm::journal::jexception);
void aio_callback(u_int32_t num_dtoks);
- const inline u_int64_t get_tot_blks() const { return _tot_blks; }
- const inline u_int64_t get_tot_msize() const { return _tot_msize; }
+ const inline u_int64_t get_tot_dblks() const { return _tot_dblks; }
+ const inline u_int64_t get_tot_dsize() const { return _tot_dsize; }
inline std::deque<rhm::journal::data_tok*>& aio_dtokl() { return
_aio_cmpl_dtok_list; }
static void interrupt();
private:
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -87,6 +87,25 @@
initialize(args->_num_msgs, args->_auto_dequeue);
}
+void
+msg_producer::finalize()
+{
+ _num_msgs_enq_subm = 0;
+ _num_msgs_enq = 0;
+ _num_msgs_deq_subm = 0;
+ _num_msgs_deq = 0;
+ _tot_dblks = 0;
+ _tot_dsize = 0;
+ _aio_cmpl_dtok_list.clear();
+ _dd_dtok_list.clear();
+ for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
+ _dtok_master_list.clear();
+}
+
u_int32_t
msg_producer::produce(rhm::journal::jcntl& jc, const size_t minMsgSize,
const size_t maxMsgSize) throw (rhm::journal::jexception)
@@ -111,7 +130,7 @@
}
rhm::journal::data_tok* dtokp = _dtok_master_list[msgCntr];
const void* const msg = (char*)_msg_buff + (msgCntr%10);
-//std::cout << "e" << dtokp->id() << " "
<< std::flush;
+//std::cout << "e" << dtokp->id() << "-"
<< dtokp->wstate_str() << " " << std::flush;
bool written = false;
while (!written)
{
@@ -175,10 +194,10 @@
}
_interrupt_flag = false;
//std::cout << std::endl;
- std::cout << std::dec;
- std::cout << "Messages sent = " << _num_msgs <<
std::endl;
- std::cout << "Total enqueue events = " << _num_msgs_enq
<< std::endl;
- std::cout << "Total dequeue events = " << _num_msgs_deq
<< std::endl;
+// std::cout << std::dec;
+// std::cout << "Messages sent = " << _num_msgs <<
std::endl;
+// std::cout << "Total enqueue events = " << _num_msgs_enq
<< std::endl;
+// std::cout << "Total dequeue events = " << _num_msgs_deq
<< std::endl;
//std::cout << std::endl;
return _num_msgs;
}
Modified: store/trunk/cpp/tests/jrnl/msg_producer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -81,6 +81,7 @@
void initialize(const u_int32_t numMsgs, bool auto_dequeue);
void initialize(_p_args* args);
+ void finalize();
u_int32_t produce(rhm::journal::jcntl& jc, const size_t minMsgSize, const size_t
maxMsgSize)
throw (rhm::journal::jexception);