Skip to content

Commit

Permalink
Replace values().iterator() with iterateAll() in blob list ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Mar 3, 2016
1 parent 452e274 commit 622dcc9
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ public static void afterClass() throws ExecutionException, InterruptedException

@Test(timeout = 5000)
public void testListBuckets() throws InterruptedException {
Iterator<Bucket> bucketIterator =
storage.list(Storage.BucketListOption.prefix(BUCKET),
Storage.BucketListOption.fields()).values().iterator();
Iterator<Bucket> bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET),
Storage.BucketListOption.fields()).iterateAll();
while (!bucketIterator.hasNext()) {
Thread.sleep(500);
bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET),
Storage.BucketListOption.fields()).values().iterator();
Storage.BucketListOption.fields()).iterateAll();
}
while (bucketIterator.hasNext()) {
Bucket remoteBucket = bucketIterator.next();
Expand Down Expand Up @@ -310,14 +309,16 @@ public void testListBlobsSelectedFields() throws InterruptedException {
Storage.BlobListOption.fields(BlobField.METADATA));
// Listing blobs is eventually consistent, we loop until the list is of the expected size. The
// test fails if timeout is reached.
while (Iterators.size(page.values().iterator()) != 2) {
while (Iterators.size(page.iterateAll()) != 2) {
Thread.sleep(500);
page = storage.list(BUCKET,
Storage.BlobListOption.prefix("test-list-blobs-selected-fields-blob"),
Storage.BlobListOption.fields(BlobField.METADATA));
}
Set<String> blobSet = ImmutableSet.of(blobNames[0], blobNames[1]);
for (Blob remoteBlob : page.values()) {
Iterator<Blob> iterator = page.iterateAll();
while (iterator.hasNext()) {
Blob remoteBlob = iterator.next();
assertEquals(BUCKET, remoteBlob.bucket());
assertTrue(blobSet.contains(remoteBlob.name()));
assertEquals(metadata, remoteBlob.metadata());
Expand Down Expand Up @@ -346,14 +347,16 @@ public void testListBlobsEmptySelectedFields() throws InterruptedException {
Storage.BlobListOption.fields());
// Listing blobs is eventually consistent, we loop until the list is of the expected size. The
// test fails if timeout is reached.
while (Iterators.size(page.values().iterator()) != 2) {
while (Iterators.size(page.iterateAll()) != 2) {
Thread.sleep(500);
page = storage.list(BUCKET,
Storage.BlobListOption.prefix("test-list-blobs-empty-selected-fields-blob"),
Storage.BlobListOption.fields());
}
Set<String> blobSet = ImmutableSet.of(blobNames[0], blobNames[1]);
for (Blob remoteBlob : page.values()) {
Iterator<Blob> iterator = page.iterateAll();
while (iterator.hasNext()) {
Blob remoteBlob = iterator.next();
assertEquals(BUCKET, remoteBlob.bucket());
assertTrue(blobSet.contains(remoteBlob.name()));
assertNull(remoteBlob.contentType());
Expand All @@ -362,7 +365,7 @@ public void testListBlobsEmptySelectedFields() throws InterruptedException {
assertTrue(remoteBlob2.delete());
}

@Test(timeout = 10000)
@Test(timeout = 15000)
public void testListBlobsVersioned() throws ExecutionException, InterruptedException {
String bucketName = RemoteGcsHelper.generateBucketName();
Bucket bucket = storage.create(BucketInfo.builder(bucketName).versioningEnabled(true).build());
Expand All @@ -385,14 +388,16 @@ public void testListBlobsVersioned() throws ExecutionException, InterruptedExcep
Storage.BlobListOption.versions(true));
// Listing blobs is eventually consistent, we loop until the list is of the expected size. The
// test fails if timeout is reached.
while (Iterators.size(page.values().iterator()) != 3) {
while (Iterators.size(page.iterateAll()) != 3) {
Thread.sleep(500);
page = storage.list(bucketName,
Storage.BlobListOption.prefix("test-list-blobs-versioned-blob"),
Storage.BlobListOption.versions(true));
}
Set<String> blobSet = ImmutableSet.of(blobNames[0], blobNames[1]);
for (Blob remoteBlob : page.values()) {
Iterator<Blob> iterator = page.iterateAll();
while (iterator.hasNext()) {
Blob remoteBlob = iterator.next();
assertEquals(bucketName, remoteBlob.bucket());
assertTrue(blobSet.contains(remoteBlob.name()));
assertNotNull(remoteBlob.generation());
Expand Down

0 comments on commit 622dcc9

Please sign in to comment.