use of com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request in project cloudbreak by hortonworks.
the class UpgradeConverterTest method testConvertRequestWhenInternal.
@Test
public void testConvertRequestWhenInternal() {
// GIVEN
DistroXUpgradeV1Request source = new DistroXUpgradeV1Request();
// WHEN
UpgradeV4Request result = underTest.convert(source, new InternalUpgradeSettings(true, true, true));
// THEN
assertTrue(result.getInternalUpgradeSettings().isSkipValidations());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request in project cloudbreak by hortonworks.
the class DistroXUpgradeV1ControllerTest method testDryRun.
@Test
public void testDryRun() {
DistroXUpgradeV1Request distroxUpgradeRequest = new DistroXUpgradeV1Request();
UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
upgradeV4Request.setDryRun(Boolean.TRUE);
when(upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
when(upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
when(upgradeConverter.convert(distroxUpgradeRequest, new InternalUpgradeSettings(false, true, true))).thenReturn(upgradeV4Request);
UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
when(upgradeAvailabilityService.checkForUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, upgradeV4Request, USER_CRN)).thenReturn(upgradeV4Response);
when(upgradeConverter.convert(upgradeV4Response)).thenReturn(new DistroXUpgradeV1Response());
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, distroxUpgradeRequest));
verify(upgradeAvailabilityService).checkForUpgrade(NameOrCrn.ofName(CLUSTER_NAME), WORKSPACE_ID, upgradeV4Request, USER_CRN);
verifyNoInteractions(upgradeService);
}
use of com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request in project cloudbreak by hortonworks.
the class UpgradeConverterTest method testConvertRequest.
@Test
public void testConvertRequest() {
DistroXUpgradeV1Request source = new DistroXUpgradeV1Request();
source.setDryRun(Boolean.TRUE);
source.setImageId("asdf");
source.setShowAvailableImages(DistroXUpgradeShowAvailableImages.LATEST_ONLY);
source.setLockComponents(Boolean.TRUE);
source.setReplaceVms(DistroXUpgradeReplaceVms.DISABLED);
source.setRuntime("runtime");
UpgradeV4Request result = underTest.convert(source, new InternalUpgradeSettings(false, true, true));
assertEquals(source.getDryRun(), result.getDryRun());
assertEquals(source.getImageId(), result.getImageId());
assertEquals(source.getShowAvailableImages().name(), result.getShowAvailableImages().name());
assertEquals(source.getLockComponents(), result.getLockComponents());
assertEquals(Boolean.FALSE, result.getReplaceVms());
assertEquals(source.getRuntime(), result.getRuntime());
assertFalse(result.getInternalUpgradeSettings().isSkipValidations());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request in project cloudbreak by hortonworks.
the class UpgradeConverterTest method testConvertRequestWhenReplaceVmsParamIsNotGiven.
@Test
public void testConvertRequestWhenReplaceVmsParamIsNotGiven() {
// GIVEN
DistroXUpgradeV1Request source = new DistroXUpgradeV1Request();
// WHEN
UpgradeV4Request result = underTest.convert(source, new InternalUpgradeSettings(false, true, true));
// THEN
assertNull(result.getReplaceVms());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request in project cloudbreak by hortonworks.
the class DistroXUpgradeV1ControllerTest method testUpgradeCalledWithCrn.
@Test
public void testUpgradeCalledWithCrn() {
DistroXUpgradeV1Request distroxUpgradeRequest = new DistroXUpgradeV1Request();
UpgradeV4Request upgradeV4Request = new UpgradeV4Request();
upgradeV4Request.setDryRun(Boolean.FALSE);
when(upgradeAvailabilityService.isRuntimeUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
when(upgradeAvailabilityService.isOsUpgradeEnabledByAccountId(ACCOUNT_ID)).thenReturn(true);
when(upgradeConverter.convert(distroxUpgradeRequest, new InternalUpgradeSettings(false, true, true))).thenReturn(upgradeV4Request);
UpgradeV4Response upgradeV4Response = new UpgradeV4Response();
when(upgradeService.triggerUpgrade(NameOrCrn.ofCrn(CLUSTER_NAME), WORKSPACE_ID, USER_CRN, upgradeV4Request)).thenReturn(upgradeV4Response);
when(upgradeConverter.convert(upgradeV4Response)).thenReturn(new DistroXUpgradeV1Response());
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.upgradeClusterByCrn(CLUSTER_NAME, distroxUpgradeRequest));
verify(upgradeService).triggerUpgrade(NameOrCrn.ofCrn(CLUSTER_NAME), WORKSPACE_ID, USER_CRN, upgradeV4Request);
}
Aggregations