@Test public void testCreateBackupOfServer() throws InterruptedException { if (clientOption.isPresent()) { backupImageId = clientOption .get() .createBackupOfServer( testServerId, "jclouds-test-backup", BackupType.DAILY, 0, CreateBackupOfServerOptions.Builder.metadata( ImmutableMap.of("test", "metadata"))); assertNotNull(backupImageId); // If we don't have extended task status, we'll have to wait here! if (extensionClient.getExtensionByAlias("OS-EXT-STS") == null) { Thread.sleep(30000); } blockUntilServerInState(testServerId, serverClient, Server.Status.ACTIVE); Image backupImage = imageClient.getImage(backupImageId); assertEquals(backupImage.getId(), backupImageId); } }
@Test public void testConversionWhereLocationFound() { UUID id = UUID.randomUUID(); Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build(); OperatingSystem operatingSystem = new OperatingSystem( OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86", "My Test OS", true); ImageInZoneToImage converter = new ImageInZoneToImage(new MockImageToOsConverter(operatingSystem), locationIndex); ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "az-1.region-a.geo-1"); org.jclouds.compute.domain.Image convertedImage = converter.apply(novaImageInZoneToConvert); assertEquals(convertedImage.getId(), novaImageInZoneToConvert.slashEncode()); assertEquals(convertedImage.getProviderId(), novaImageToConvert.getId()); assertEquals(convertedImage.getLocation(), locationIndex.get().get("az-1.region-a.geo-1")); assertEquals(convertedImage.getName(), novaImageToConvert.getName()); assertEquals(convertedImage.getOperatingSystem(), operatingSystem); }
@Test(expectedExceptions = IllegalStateException.class) public void testConversionWhereLocationNotFound() { UUID id = UUID.randomUUID(); Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build(); OperatingSystem operatingSystem = new OperatingSystem( OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86", "My Test OS", true); ImageInZoneToImage converter = new ImageInZoneToImage(new MockImageToOsConverter(operatingSystem), locationIndex); ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "South"); converter.apply(novaImageInZoneToConvert); }