-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support of startOffset and endOffset #430
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -993,6 +993,56 @@ public void testListBlobsVersioned() throws ExecutionException, InterruptedExcep | |
} | ||
} | ||
|
||
@Test | ||
public void testListBlobsWithOffset() throws ExecutionException, InterruptedException { | ||
String bucketName = RemoteStorageHelper.generateBucketName(); | ||
Bucket bucket = | ||
storage.create(BucketInfo.newBuilder(bucketName).setVersioningEnabled(true).build()); | ||
try { | ||
String[] blobNames = { | ||
"test-list-blobs-start-offset-blob1", | ||
"test-list-blobs-start-offset-blob2", | ||
"test-list-blobs-end-offset-blob3" | ||
}; | ||
BlobInfo blob1 = | ||
BlobInfo.newBuilder(bucket, blobNames[0]).setContentType(CONTENT_TYPE).build(); | ||
BlobInfo blob2 = | ||
BlobInfo.newBuilder(bucket, blobNames[1]).setContentType(CONTENT_TYPE).build(); | ||
BlobInfo blob3 = | ||
BlobInfo.newBuilder(bucket, blobNames[2]).setContentType(CONTENT_TYPE).build(); | ||
|
||
Blob remoteBlob1 = storage.create(blob1); | ||
Blob remoteBlob2 = storage.create(blob2); | ||
Blob remoteBlob3 = storage.create(blob3); | ||
assertNotNull(remoteBlob1); | ||
assertNotNull(remoteBlob2); | ||
assertNotNull(remoteBlob3); | ||
Page<Blob> page = | ||
storage.list( | ||
bucketName, | ||
Storage.BlobListOption.startOffset("test-list-blobs-start-offset-blob"), | ||
Storage.BlobListOption.endOffset("test-list-blobs-end-offset-blob3")); | ||
// Listing blobs is eventually consistent, we loop until the list is of the expected size. | ||
while (Iterators.size(page.iterateAll().iterator()) != 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't tell if this is working because it's using all the objects created during the test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @frankyn yes you are right, i have wrote new test instead of that. Now you can easily verify it. |
||
page = | ||
storage.list( | ||
bucketName, | ||
Storage.BlobListOption.startOffset("test-list-blobs-start-offset-blob"), | ||
Storage.BlobListOption.endOffset("test-list-blobs-end-offset-blob3")); | ||
} | ||
Set<String> blobSet = ImmutableSet.of(blobNames[0], blobNames[1], blobNames[2]); | ||
Iterator<Blob> iterator = page.iterateAll().iterator(); | ||
while (iterator.hasNext()) { | ||
Blob remoteBlob = iterator.next(); | ||
assertEquals(bucketName, remoteBlob.getBucket()); | ||
assertTrue(blobSet.contains(remoteBlob.getName())); | ||
assertNotNull(remoteBlob.getGeneration()); | ||
} | ||
} finally { | ||
RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS); | ||
} | ||
} | ||
|
||
@Test(timeout = 5000) | ||
public void testListBlobsCurrentDirectory() throws InterruptedException { | ||
String directoryName = "test-list-blobs-current-directory/"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend starting from not the first object in the new objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this test with new one.