@@ -918,7 +918,7 @@ func TestFastStorageReUpgradeProtection_ForceUpgradeFirstTime_NoForceSecondTime_
918918 // dbMock represents the underlying database under the hood of nodeDB
919919 dbMock .EXPECT ().Get (gomock .Any ()).Return (expectedStorageVersion , nil ).Times (1 )
920920
921- dbMock .EXPECT ().NewBatchWithSize (gomock .Any ()).Return (batchMock ).Times (3 )
921+ dbMock .EXPECT ().NewBatchWithSize (gomock .Any ()).Return (batchMock ).Times (2 )
922922 dbMock .EXPECT ().ReverseIterator (gomock .Any (), gomock .Any ()).Return (rIterMock , nil ).Times (1 ) // called to get latest version
923923 startFormat := fastKeyFormat .Key ()
924924 endFormat := fastKeyFormat .Key ()
@@ -940,8 +940,8 @@ func TestFastStorageReUpgradeProtection_ForceUpgradeFirstTime_NoForceSecondTime_
940940 batchMock .EXPECT ().GetByteSize ().Return (100 , nil ).Times (2 )
941941 batchMock .EXPECT ().Delete (fastKeyFormat .Key (fastNodeKeyToDelete )).Return (nil ).Times (1 )
942942 batchMock .EXPECT ().Set (metadataKeyFormat .Key ([]byte (storageVersionKey )), updatedExpectedStorageVersion ).Return (nil ).Times (1 )
943- batchMock .EXPECT ().Write ().Return (nil ).Times (2 )
944- batchMock .EXPECT ().Close ().Return (nil ).Times (2 )
943+ batchMock .EXPECT ().Write ().Return (nil ).Times (1 )
944+ batchMock .EXPECT ().Close ().Return (nil ).Times (1 )
945945
946946 // iterMock is used to mock the underlying db iterator behing fast iterator
947947 // Here, we want to mock the behavior of deleting fast nodes from disk when
@@ -1124,11 +1124,7 @@ func TestUpgradeStorageToFast_Integration_Upgraded_GetFast_Success(t *testing.T)
11241124}
11251125
11261126func TestUpgradeStorageToFast_Success (t * testing.T ) {
1127- tmpCommitGap := commitGap
1128- commitGap = 1000
1129- defer func () {
1130- commitGap = tmpCommitGap
1131- }()
1127+ commitGap := 1000
11321128
11331129 type fields struct {
11341130 nodeCount int
@@ -1138,10 +1134,10 @@ func TestUpgradeStorageToFast_Success(t *testing.T) {
11381134 fields fields
11391135 }{
11401136 {"less than commit gap" , fields {nodeCount : 100 }},
1141- {"equal to commit gap" , fields {nodeCount : int ( commitGap ) }},
1142- {"great than commit gap" , fields {nodeCount : int ( commitGap ) + 100 }},
1143- {"two times commit gap" , fields {nodeCount : int ( commitGap ) * 2 }},
1144- {"two times plus commit gap" , fields {nodeCount : int ( commitGap ) * 2 + 1 }},
1137+ {"equal to commit gap" , fields {nodeCount : commitGap }},
1138+ {"great than commit gap" , fields {nodeCount : commitGap + 100 }},
1139+ {"two times commit gap" , fields {nodeCount : commitGap * 2 }},
1140+ {"two times plus commit gap" , fields {nodeCount : commitGap * 2 + 1 }},
11451141 }
11461142
11471143 for _ , tt := range tests {
@@ -1164,11 +1160,7 @@ func TestUpgradeStorageToFast_Success(t *testing.T) {
11641160
11651161func TestUpgradeStorageToFast_Delete_Stale_Success (t * testing.T ) {
11661162 // we delete fast node, in case of deadlock. we should limit the stale count lower than chBufferSize(64)
1167- tmpCommitGap := commitGap
1168- commitGap = 5
1169- defer func () {
1170- commitGap = tmpCommitGap
1171- }()
1163+ commitGap := 5
11721164
11731165 valStale := "val_stale"
11741166 addStaleKey := func (ndb * nodeDB , staleCount int ) {
@@ -1197,10 +1189,10 @@ func TestUpgradeStorageToFast_Delete_Stale_Success(t *testing.T) {
11971189 fields fields
11981190 }{
11991191 {"stale less than commit gap" , fields {nodeCount : 100 , staleCount : 4 }},
1200- {"stale equal to commit gap" , fields {nodeCount : int ( commitGap ) , staleCount : int ( commitGap ) }},
1201- {"stale great than commit gap" , fields {nodeCount : int ( commitGap ) + 100 , staleCount : int ( commitGap ) * 2 - 1 }},
1202- {"stale twice commit gap" , fields {nodeCount : int ( commitGap ) + 100 , staleCount : int ( commitGap ) * 2 }},
1203- {"stale great than twice commit gap" , fields {nodeCount : int ( commitGap ) , staleCount : int ( commitGap ) * 2 + 1 }},
1192+ {"stale equal to commit gap" , fields {nodeCount : commitGap , staleCount : commitGap }},
1193+ {"stale great than commit gap" , fields {nodeCount : commitGap + 100 , staleCount : commitGap * 2 - 1 }},
1194+ {"stale twice commit gap" , fields {nodeCount : commitGap + 100 , staleCount : commitGap * 2 }},
1195+ {"stale great than twice commit gap" , fields {nodeCount : commitGap , staleCount : commitGap * 2 + 1 }},
12041196 }
12051197
12061198 for _ , tt := range tests {
0 commit comments