/** Ensures that the right object is returned. */
  @Test
  public void testGet() {
    VdsDynamic result = dao.get(existingVds.getId());

    assertNotNull(result);
    assertEquals(existingVds.getId(), result.getId());
  }
 @Test
 public void testUpdateStatus() {
   VdsDynamic before = dao.get(existingVds.getId());
   before.setStatus(VDSStatus.Down);
   dao.updateStatus(before.getId(), before.getStatus());
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before, after);
 }
 @Test
 public void testGlusterVersion() {
   RpmVersion glusterVersion = new RpmVersion("glusterfs-3.4.0.34.1u2rhs-1.el6rhs");
   VdsDynamic before = dao.get(existingVds.getId());
   before.setGlusterVersion(glusterVersion);
   dao.update(before);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(glusterVersion, after.getGlusterVersion());
 }
 @Test
 public void testUpdateLibrbdVersion() {
   RpmVersion librbdVersion = new RpmVersion("librbd1-0.80.9-1.fc21.x86_64_updated");
   VdsDynamic before = dao.get(existingVds.getId());
   assertNotEquals(librbdVersion, before.getLibrbdVersion());
   before.setLibrbdVersion(librbdVersion);
   dao.update(before);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(librbdVersion, after.getLibrbdVersion());
 }
 @Test
 public void testUpdateNetConfigDirty() {
   VdsDynamic before = dao.get(existingVds.getId());
   Boolean netConfigDirty = before.getNetConfigDirty();
   netConfigDirty = Boolean.FALSE.equals(netConfigDirty);
   before.setNetConfigDirty(netConfigDirty);
   dao.updateNetConfigDirty(before.getId(), netConfigDirty);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before, after);
 }
 private void checkKdumpIntegrationStatus() {
   VdsStatic vdsSt = getParameters().getVdsStaticData();
   if (vdsSt.isPmEnabled() && vdsSt.isPmKdumpDetection()) {
     VdsDynamic vdsDyn = getDbFacade().getVdsDynamicDao().get(vdsSt.getId());
     if (vdsDyn != null && vdsDyn.getKdumpStatus() != KdumpStatus.ENABLED) {
       auditLogDirector.log(
           new AuditLogableBase(vdsSt.getId()),
           AuditLogType.KDUMP_DETECTION_NOT_CONFIGURED_ON_VDS);
     }
   }
 }
示例#7
0
 private void addVdsDynamicToDb() {
   VdsDynamic vdsDynamic = new VdsDynamic();
   vdsDynamic.setId(getParameters().getVdsStaticData().getId());
   // TODO: oVirt type - here oVirt behaves like power client?
   if (getParameters().isPending()) {
     vdsDynamic.setStatus(VDSStatus.PendingApproval);
   } else if (getParameters().isProvisioned()) {
     vdsDynamic.setStatus(VDSStatus.InstallingOS);
   } else if (Config.<Boolean>getValue(ConfigValues.InstallVds)) {
     vdsDynamic.setStatus(VDSStatus.Installing);
   }
   vdsDynamicDao.save(vdsDynamic);
   getCompensationContext().snapshotNewEntity(vdsDynamic);
 }
 @Test
 public void testUpdateAvailableUpdates() {
   VdsDynamic before = dao.get(existingVds.getId());
   assertFalse(before.isUpdateAvailable());
   before.setUpdateAvailable(true);
   dao.updateUpdateAvailable(before.getId(), before.isUpdateAvailable());
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before.isUpdateAvailable(), after.isUpdateAvailable());
 }
 @Test
 public void testUpdateHostExternalStatus() {
   VdsDynamic before = dao.get(existingVds.getId());
   before.setExternalStatus(ExternalStatus.Error);
   dao.updateExternalStatus(before.getId(), before.getExternalStatus());
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before.getExternalStatus(), after.getExternalStatus());
 }
  /** Ensures saving a VDS instance works. */
  @Test
  public void testSave() {
    staticDao.save(newStaticVds);
    newDynamicVds.setId(newStaticVds.getId());
    newDynamicVds.setUpdateAvailable(true);
    dao.save(newDynamicVds);

    VdsStatic staticResult = staticDao.get(newStaticVds.getId());
    VdsDynamic dynamicResult = dao.get(newDynamicVds.getId());

    assertNotNull(staticResult);
    assertEquals(newStaticVds, staticResult);
    assertNotNull(dynamicResult);
    assertEquals(newDynamicVds, dynamicResult);
    assertEquals(newDynamicVds.isUpdateAvailable(), dynamicResult.isUpdateAvailable());
  }
 @Test
 public void testUpdateStatusAndReasons() {
   VdsDynamic before = dao.get(existingVds.getId());
   before.setStatus(RandomUtils.instance().nextEnum(VDSStatus.class));
   before.setNonOperationalReason(RandomUtils.instance().nextEnum(NonOperationalReason.class));
   before.setMaintenanceReason(RandomUtils.instance().nextString(50));
   dao.updateStatusAndReasons(before);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before, after);
   assertEquals(before.getStatus(), after.getStatus());
   assertEquals(before.getNonOperationalReason(), after.getNonOperationalReason());
   assertEquals(before.getMaintenanceReason(), after.getMaintenanceReason());
 }