use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class UpdateRecipeService method refreshRecipesForCluster.
/**
* Updating recipes for an existing cluster. The input should contain host group - recipes mapping
* If a host group key from the mappings is missing from the input, that is not going to be updated.
* (or both - that is the default). Output is the newly attached/detached recipes in db.
*/
public UpdateRecipesV4Response refreshRecipesForCluster(Long workspaceId, Stack stack, List<UpdateHostGroupRecipes> recipesPerHostGroup) {
Set<String> recipesToFind = recipesPerHostGroup.stream().flatMap(rphg -> rphg.getRecipeNames().stream()).collect(Collectors.toSet());
Map<String, Set<String>> recipesToUpdate = recipesPerHostGroup.stream().collect(Collectors.toMap(UpdateHostGroupRecipes::getHostGroupName, UpdateHostGroupRecipes::getRecipeNames, (n1, n2) -> n1));
LOGGER.debug("Update recipes {}", recipesToUpdate);
Set<Recipe> recipes = recipeService.getByNamesForWorkspaceId(recipesToFind, workspaceId);
validate(recipesToFind, recipes);
Set<HostGroup> hostGroups = hostGroupService.getByClusterWithRecipes(stack.getCluster().getId());
UpdateRecipesV4Response result = updateRecipesForHostGroups(recipesToUpdate, recipes, hostGroups);
LOGGER.debug("Update recipes result: {}", result);
return result;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method testWhenRegionIsEmptyButDefaultRegionsAreEmptyThenBadRequestExceptionComes.
@Test
public void testWhenRegionIsEmptyButDefaultRegionsAreEmptyThenBadRequestExceptionComes() {
setDefaultRegions(null);
StackV4Request request = getRequest("stack.json");
request.setCloudPlatform(MOCK);
request.getPlacement().setRegion(null);
BadRequestException resultException = assertThrows(BadRequestException.class, () -> underTest.convert(request));
assertEquals("No default region is specified. Region cannot be empty.", resultException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ClusterToClusterV4RequestConverterTest method testConvertWhenRdsConfigsContainsElementsThenUserManagedOnesNameShouldBeStored.
@Test
public void testConvertWhenRdsConfigsContainsElementsThenUserManagedOnesNameShouldBeStored() {
RDSConfig notUserManaged = new RDSConfig();
notUserManaged.setId(0L);
notUserManaged.setStatus(DEFAULT);
RDSConfig userManaged = new RDSConfig();
notUserManaged.setId(1L);
userManaged.setStatus(USER_MANAGED);
Set<RDSConfig> rdsConfigs = new LinkedHashSet<>(2);
rdsConfigs.add(notUserManaged);
rdsConfigs.add(userManaged);
when(cluster.getRdsConfigs()).thenReturn(rdsConfigs);
ClusterV4Request result = underTest.convert(cluster);
assertEquals(1L, result.getDatabases().size());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ClusterTemplateTest method validateDefaultCount.
private ClusterTemplateTestDto validateDefaultCount(TestContext tc, ClusterTemplateTestDto entity, CloudbreakClient cc) {
try {
assertNotNull(entity);
assertNotNull(entity.getResponses());
long defaultCount = entity.getResponses().stream().filter(template -> ResourceStatus.DEFAULT.equals(template.getStatus())).count();
long expectedCount = 602;
assertEquals("Should have " + expectedCount + " of default cluster templates.", expectedCount, defaultCount);
} catch (Exception e) {
throw new TestFailException(String.format("Failed to validate default count of cluster templates: %s", e.getMessage()), e);
}
return entity;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ImageCatalogTest method testGetImageCatalogWhenCatalogDoesNotContainTheRequestedProvider.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "image catalog get the default catalog with AWS provider but catalog does not contain AWS entry", when = "calling get on the default", then = "the response does not contains AWS images")
public void testGetImageCatalogWhenCatalogDoesNotContainTheRequestedProvider(MockedTestContext testContext) {
String imgCatalogName = resourcePropertyProvider().getName();
testContext.given(imgCatalogName, ImageCatalogTestDto.class).withName(imgCatalogName).withUrl(getImageCatalogMockServerSetup().getImageCatalogUrl()).when(imageCatalogTestClient.createV4(), key(imgCatalogName)).when(new ImageCatalogGetImagesByNameAction(CloudPlatform.AWS), key(imgCatalogName)).then((testContext1, entity, cloudbreakClient) -> {
ImagesV4Response catalog = entity.getResponseByProvider();
if (!catalog.getBaseImages().isEmpty()) {
throw new IllegalArgumentException("The Images response should NOT contain results for AWS provider.");
}
return entity;
}).validate();
}
Aggregations