Removed unneeded check for prefix in clearContainer

This commit is contained in:
Joe Meiring 2018-11-01 17:01:50 -05:00 committed by Andrew Gaul
parent bbb41b4590
commit 22ce5484a4
3 changed files with 73 additions and 3 deletions

View File

@ -380,9 +380,6 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
public void execute(final String containerName,
ListContainerOptions listOptions) {
if (listOptions.getDelimiter() != null || listOptions.getPrefix() != null) {
throw new IllegalArgumentException("Prefix and delimiter support has not yet been added");
}
final AtomicBoolean deleteFailure = new AtomicBoolean();
int retries = maxErrors;

View File

@ -80,6 +80,14 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest<BlobStoreCont
String.format(XML_STRING_FORMAT, "candy"), "path/4", String.format(XML_STRING_FORMAT, "dogma"), "path/5",
String.format(XML_STRING_FORMAT, "emma"));
private static final Map<String, String> FILE_NESTED_STRINGS = ImmutableMap.of(
"path/1/a", String.format(XML_STRING_FORMAT, "apple"),
"path/1/2/b", String.format(XML_STRING_FORMAT, "bear"),
"path/1/2/3/c", String.format(XML_STRING_FORMAT, "candy"),
"path/1/2/3/4/d", String.format(XML_STRING_FORMAT, "dog"),
"path/1/2/3/5/e", String.format(XML_STRING_FORMAT, "echo")
);
public static long INCONSISTENCY_WINDOW = 10000;
protected static final AtomicInteger containerIndex = new AtomicInteger(0);
@ -282,6 +290,14 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest<BlobStoreCont
}
}
protected void add5NestedBlobsToContainer(String sourceContainer) {
for (Entry<String, String> entry : FILE_NESTED_STRINGS.entrySet()) {
Blob sourceObject = view.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue())
.contentType("text/xml").build();
addBlobToContainer(sourceContainer, sourceObject);
}
}
protected String addBlobToContainer(String sourceContainer, Blob object) {
return view.getBlobStore().putBlob(sourceContainer, object);
}

View File

@ -176,6 +176,63 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
}
}
@Test(groups = { "integration", "live" })
public void testClearWithOptions() throws InterruptedException {
String containerName = getContainerName();
try {
ListContainerOptions options;
add5NestedBlobsToContainer(containerName);
options = new ListContainerOptions();
options.prefix("path/1/");
options.recursive();
view.getBlobStore().clearContainer(containerName, options);
assertConsistencyAwareContainerSize(containerName, 0);
view.getBlobStore().clearContainer(containerName);
add5NestedBlobsToContainer(containerName);
options = new ListContainerOptions();
options.prefix("path/1/2/3");
options.recursive();
view.getBlobStore().clearContainer(containerName, options);
assertConsistencyAwareContainerSize(containerName, 2);
view.getBlobStore().clearContainer(containerName);
add5NestedBlobsToContainer(containerName);
options = new ListContainerOptions();
options.prefix("path/1/2/3/4/");
options.recursive();
view.getBlobStore().clearContainer(containerName, options);
assertConsistencyAwareContainerSize(containerName, 4);
// non-recursive, should not clear anything, as prefix does not match
view.getBlobStore().clearContainer(containerName);
add5NestedBlobsToContainer(containerName);
options = new ListContainerOptions();
options.prefix("path/1/2/3");
view.getBlobStore().clearContainer(containerName, options);
assertConsistencyAwareContainerSize(containerName, 5);
// non-recursive, should only clear path/1/2/3/c
view.getBlobStore().clearContainer(containerName);
add5NestedBlobsToContainer(containerName);
options = new ListContainerOptions();
options.prefix("path/1/2/3/");
view.getBlobStore().clearContainer(containerName, options);
assertConsistencyAwareContainerSize(containerName, 4);
// non-recursive, should only clear path/1/2/3/c
view.getBlobStore().clearContainer(containerName);
add5NestedBlobsToContainer(containerName);
options = new ListContainerOptions();
options.prefix("path/1/2/3/c");
view.getBlobStore().clearContainer(containerName, options);
assertConsistencyAwareContainerSize(containerName, 4);
} finally {
returnContainer(containerName);
}
}
@Test(groups = { "integration", "live" })
public void testListContainerMarker() throws InterruptedException {
String containerName = getContainerName();