Skip to content

Commit fc2f24c

Browse files
committed
fix test
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
1 parent d447cef commit fc2f24c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/compactor/compactor_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ func TestCompactor_SkipCompactionWhenCmkError(t *testing.T) {
173173
// No user blocks stored in the bucket.
174174
bucketClient := &bucket.ClientMock{}
175175
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
176+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
176177
bucketClient.MockIter("", []string{userID}, nil)
177178
bucketClient.MockIter("__markers__", []string{}, nil)
178179
bucketClient.MockIter(userID+"/", []string{userID + "/01DTVP434PA9VFXSW2JKB3392D"}, nil)
@@ -207,6 +208,7 @@ func TestCompactor_ShouldDoNothingOnNoUserBlocks(t *testing.T) {
207208
// No user blocks stored in the bucket.
208209
bucketClient := &bucket.ClientMock{}
209210
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
211+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
210212
bucketClient.MockIter("", []string{}, nil)
211213
bucketClient.MockIter("__markers__", []string{}, nil)
212214
cfg := prepareConfig()
@@ -284,6 +286,7 @@ func TestCompactor_ShouldRetryCompactionOnFailureWhileDiscoveringUsersFromBucket
284286
// Fail to iterate over the bucket while discovering users.
285287
bucketClient := &bucket.ClientMock{}
286288
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
289+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
287290
bucketClient.MockIter("__markers__", nil, errors.New("failed to iterate the bucket"))
288291
bucketClient.MockIter("", nil, errors.New("failed to iterate the bucket"))
289292

@@ -357,6 +360,7 @@ func TestCompactor_ShouldIncrementCompactionErrorIfFailedToCompactASingleTenant(
357360
userID := "test-user"
358361
bucketClient := &bucket.ClientMock{}
359362
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
363+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
360364
bucketClient.MockIter("", []string{userID}, nil)
361365
bucketClient.MockIter("__markers__", []string{}, nil)
362366
bucketClient.MockIter(userID+"/", []string{userID + "/01DTVP434PA9VFXSW2JKB3392D", userID + "/01FN6CDF3PNEWWRY5MPGJPE3EX", userID + "/01DTVP434PA9VFXSW2JKB3392D/meta.json", userID + "/01FN6CDF3PNEWWRY5MPGJPE3EX/meta.json"}, nil)
@@ -414,6 +418,7 @@ func TestCompactor_ShouldIncrementCompactionErrorIfFailedToCompactASingleTenant(
414418
func TestCompactor_ShouldCompactAndRemoveUserFolder(t *testing.T) {
415419
bucketClient := &bucket.ClientMock{}
416420
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
421+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
417422
bucketClient.MockIter("", []string{"user-1"}, nil)
418423
bucketClient.MockIter("__markers__", []string{}, nil)
419424
bucketClient.MockExists(users.GetGlobalDeletionMarkPath("user-1"), false, nil)
@@ -464,6 +469,7 @@ func TestCompactor_ShouldIterateOverUsersAndRunCompaction(t *testing.T) {
464469
// Mock the bucket to contain two users, each one with one block.
465470
bucketClient := &bucket.ClientMock{}
466471
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
472+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
467473
bucketClient.MockIter("", []string{"user-1", "user-2"}, nil)
468474
bucketClient.MockIter("__markers__", []string{}, nil)
469475
bucketClient.MockExists(users.GetGlobalDeletionMarkPath("user-1"), false, nil)
@@ -609,6 +615,7 @@ func TestCompactor_ShouldNotCompactBlocksMarkedForDeletion(t *testing.T) {
609615
// Mock the bucket to contain two users, each one with one block.
610616
bucketClient := &bucket.ClientMock{}
611617
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
618+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
612619
bucketClient.MockIter("", []string{"user-1"}, nil)
613620
bucketClient.MockIter("__markers__", []string{}, nil)
614621
bucketClient.MockIter("user-1/", []string{"user-1/01DTVP434PA9VFXSW2JKB3392D", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ"}, nil)
@@ -731,6 +738,7 @@ func TestCompactor_ShouldNotCompactBlocksMarkedForSkipCompact(t *testing.T) {
731738
// Mock the bucket to contain two users, each one with one block.
732739
bucketClient := &bucket.ClientMock{}
733740
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
741+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
734742
bucketClient.MockIter("", []string{"user-1", "user-2"}, nil)
735743
bucketClient.MockIter("__markers__", []string{}, nil)
736744
bucketClient.MockExists(users.GetGlobalDeletionMarkPath("user-1"), false, nil)
@@ -817,6 +825,7 @@ func TestCompactor_ShouldNotCompactBlocksForUsersMarkedForDeletion(t *testing.T)
817825
// Mock the bucket to contain two users, each one with one block.
818826
bucketClient := &bucket.ClientMock{}
819827
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
828+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
820829
bucketClient.MockIter("", []string{"user-1"}, nil)
821830
bucketClient.MockIter("__markers__", []string{"__markers__/user-1/"}, nil)
822831
bucketClient.MockIter("user-1/", []string{"user-1/01DTVP434PA9VFXSW2JKB3392D"}, nil)
@@ -981,6 +990,7 @@ func TestCompactor_ShouldCompactAllUsersOnShardingEnabledButOnlyOneInstanceRunni
981990
// Mock the bucket to contain two users, each one with one block.
982991
bucketClient := &bucket.ClientMock{}
983992
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
993+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
984994
bucketClient.MockIter("", []string{"user-1", "user-2"}, nil)
985995
bucketClient.MockIter("__markers__", []string{}, nil)
986996
bucketClient.MockExists(users.GetGlobalDeletionMarkPath("user-1"), false, nil)
@@ -1092,6 +1102,7 @@ func TestCompactor_ShouldCompactOnlyUsersOwnedByTheInstanceOnShardingEnabledAndM
10921102
// Mock the bucket to contain all users, each one with one block.
10931103
bucketClient := &bucket.ClientMock{}
10941104
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
1105+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
10951106
bucketClient.MockIter("", userIDs, nil)
10961107
bucketClient.MockIter("__markers__", []string{}, nil)
10971108
for _, userID := range userIDs {
@@ -1203,6 +1214,7 @@ func TestCompactor_ShouldCompactOnlyShardsOwnedByTheInstanceOnShardingEnabledWit
12031214
// Mock the bucket to contain all users, each one with five blocks, 2 sets of overlapping blocks and 1 separate block.
12041215
bucketClient := &bucket.ClientMock{}
12051216
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
1217+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
12061218
bucketClient.MockIter("", userIDs, nil)
12071219
bucketClient.MockIter("__markers__", []string{}, nil)
12081220

@@ -1856,6 +1868,7 @@ func TestCompactor_ShouldFailCompactionOnTimeout(t *testing.T) {
18561868
// Mock the bucket
18571869
bucketClient := &bucket.ClientMock{}
18581870
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
1871+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
18591872
bucketClient.MockIter("", []string{}, nil)
18601873
bucketClient.MockIter("__markers__", []string{}, nil)
18611874

@@ -1957,6 +1970,7 @@ func TestCompactor_ShouldNotFailCompactionIfAccessDeniedErrDuringMetaSync(t *tes
19571970

19581971
bucketClient := &bucket.ClientMock{}
19591972
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
1973+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
19601974
bucketClient.MockIter("__markers__", []string{}, nil)
19611975
bucketClient.MockIter("", []string{"user-1"}, nil)
19621976
bucketClient.MockIter("user-1/", []string{"user-1/01DTVP434PA9VFXSW2JKB3392D", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ", "user-1/01DTVP434PA9VFXSW2JKB3392D/meta.json", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ/meta.json"}, nil)
@@ -2008,6 +2022,7 @@ func TestCompactor_ShouldNotFailCompactionIfAccessDeniedErrReturnedFromBucket(t
20082022

20092023
bucketClient := &bucket.ClientMock{}
20102024
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
2025+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
20112026
bucketClient.MockIter("__markers__", []string{}, nil)
20122027
bucketClient.MockIter("", []string{"user-1"}, nil)
20132028
bucketClient.MockIter("user-1/", []string{"user-1/01DTVP434PA9VFXSW2JKB3392D", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ", "user-1/01DTVP434PA9VFXSW2JKB3392D/meta.json", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ/meta.json"}, nil)
@@ -2059,6 +2074,7 @@ func TestCompactor_FailedWithRetriableError(t *testing.T) {
20592074

20602075
bucketClient := &bucket.ClientMock{}
20612076
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
2077+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
20622078
bucketClient.MockIter("__markers__", []string{}, nil)
20632079
bucketClient.MockIter("", []string{"user-1"}, nil)
20642080
bucketClient.MockIter("user-1/", []string{"user-1/01DTVP434PA9VFXSW2JKB3392D", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ", "user-1/01DTVP434PA9VFXSW2JKB3392D/meta.json", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ/meta.json"}, nil)
@@ -2113,6 +2129,7 @@ func TestCompactor_FailedWithHaltError(t *testing.T) {
21132129

21142130
bucketClient := &bucket.ClientMock{}
21152131
bucketClient.MockGet(users.UserIndexCompressedFilename, "", nil)
2132+
bucketClient.MockUpload(users.UserIndexCompressedFilename, nil)
21162133
bucketClient.MockIter("__markers__", []string{}, nil)
21172134
bucketClient.MockIter("", []string{"user-1"}, nil)
21182135
bucketClient.MockIter("user-1/", []string{"user-1/01DTVP434PA9VFXSW2JKB3392D", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ", "user-1/01DTVP434PA9VFXSW2JKB3392D/meta.json", "user-1/01DTW0ZCPDDNV4BV83Q2SV4QAZ/meta.json"}, nil)

0 commit comments

Comments
 (0)