@@ -1576,18 +1576,33 @@ build_dummy_journal(KeyConvertF) ->
15761576 ok = filelib :ensure_dir (ManifestFP ),
15771577 F1 = filename :join (JournalFP , " nursery_1.pnd" ),
15781578 {ok , J1 } = leveled_cdb :cdb_open_writer (F1 ),
1579+ % % Load some dummmy keys to avoid timing issues when scenarios are not
1580+ % % triggered due to hashtable being calculated too fast
1581+ lists :foreach (
1582+ fun (I ) ->
1583+ DK = lists :flatten (io_lib :format (" DummmyK~6..0w " , [I ])),
1584+ DV = lists :flatten (io_lib :format (" TestValue~6..0w " , [I ])),
1585+ leveled_cdb :cdb_put (
1586+ J1 ,
1587+ {I , stnd , KeyConvertF (DK )},
1588+ create_value_for_journal ({DV , ? TEST_KC }, false )
1589+ )
1590+ end ,
1591+ lists :seq (1 , 1000 )
1592+ ),
1593+
15791594 {K1 , V1 } = {KeyConvertF (" Key1" ), " TestValue1" },
15801595 {K2 , V2 } = {KeyConvertF (" Key2" ), " TestValue2" },
15811596 ok =
15821597 leveled_cdb :cdb_put (
15831598 J1 ,
1584- {1 , stnd , K1 },
1599+ {1001 , stnd , K1 },
15851600 create_value_for_journal ({V1 , ? TEST_KC }, false )
15861601 ),
15871602 ok =
15881603 leveled_cdb :cdb_put (
15891604 J1 ,
1590- {2 , stnd , K2 },
1605+ {1002 , stnd , K2 },
15911606 create_value_for_journal ({V2 , ? TEST_KC }, false )
15921607 ),
15931608 ok = leveled_cdb :cdb_roll (J1 ),
@@ -1618,20 +1633,20 @@ build_dummy_journal(KeyConvertF) ->
16181633 ok =
16191634 leveled_cdb :cdb_put (
16201635 J2 ,
1621- {3 , stnd , K1 },
1636+ {1003 , stnd , K1 },
16221637 create_value_for_journal ({V3 , ? TEST_KC }, false )
16231638 ),
16241639 ok =
16251640 leveled_cdb :cdb_put (
16261641 J2 ,
1627- {4 , stnd , K4 },
1642+ {1004 , stnd , K4 },
16281643 create_value_for_journal ({V4 , ? TEST_KC }, false )
16291644 ),
16301645 LK2 = leveled_cdb :cdb_lastkey (J2 ),
16311646 ok = leveled_cdb :cdb_close (J2 ),
16321647 Manifest = [
16331648 {1 , " test/test_area/journal/journal_files/nursery_1" , " pid1" , LK1 },
1634- {3 , " test/test_area/journal/journal_files/nursery_3" , " pid2" , LK2 }
1649+ {1003 , " test/test_area/journal/journal_files/nursery_3" , " pid2" , LK2 }
16351650 ],
16361651 ManifestBin = term_to_binary (Manifest ),
16371652 {ok , MF1 } = file :open (
@@ -1671,12 +1686,12 @@ simple_inker_test() ->
16711686 compression_method = native ,
16721687 compress_on_receipt = true
16731688 }),
1674- Obj1 = ink_get (Ink1 , key_converter (" Key1" ), 1 ),
1675- ? assertMatch (Obj1 , {{1 , key_converter (" Key1" )}, {" TestValue1" , ? TEST_KC }}),
1676- Obj3 = ink_get (Ink1 , key_converter (" Key1" ), 3 ),
1677- ? assertMatch (Obj3 , {{3 , key_converter (" Key1" )}, {" TestValue3" , ? TEST_KC }}),
1678- Obj4 = ink_get (Ink1 , key_converter (" Key4" ), 4 ),
1679- ? assertMatch (Obj4 , {{4 , key_converter (" Key4" )}, {" TestValue4" , ? TEST_KC }}),
1689+ Obj1 = ink_get (Ink1 , key_converter (" Key1" ), 1001 ),
1690+ ? assertMatch (Obj1 , {{1001 , key_converter (" Key1" )}, {" TestValue1" , ? TEST_KC }}),
1691+ Obj3 = ink_get (Ink1 , key_converter (" Key1" ), 1003 ),
1692+ ? assertMatch (Obj3 , {{1003 , key_converter (" Key1" )}, {" TestValue3" , ? TEST_KC }}),
1693+ Obj4 = ink_get (Ink1 , key_converter (" Key4" ), 1004 ),
1694+ ? assertMatch (Obj4 , {{1004 , key_converter (" Key4" )}, {" TestValue4" , ? TEST_KC }}),
16801695 ink_close (Ink1 ),
16811696 clean_testdir (RootPath ).
16821697
@@ -1697,10 +1712,10 @@ simple_inker_completeactivejournal_test() ->
16971712 compression_method = native ,
16981713 compress_on_receipt = true
16991714 }),
1700- Obj1 = ink_get (Ink1 , key_converter (" Key1" ), 1 ),
1701- ? assertMatch (Obj1 , {{1 , key_converter (" Key1" )}, {" TestValue1" , ? TEST_KC }}),
1702- Obj2 = ink_get (Ink1 , key_converter (" Key4" ), 4 ),
1703- ? assertMatch (Obj2 , {{4 , key_converter (" Key4" )}, {" TestValue4" , ? TEST_KC }}),
1715+ Obj1 = ink_get (Ink1 , key_converter (" Key1" ), 1001 ),
1716+ ? assertMatch (Obj1 , {{1001 , key_converter (" Key1" )}, {" TestValue1" , ? TEST_KC }}),
1717+ Obj2 = ink_get (Ink1 , key_converter (" Key4" ), 1004 ),
1718+ ? assertMatch (Obj2 , {{1004 , key_converter (" Key4" )}, {" TestValue4" , ? TEST_KC }}),
17041719 ink_close (Ink1 ),
17051720 clean_testdir (RootPath ).
17061721
@@ -1738,12 +1753,12 @@ compact_journal_testto(WRP, ExpectedFiles) ->
17381753 {[], infinity },
17391754 true
17401755 ),
1741- ? assertMatch (NewSQN1 , 5 ),
1756+ ? assertMatch (NewSQN1 , 1005 ),
17421757 ok = ink_printmanifest (Ink1 ),
1743- R0 = ink_get (Ink1 , test_ledgerkey (" KeyAA" ), 5 ),
1758+ R0 = ink_get (Ink1 , test_ledgerkey (" KeyAA" ), 1005 ),
17441759 ? assertMatch (
17451760 R0 ,
1746- {{5 , test_ledgerkey (" KeyAA" )}, {" TestValueAA" , {[], infinity }}}
1761+ {{1005 , test_ledgerkey (" KeyAA" )}, {" TestValueAA" , {[], infinity }}}
17471762 ),
17481763 FunnyLoop = lists :seq (1 , 48 ),
17491764 Checker = lists :map (
@@ -1767,14 +1782,14 @@ compact_journal_testto(WRP, ExpectedFiles) ->
17671782 {[], infinity },
17681783 true
17691784 ),
1770- ? assertMatch (NewSQN2 , 54 ),
1785+ ? assertMatch (NewSQN2 , 1054 ),
17711786 ActualManifest = ink_getmanifest (Ink1 ),
17721787 ok = ink_printmanifest (Ink1 ),
17731788 ? assertMatch (3 , length (ActualManifest )),
17741789 {ok , _ICL1 } = ink_compactjournal (
17751790 Ink1 ,
17761791 Checker ,
1777- fun (X ) -> {X , 55 } end ,
1792+ fun (X ) -> {X , 1055 } end ,
17781793 fun (_F ) -> ok end ,
17791794 fun (L , K , SQN ) ->
17801795 case lists :member ({SQN , K }, L ) of
@@ -1791,7 +1806,7 @@ compact_journal_testto(WRP, ExpectedFiles) ->
17911806 {ok , _ICL2 } = ink_compactjournal (
17921807 Ink1 ,
17931808 Checker2 ,
1794- fun (X ) -> {X , 55 } end ,
1809+ fun (X ) -> {X , 1055 } end ,
17951810 fun (_F ) -> ok end ,
17961811 fun (L , K , SQN ) ->
17971812 case lists :member ({SQN , K }, L ) of
0 commit comments