protected String addBlobToContainer(String sourceContainer, String key) { return addBlobToContainer(sourceContainer, key, TEST_STRING, MediaType.TEXT_XML); }
/** * requestor will create a container using the name returned from this. This method will take * care not to exceed the maximum containers permitted by a provider by deleting an existing * container first. * * @throws InterruptedException */ public String getScratchContainerName() throws InterruptedException { return allocateNewContainerName(getContainerName()); }
protected void assertConsistencyAwareContainerExists(final String containerName) throws InterruptedException { assertConsistencyAware(new Runnable() { public void run() { try { assert view.getBlobStore().containerExists(containerName) : String.format("container %s doesn't exist", containerName); } catch (Exception e) { Throwables.propagate(e); } } }); }
protected String recycleContainer(final String container) throws InterruptedException { String newScratchContainer = allocateNewContainerName(container); createContainerAndEnsureEmpty(newScratchContainer); return newScratchContainer; }
protected Iterable<Module> setupModules() { return ImmutableSet.<Module> of(getLoggingModule(), createHttpModule()); }
synchronized (BaseBlobStoreIntegrationTest.class) { if (!initialized) { deleteEverything(context); for (; containerIndex.get() < containerCount; containerIndex.incrementAndGet()) { String containerName = CONTAINER_PREFIX + containerIndex; } else { try { createContainerAndEnsureEmpty(context, containerName, false); if (context.getBlobStore().containerExists(containerName)) containerNames.put(containerName); else { deleteContainerOrWarnIfUnable(context, containerName); containerCount++; deleteContainerOrWarnIfUnable(context, containerName); containerCount++; awaitConsistency(); testContext.setAttribute("containerNames", containerNames); System.err.printf("*** containers to test: %s%n", containerNames);
protected Blob validateContent(String container, String name) throws InterruptedException { assertConsistencyAwareContainerSize(container, 1); Blob newObject = view.getBlobStore().getBlob(container, name); assert newObject != null; validateMetadata(newObject.getMetadata(), container, name); try { assertEquals(getContentAsStringOrNullAndClose(newObject), TEST_STRING); } catch (IOException e) { throw new RuntimeException(e); } return newObject; }
synchronized (BaseBlobStoreIntegrationTest.class) { if (!initialized) { deleteEverything(context); for (; containerIndex.get() < containerCount; containerIndex.incrementAndGet()) { String containerName = CONTAINER_PREFIX + containerIndex; } else { try { createContainerAndEnsureEmpty(context, containerName); if (context.getBlobStore().containerExists(containerName)) containerNames.put(containerName); else { deleteContainerOrWarnIfUnable(context, containerName); containerCount++; deleteContainerOrWarnIfUnable(context, containerName); containerCount++;
@Override protected Properties setupProperties() { Properties props = super.setupProperties(); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); return props; }
/** * There are a lot of retries here mainly from experience running inside amazon EC2. */ @BeforeSuite public void setUpResourcesForAllThreads(ITestContext testContext) throws Exception { setupContext(); createContainersSharedByAllThreads(view, testContext); view.close(); view = null; }
@AfterSuite(groups = { "integration", "live" }) protected void destroyResources() throws Exception { setupContext(); deleteEverything(view); view.close(); view = null; }
protected void createContainerAndEnsureEmpty(String containerName) throws InterruptedException { createContainerAndEnsureEmpty(view, containerName); }
/** * Tries to delete all containers, runs up to two times */ protected static void deleteEverything(final BlobStoreContext context) throws Exception { try { for (int i = 0; i < 2; i++) { Iterable<? extends StorageMetadata> testContainers = Iterables.filter(context.getBlobStore().list(), new Predicate<StorageMetadata>() { public boolean apply(StorageMetadata input) { return (input.getType() == StorageType.CONTAINER || input.getType() == StorageType.FOLDER) && input.getName().startsWith(CONTAINER_PREFIX); } }); for (StorageMetadata container : testContainers) { deleteContainerOrWarnIfUnable(context, container.getName()); } } // try twice } catch (CancellationException e) { throw e; } }
protected Blob validateContent(String container, String name) throws InterruptedException { assertConsistencyAwareContainerSize(container, 1); Blob newObject = view.getBlobStore().getBlob(container, name); assert newObject != null; validateMetadata(newObject.getMetadata(), container, name); try { assertEquals(getContentAsStringOrNullAndClose(newObject), TEST_STRING); } catch (IOException e) { throw new RuntimeException(e); } return newObject; }
@Override protected Properties setupProperties() { Properties props = super.setupProperties(); setIfTestSystemPropertyPresent(props, CREDENTIAL_TYPE); return props; }
/** * There are a lot of retries here mainly from experience running inside amazon EC2. */ @BeforeSuite(groups = { "integration", "live" }) public void setUpResourcesForAllThreads(ITestContext testContext) throws Exception { setupContext(); createContainersSharedByAllThreads(view, testContext); view.close(); view = null; }
protected String recycleContainer(final String container) throws InterruptedException { String newScratchContainer = allocateNewContainerName(container); createContainerAndEnsureEmpty(newScratchContainer); return newScratchContainer; }
protected Iterable<Module> setupModules() { return ImmutableSet.<Module> of(getLoggingModule(), createHttpModule()); }
protected void createContainerAndEnsureEmpty(String containerName) throws InterruptedException { createContainerAndEnsureEmpty(view, containerName, true); }
/** * Tries to delete all containers, runs up to two times */ protected static void deleteEverything(final BlobStoreContext context) throws Exception { try { for (int i = 0; i < 2; i++) { Iterable<? extends StorageMetadata> testContainers = Iterables.filter(context.getBlobStore().list(), new Predicate<StorageMetadata>() { public boolean apply(StorageMetadata input) { return (input.getType() == StorageType.CONTAINER || input.getType() == StorageType.FOLDER) && input.getName().startsWith(CONTAINER_PREFIX); } }); for (StorageMetadata container : testContainers) { deleteContainerOrWarnIfUnable(context, container.getName()); } } // try twice } catch (CancellationException e) { throw e; } }