use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsDefaultCase.
@Test
public void testFilterUpgradeOptionsDefaultCase() {
UpgradeV4Request request = new UpgradeV4Request();
request.setDryRun(true);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
assertEquals(2, response.getUpgradeCandidates().size());
assertEquals(2, response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).collect(Collectors.toSet()).size());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsLockComponents.
@Test
public void testFilterUpgradeOptionsLockComponents() {
UpgradeV4Request request = new UpgradeV4Request();
request.setLockComponents(true);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true);
assertEquals(2, response.getUpgradeCandidates().size());
assertTrue(response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).anyMatch(id -> id.equals(IMAGE_ID_LAST)));
assertTrue(response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).anyMatch(id -> id.equals(IMAGE_ID)));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsImageIdInvalid.
@Test
public void testFilterUpgradeOptionsImageIdInvalid() {
UpgradeV4Request request = new UpgradeV4Request();
request.setImageId(ANOTHER_IMAGE_ID);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
Exception e = Assertions.assertThrows(BadRequestException.class, () -> underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true));
Assert.assertEquals("The given image (another-image-id) is not eligible for the cluster upgrade. " + "Please choose an id from the following image(s): image-id-first,image-id-last", e.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityServiceTest method testFilterUpgradeOptionsRuntimeInvalid.
@Test
public void testFilterUpgradeOptionsRuntimeInvalid() {
UpgradeV4Request request = new UpgradeV4Request();
request.setRuntime(ANOTHER_TARGET_RUNTIME);
UpgradeV4Response response = new UpgradeV4Response();
ImageInfoV4Response imageInfo = new ImageInfoV4Response();
imageInfo.setImageId(IMAGE_ID);
imageInfo.setCreated(1);
imageInfo.setComponentVersions(createExpectedPackageVersions());
ImageInfoV4Response lastImageInfo = new ImageInfoV4Response();
lastImageInfo.setImageId(IMAGE_ID_LAST);
lastImageInfo.setCreated(2);
lastImageInfo.setComponentVersions(createExpectedPackageVersions());
response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo));
Exception e = Assertions.assertThrows(BadRequestException.class, () -> underTest.filterUpgradeOptions(ACCOUNT_ID, response, request, true));
Assert.assertEquals("There is no image eligible for the cluster upgrade with runtime: 7.2.0. " + "Please choose a runtime from the following: 7.0.2", e.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request in project cloudbreak by hortonworks.
the class DistroXUpgradeImageSelectorTest method testSelectedImageByIdNotInCandidates.
@Test
public void testSelectedImageByIdNotInCandidates() {
List<ImageInfoV4Response> candidates = List.of(createImageResponse("A", 1L, "5"), createImageResponse("B", 6L, "3"), createImageResponse("C", 3L, "1"));
UpgradeV4Request request = new UpgradeV4Request();
request.setImageId("D");
assertThrows(BadRequestException.class, () -> underTest.determineImageId(request, candidates));
}
Aggregations