Java Code Examples for com.google.cloud.storage.testing.RemoteStorageHelper#forceDelete()

The following examples show how to use com.google.cloud.storage.testing.RemoteStorageHelper#forceDelete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ITBucketSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void afterClass() throws ExecutionException, InterruptedException {
  if (storage != null) {
    boolean wasDeleted = RemoteStorageHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS);
    if (!wasDeleted && log.isLoggable(Level.WARNING)) {
      log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET);
    }
  }
}
 
Example 2
Source File: ITBlobSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void afterClass() throws ExecutionException, InterruptedException {
  if (storage != null) {
    boolean wasDeleted = RemoteStorageHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS);
    if (!wasDeleted && log.isLoggable(Level.WARNING)) {
      log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET);
    }
  }
}
 
Example 3
Source File: ITStorageSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void afterClass() throws ExecutionException, InterruptedException {
  if (storage != null) {
    // In beforeClass, we make buckets auto-delete blobs older than a day old.
    // Here, delete all buckets older than 2 days. They should already be empty and easy.
    long cleanTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(2);
    long cleanTimeout = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(1);
    RemoteStorageHelper.cleanBuckets(storage, cleanTime, cleanTimeout);

    boolean wasDeleted = RemoteStorageHelper.forceDelete(storage, BUCKET, 1, TimeUnit.MINUTES);
    if (!wasDeleted && log.isLoggable(Level.WARNING)) {
      log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET);
    }
  }
}
 
Example 4
Source File: GcsBucket.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
/** Remove all resources we created in GCS. */
@Override
protected void finished(Description description) {
  RemoteStorageHelper.forceDelete(storage, bucket);
}
 
Example 5
Source File: KeyStoreIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 4 votes vote down vote up
/** Clean up storage resources. */
@After
public void deleteBucket() throws Exception {
  RemoteStorageHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
}
 
Example 6
Source File: ITTableSnippets.java    From google-cloud-java with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void afterClass() {
  RemoteBigQueryHelper.forceDelete(bigquery, DATASET_NAME);
  RemoteBigQueryHelper.forceDelete(bigquery, COPY_DATASET_NAME);
  RemoteStorageHelper.forceDelete(storage, BUCKET_NAME);
}
 
Example 7
Source File: StorageIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Clean up all GCS resources we created.
 *
 * @throws Exception if BigQuery is unavailable
 */
@After
public void deleteBucket() throws Exception {
  RemoteStorageHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
}