Search in sources :

Example 16 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CachedImageCatalogWrapperProviderTest method testReadImageCatalogFromFile.

@Test
public void testReadImageCatalogFromFile() throws Exception {
    String path = getPath(CB_IMAGE_CATALOG_V2_JSON);
    ReflectionTestUtils.setField(underTest, "etcConfigDir", path);
    ReflectionTestUtils.setField(underTest, "enabledLinuxTypes", Collections.emptyList());
    CloudbreakImageCatalogV3 catalog = underTest.getImageCatalogWrapper(CB_IMAGE_CATALOG_V2_JSON).getImageCatalog();
    assertNotNull(catalog);
    Optional<CloudbreakVersion> ver = catalog.getVersions().getCloudbreakVersions().stream().filter(v -> v.getVersions().contains(CB_VERSION)).findFirst();
    Assertions.assertTrue(ver.isPresent(), "Check that the parsed ImageCatalog contains the desired version of Cloudbreak.");
    List<String> imageIds = ver.get().getImageIds();
    assertNotNull(imageIds);
    Optional<String> imageIdOptional = imageIds.stream().findFirst();
    Assertions.assertTrue(imageIdOptional.isPresent(), "Check that the parsed ImageCatalog contains image reference for the Cloudbreak version.");
    String imageId = imageIdOptional.get();
    boolean baseImageFound = false;
    if (catalog.getImages().getBaseImages() != null) {
        baseImageFound = catalog.getImages().getBaseImages().stream().anyMatch(i -> i.getUuid().equals(imageId));
    }
    Assertions.assertTrue(baseImageFound, "Check that the parsed ImageCatalog contains image for the Cloudbreak version.");
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) RestClientFactory(com.sequenceiq.cloudbreak.client.RestClientFactory) Mock(org.mockito.Mock) Client(javax.ws.rs.client.Client) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) CloudbreakVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion) Spy(org.mockito.Spy) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) Invocation(javax.ws.rs.client.Invocation) Collectors(java.util.stream.Collectors) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test) ImageCatalogServiceProxy(com.sequenceiq.cloudbreak.service.image.catalog.ImageCatalogServiceProxy) List(java.util.List) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) Lists(org.assertj.core.util.Lists) Assertions(org.junit.jupiter.api.Assertions) Optional(java.util.Optional) WebTarget(javax.ws.rs.client.WebTarget) Collections(java.util.Collections) CloudbreakVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.jupiter.api.Test)

Example 17 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CloudbreakVersionListProviderTest method testGetVersionsWithFreeipaVersions.

@Test
public void testGetVersionsWithFreeipaVersions() {
    CloudbreakImageCatalogV3 catalog = new CloudbreakImageCatalogV3(null, new Versions(null, freeipaVersions()));
    List<CloudbreakVersion> versions = underTest.getVersions(catalog);
    assertEquals(1, versions.size());
    assertEquals(FREEIPA_VERSIONS, versions.get(0).getVersions());
    assertEquals(FREEIPA_IMAGE_IDS, versions.get(0).getImageIds());
    assertTrue(versions.get(0).getDefaults().isEmpty());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) CloudbreakVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.Test)

Example 18 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class CloudbreakVersionListProviderTest method testGetVersionsWithCloudbreakVersions.

@Test
public void testGetVersionsWithCloudbreakVersions() {
    CloudbreakImageCatalogV3 catalog = new CloudbreakImageCatalogV3(null, new Versions(cloudbreakVersions(), null));
    List<CloudbreakVersion> versions = underTest.getVersions(catalog);
    assertEquals(1, versions.size());
    assertEquals(CLOUDBREAK_VERSIONS, versions.get(0).getVersions());
    assertEquals(CLOUDBREAK_IMAGE_IDS, versions.get(0).getImageIds());
    assertEquals(CLOUDBREAK_DEFAULTS, versions.get(0).getDefaults());
}
Also used : Versions(com.sequenceiq.cloudbreak.cloud.model.catalog.Versions) CloudbreakVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion) CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) Test(org.junit.Test)

Example 19 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class ImageProviderTest method testGetCurrentImageFromCatalogShouldThrowExceptionWhenTheCurrentImageIsNotFound.

@Test
public void testGetCurrentImageFromCatalogShouldThrowExceptionWhenTheCurrentImageIsNotFound() {
    CloudbreakImageCatalogV3 imageCatalog = createImageCatalog(List.of("other-image1", "other-image2"));
    Exception exception = assertThrows(CloudbreakImageNotFoundException.class, () -> underTest.getCurrentImageFromCatalog(CURRENT_IMAGE_ID, imageCatalog));
    assertEquals("Image not found with id: current-image", exception.getMessage());
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test)

Example 20 with CloudbreakImageCatalogV3

use of com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3 in project cloudbreak by hortonworks.

the class PrefixMatcherServiceTest method getVersions.

private static Collection<CloudbreakVersion> getVersions(String catalogFilePath) throws IOException {
    String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFilePath);
    CloudbreakImageCatalogV3 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV3.class);
    return catalog.getVersions().getCloudbreakVersions();
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)

Aggregations

CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)48 Test (org.junit.jupiter.api.Test)21 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)17 Test (org.junit.Test)14 ImageFilterResult (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterResult)10 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)8 ImageFilterParams (com.sequenceiq.cloudbreak.service.upgrade.image.ImageFilterParams)8 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)6 CloudbreakVersion (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion)5 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)5 StatedImages (com.sequenceiq.cloudbreak.service.image.StatedImages)5 Image (com.sequenceiq.cloudbreak.cloud.model.Image)4 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)4 List (java.util.List)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Versions (com.sequenceiq.cloudbreak.cloud.model.catalog.Versions)3 ImageFilter (com.sequenceiq.cloudbreak.service.image.ImageFilter)3 ImageCatalogWrapper (com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogWrapper)3