• R/O
  • SSH
  • HTTPS

eirsamples: Commit


Commit MetaInfo

Revision30 (tree)
Time2019-07-15 21:08:33
Authorquiret

Log Message

- added more ArrayDatabase tests

Change Summary

Incremental Difference

--- bigunittest/src/arrdbtest.cpp (revision 29)
+++ bigunittest/src/arrdbtest.cpp (revision 30)
@@ -430,5 +430,67 @@
430430 }
431431 printf( "ok.\n" );
432432
433+ printf( "testing ArrayDatabase recovery time-out after too many parallel transactions (100ms)..." );
434+ {
435+ filePtr memFile = fileSys->CreateMemoryFile();
436+
437+ ArrayDatabase::db_construction_params cparams;
438+ cparams.item_block_size = 512;
439+ cparams.journal_size = 200;
440+ cparams.user_ident = 0x74926487;
441+
442+ ArrayDatabase::CreateDatabase( memFile, cparams );
443+
444+ ArrayDatabase db( execMan, std::move( memFile ), 100 );
445+
446+ for ( size_t n = 0; n < ArrayDatabase::MAX_PARALLEL_TRANS; n++ )
447+ {
448+ db.BeginTransaction( 0 );
449+ }
450+
451+ try
452+ {
453+ db.BeginTransaction( 0 );
454+
455+ // Must not reach here.
456+ assert( 0 );
457+ }
458+ catch( eir_exception& )
459+ {
460+ // OK.
461+ }
462+ }
463+ printf( "ok.\n" );
464+
465+ printf( "testing ArrayDatabase writing too much into journal exception..." );
466+ {
467+ filePtr memFile = fileSys->CreateMemoryFile();
468+
469+ ArrayDatabase::db_construction_params cparams;
470+ cparams.item_block_size = 512;
471+ cparams.journal_size = 85;
472+ cparams.user_ident = 0x85639458;
473+
474+ ArrayDatabase::CreateDatabase( memFile, cparams );
475+
476+ ArrayDatabase db( execMan, std::move( memFile ) );
477+
478+ std::uint32_t tid = db.BeginTransaction( 0 );
479+
480+ try
481+ {
482+ while ( true )
483+ {
484+ // We cannot write forever.
485+ db.WriteStruct <std::uint32_t> ( tid, 0, 0 );
486+ }
487+ }
488+ catch( eir_exception& )
489+ {
490+ // OK.
491+ }
492+ }
493+ printf( "ok.\n" );
494+
433495 // TODO: more tests.
434496 }
\ No newline at end of file
Show on old repository browser