Ejemplo n.º 1
0
  @Test
  public void testCreateBackupOfServer() throws InterruptedException {
    skipOnAdminExtensionAbsent();
    backupImageId =
        apiOption
            .get()
            .createBackup(
                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 (extensionApi.get("OS-EXT-STS") == null) {
      Thread.sleep(30000);
    }

    blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);

    Image backupImage = imageApi.get(backupImageId);
    assertEquals(backupImage.getId(), backupImageId);
  }
  @Test
  public void testTryStackNatty() {

    String name = "natty-server-cloudimg-amd64";

    Image imageToConvert = Image.builder().id("id-" + name).name(name).build();

    OperatingSystem convertedOs = converterForUbuntu.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), OsFamily.UBUNTU);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), "11.04");
    assertEquals(convertedOs.getArch(), null);
    assertTrue(convertedOs.is64Bit());
  }
  @Test(dataProvider = "getOsFamilyValues")
  public void testOsFamilyValues(OsFamily family) {

    Image imageToConvert = Image.builder().id("id-" + family.name()).name(family.name()).build();

    ImageToOperatingSystem converter =
        new ImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());

    OperatingSystem convertedOs = converter.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), family);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), null);
    assertEquals(convertedOs.getArch(), null);
    assertTrue(convertedOs.is64Bit());
  }
  @Test
  public void testOEL() {
    String name = "Oracle EL";

    Image imageToConvert = Image.builder().id("id-" + name).name(name).build();

    ImageToOperatingSystem converter =
        new ImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());

    OperatingSystem convertedOs = converter.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), OsFamily.OEL);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), null);
    assertEquals(convertedOs.getArch(), null);
    assertTrue(convertedOs.is64Bit());
  }
  @Test
  public void testWindows98x86() {
    String name = "Windows 98 x86";

    Image imageToConvert = Image.builder().id("id-" + name).name(name).build();

    Map<OsFamily, Map<String, String>> osFamilyMap = new HashMap<OsFamily, Map<String, String>>();
    osFamilyMap.put(OsFamily.WINDOWS, ImmutableMap.of("98", "98"));

    ImageToOperatingSystem converter = new ImageToOperatingSystem(osFamilyMap);

    OperatingSystem convertedOs = converter.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), OsFamily.WINDOWS);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), "98");
    assertEquals(convertedOs.getArch(), null);
    assertFalse(convertedOs.is64Bit());
  }