@@ -58,12 +58,20 @@ var testCases = []struct {
5858 },
5959}
6060
61+ func newTestMetricsServer (t * testing.T , log zlog.Logger ) monitoring.MetricServer {
62+ t .Helper ()
63+
64+ metrics := monitoring .NewMetricsServer (false , log )
65+ t .Cleanup (metrics .Stop )
66+
67+ return metrics
68+ }
69+
6170func TestGarbageCollectAndRetentionMetaDB (t * testing.T ) {
6271 log := zlog .NewTestLogger ()
6372 audit := zlog .NewAuditLogger ("debug" , "/dev/null" )
6473
65- metrics := monitoring .NewMetricsServer (false , log )
66- defer metrics .Stop () // Clean up metrics server to prevent resource leaks
74+ metrics := newTestMetricsServer (t , log )
6775
6876 trueVal := true
6977
@@ -1242,7 +1250,7 @@ func TestGarbageCollectAndRetentionMetaDB(t *testing.T) {
12421250 So (err , ShouldBeNil )
12431251
12441252 if testcase .testCaseName == s3TestName {
1245- // Remote sorage is written to only after the blob upload is finished,
1253+ // Remote storage is written to only after the blob upload is finished,
12461254 // there should be no space used by blob uploads
12471255 So (uploads , ShouldEqual , []string {})
12481256 } else {
@@ -1253,7 +1261,7 @@ func TestGarbageCollectAndRetentionMetaDB(t *testing.T) {
12531261 isPresent , _ , _ , err := imgStore .StatBlobUpload (repoName , blobUploadID )
12541262
12551263 if testcase .testCaseName == s3TestName {
1256- // Remote sorage is written to only after the blob upload is finished,
1264+ // Remote storage is written to only after the blob upload is finished,
12571265 // there should be no space used by blob uploads
12581266 So (err , ShouldNotBeNil )
12591267 So (isPresent , ShouldBeFalse )
@@ -1271,7 +1279,7 @@ func TestGarbageCollectAndRetentionMetaDB(t *testing.T) {
12711279 So (err , ShouldBeNil )
12721280
12731281 if testcase .testCaseName == s3TestName {
1274- // Remote sorage is written to only after the blob upload is finished,
1282+ // Remote storage is written to only after the blob upload is finished,
12751283 // there should be no space used by blob uploads
12761284 So (uploads , ShouldEqual , []string {})
12771285 } else {
@@ -1282,7 +1290,7 @@ func TestGarbageCollectAndRetentionMetaDB(t *testing.T) {
12821290 isPresent , _ , _ , err = imgStore .StatBlobUpload (repoName , blobUploadID )
12831291
12841292 if testcase .testCaseName == s3TestName {
1285- // Remote sorage is written to only after the blob upload is finished,
1293+ // Remote storage is written to only after the blob upload is finished,
12861294 // there should be no space used by blob uploads
12871295 So (err , ShouldNotBeNil )
12881296 So (isPresent , ShouldBeFalse )
@@ -1316,8 +1324,7 @@ func TestGarbageCollectDeletion(t *testing.T) {
13161324 log := zlog .NewTestLogger ()
13171325 audit := zlog .NewAuditLogger ("debug" , "/dev/null" )
13181326
1319- metrics := monitoring .NewMetricsServer (false , log )
1320- defer metrics .Stop () // Clean up metrics server to prevent resource leaks
1327+ metrics := newTestMetricsServer (t , log )
13211328
13221329 trueVal := true
13231330 falseVal := false
@@ -1755,8 +1762,7 @@ func TestGarbageCollectAndRetentionNoMetaDB(t *testing.T) {
17551762 log := zlog .NewTestLogger ()
17561763 audit := zlog .NewAuditLogger ("debug" , "/dev/null" )
17571764
1758- metrics := monitoring .NewMetricsServer (false , log )
1759- defer metrics .Stop () // Clean up metrics server to prevent resource leaks
1765+ metrics := newTestMetricsServer (t , log )
17601766
17611767 trueVal := true
17621768
@@ -2566,7 +2572,7 @@ func TestGarbageCollectAndRetentionNoMetaDB(t *testing.T) {
25662572 So (err , ShouldBeNil )
25672573
25682574 if testcase .testCaseName == s3TestName {
2569- // Remote sorage is written to only after the blob upload is finished,
2575+ // Remote storage is written to only after the blob upload is finished,
25702576 // there should be no space used by blob uploads
25712577 So (uploads , ShouldEqual , []string {})
25722578 } else {
@@ -2577,7 +2583,7 @@ func TestGarbageCollectAndRetentionNoMetaDB(t *testing.T) {
25772583 isPresent , _ , _ , err := imgStore .StatBlobUpload (repoName , blobUploadID )
25782584
25792585 if testcase .testCaseName == s3TestName {
2580- // Remote sorage is written to only after the blob upload is finished,
2586+ // Remote storage is written to only after the blob upload is finished,
25812587 // there should be no space used by blob uploads
25822588 So (err , ShouldNotBeNil )
25832589 So (isPresent , ShouldBeFalse )
@@ -2595,7 +2601,7 @@ func TestGarbageCollectAndRetentionNoMetaDB(t *testing.T) {
25952601 So (err , ShouldBeNil )
25962602
25972603 if testcase .testCaseName == s3TestName {
2598- // Remote sorage is written to only after the blob upload is finished,
2604+ // Remote storage is written to only after the blob upload is finished,
25992605 // there should be no space used by blob uploads
26002606 So (uploads , ShouldEqual , []string {})
26012607 } else {
@@ -2606,7 +2612,7 @@ func TestGarbageCollectAndRetentionNoMetaDB(t *testing.T) {
26062612 isPresent , _ , _ , err = imgStore .StatBlobUpload (repoName , blobUploadID )
26072613
26082614 if testcase .testCaseName == s3TestName {
2609- // Remote sorage is written to only after the blob upload is finished,
2615+ // Remote storage is written to only after the blob upload is finished,
26102616 // there should be no space used by blob uploads
26112617 So (err , ShouldNotBeNil )
26122618 So (isPresent , ShouldBeFalse )
0 commit comments