@Test(expectedExceptions = AWSResponseException.class) void testDescribeSnapshotsWithFilterInvalid() { String region = defaultRegion; SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); assertNotNull(allResults); if (!allResults.isEmpty()) { Snapshot snapshot = allResults.last(); client.describeSnapshotsInRegionWithFilter(region, ImmutableMultimap.<String, String>builder() .put("invalid-filter", snapshot.getId()).build()); } }
@Test void testDescribeSnapshots() { String region = defaultRegion; SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); assertNotNull(allResults); if (!allResults.isEmpty()) { Snapshot snapshot = allResults.last(); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegion(region, snapshotIds(snapshot.getId()))); assertNotNull(result); assertEquals(result, snapshot); } }
/** * Create a snapshot of the volume attached to the VM * @param vmi a VMInstance */ public String createSnapshot(VMInstance vmi){ NodeMetadata nm=getVMById(vmi.getId()); ElasticBlockStoreApi ebsClient = ec2api.getElasticBlockStoreApi().get(); journal.log(Level.INFO, ">> Creating snapshot of VM: "+vmi.getName()); Snapshot snapshot = ebsClient.createSnapshotInRegion("eu-west-1", nm.getHardware().getVolumes().get(0).getId()); String status=""; while (!status.toLowerCase().equals("completed")){ for(Snapshot s:ebsClient.describeSnapshotsInRegion("eu-west-1")) if(s.getId().equals(snapshot.getId())){ status=s.getStatus().name(); } try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } journal.log(Level.INFO, ">> Snapshot created with ID: "+snapshot.getId()); return snapshot.getId(); }
@Test void testDescribeSnapshotsWithFilter() { String region = defaultRegion; SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); assertNotNull(allResults); if (!allResults.isEmpty()) { Snapshot snapshot = allResults.last(); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegionWithFilter(region, ImmutableMultimap.<String, String>builder() .put("snapshot-id", snapshot.getId()).build())); assertNotNull(result); assertEquals(result, snapshot); } }
@Test(dependsOnMethods = "testDeleteVolumeInRegion") void testDeleteSnapshotInRegion() { client.deleteSnapshotInRegion(defaultRegion, snapshot.getId()); assert client.describeSnapshotsInRegion(defaultRegion, snapshotIds(snapshot.getId())).size() == 0; }
public boolean apply(Snapshot snapshot) { logger.trace("looking for status on snapshot %s", snapshot.getId()); snapshot = Iterables.getOnlyElement(client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId()))); logger.trace("%s: looking for status %s: currently: %s; progress %d/100", snapshot, Snapshot.Status.COMPLETED, snapshot.getStatus(), snapshot.getProgress()); return snapshot.getStatus() == Snapshot.Status.COMPLETED; }
public boolean apply(Snapshot snapshot) { logger.trace("looking for status on snapshot %s", snapshot.getId()); snapshot = Iterables.getOnlyElement(client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId()))); logger.trace("%s: looking for status %s: currently: %s; progress %d/100", snapshot, Snapshot.Status.COMPLETED, snapshot.getStatus(), snapshot.getProgress()); return snapshot.getStatus() == Snapshot.Status.COMPLETED; }
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone") void testCreateSnapshotInRegion() { Snapshot snapshot = client.createSnapshotInRegion(defaultRegion, volumeId); Predicate<Snapshot> snapshotted = retry(new SnapshotCompleted(client), 600, 10, SECONDS); assert snapshotted.apply(snapshot); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegion(defaultRegion, snapshotIds(snapshot.getId()))); assertEquals(result.getProgress(), 100); this.snapshot = result; }
public boolean apply(Snapshot snapshot) { logger.trace("looking for status on snapshot %s", snapshot.getId()); snapshot = Iterables.getOnlyElement(client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId()))); logger.trace("%s: looking for status %s: currently: %s; progress %d/100", snapshot, Snapshot.Status.COMPLETED, snapshot.getStatus(), snapshot.getProgress()); return snapshot.getStatus() == Snapshot.Status.COMPLETED; }