use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackRequestToStackConverterTest method testConvertWithLoginUserName.
@Test
public void testConvertWithLoginUserName() throws CloudbreakException {
InstanceGroup instanceGroup = mock(InstanceGroup.class);
when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
// GIVEN
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
given(conversionService.convert(any(StackAuthenticationRequest.class), eq(StackAuthentication.class))).willReturn(new StackAuthentication());
given(conversionService.convert(any(FailurePolicyRequest.class), eq(FailurePolicy.class))).willReturn(new FailurePolicy());
given(conversionService.convert(any(InstanceGroupRequest.class), eq(InstanceGroup.class))).willReturn(instanceGroup);
given(conversionService.convert(any(OrchestratorRequest.class), eq(Orchestrator.class))).willReturn(new Orchestrator());
given(orchestratorTypeResolver.resolveType(any(Orchestrator.class))).willReturn(OrchestratorType.HOST);
given(orchestratorTypeResolver.resolveType(any(String.class))).willReturn(OrchestratorType.HOST);
given(defaultCostTaggingService.prepareDefaultTags(any(String.class), any(String.class), anyMap(), anyString())).willReturn(new HashMap<>());
thrown.expect(BadRequestException.class);
thrown.expectMessage("You can not modify the default user!");
// WHEN
Stack stack = underTest.convert(getRequest("stack/stack-with-loginusername.json"));
// THEN
assertAllFieldsNotNull(stack, Arrays.asList("description", "statusReason", "cluster", "credential", "gatewayPort", "template", "network", "securityConfig", "securityGroup", "version", "created", "platformVariant", "cloudPlatform", "saltPassword", "stackTemplate", "flexSubscription", "datalakeId", "customHostname", "customDomain", "clusterNameAsSubdomain", "hostgroupNameAsHostname", "loginUserName"));
Assert.assertEquals("eu-west-1", stack.getRegion());
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class StackRequestToStackConverterTest method testConvert.
@Test
public void testConvert() throws CloudbreakException {
InstanceGroup instanceGroup = mock(InstanceGroup.class);
when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
// GIVEN
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
given(conversionService.convert(any(StackAuthenticationRequest.class), eq(StackAuthentication.class))).willReturn(new StackAuthentication());
given(conversionService.convert(any(FailurePolicyRequest.class), eq(FailurePolicy.class))).willReturn(new FailurePolicy());
given(conversionService.convert(any(InstanceGroupRequest.class), eq(InstanceGroup.class))).willReturn(instanceGroup);
given(conversionService.convert(any(OrchestratorRequest.class), eq(Orchestrator.class))).willReturn(new Orchestrator());
given(orchestratorTypeResolver.resolveType(any(Orchestrator.class))).willReturn(OrchestratorType.HOST);
given(orchestratorTypeResolver.resolveType(any(String.class))).willReturn(OrchestratorType.HOST);
given(defaultCostTaggingService.prepareDefaultTags(any(String.class), any(String.class), anyMap(), anyString())).willReturn(new HashMap<>());
// WHEN
Stack stack = underTest.convert(getRequest("stack/stack.json"));
// THEN
assertAllFieldsNotNull(stack, Arrays.asList("description", "statusReason", "cluster", "credential", "gatewayPort", "template", "network", "securityConfig", "securityGroup", "version", "created", "platformVariant", "cloudPlatform", "saltPassword", "stackTemplate", "flexSubscription", "datalakeId", "customHostname", "customDomain", "clusterNameAsSubdomain", "hostgroupNameAsHostname", "loginUserName", "parameters"));
Assert.assertEquals("YARN", stack.getRegion());
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class ClusterBootstrapperErrorHandlerTest method clusterBootstrapErrorHandlerWhenNodeCountLessThanOneAfterTheRollbackThenClusterProvisionFailed.
@Test
public void clusterBootstrapErrorHandlerWhenNodeCountLessThanOneAfterTheRollbackThenClusterProvisionFailed() throws CloudbreakOrchestratorFailedException {
Stack stack = TestUtil.stack();
doNothing().when(eventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
when(orchestrator.getAvailableNodes(any(GatewayConfig.class), anySet())).thenReturn(new ArrayList<>());
when(instanceGroupRepository.save(any(InstanceGroup.class))).then(returnsFirstArg());
when(instanceMetaDataRepository.save(any(InstanceMetaData.class))).then(returnsFirstArg());
when(instanceMetaDataRepository.findNotTerminatedByPrivateAddress(anyLong(), anyString())).thenAnswer((Answer<InstanceMetaData>) invocation -> {
Object[] args = invocation.getArguments();
String ip = (String) args[1];
for (InstanceMetaData instanceMetaData : stack.getRunningInstanceMetaData()) {
if (instanceMetaData.getPrivateIp().equals(ip)) {
return instanceMetaData;
}
}
return null;
});
when(instanceGroupRepository.findOneByGroupNameInStack(anyLong(), anyString())).thenAnswer((Answer<InstanceGroup>) invocation -> {
Object[] args = invocation.getArguments();
String name = (String) args[1];
for (InstanceMetaData instanceMetaData : stack.getRunningInstanceMetaData()) {
if (instanceMetaData.getInstanceGroup().getGroupName().equals(name)) {
return instanceMetaData.getInstanceGroup();
}
}
return null;
});
when(cloudbreakMessagesService.getMessage(eq("bootstrapper.error.invalide.nodecount"), any())).thenReturn("invalide.nodecount");
thrown.expect(CloudbreakOrchestratorFailedException.class);
thrown.expectMessage("invalide.nodecount");
underTest.terminateFailedNodes(null, orchestrator, TestUtil.stack(), new GatewayConfig("10.0.0.1", "198.0.0.1", "10.0.0.1", 8443, false), prepareNodes(stack));
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testKerberosWithoutKnox.
@Test
public void testKerberosWithoutKnox() throws IOException {
// GIVEN
Blueprint blueprint = createBlueprint();
Set<InstanceGroup> instanceGroups = createInstanceGroups();
Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
instanceGroups.add(createInstanceGroup("gateway", 1));
JsonNode blueprintJsonTree = createJsonTree();
BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
Cluster cluster = new Cluster();
cluster.setSecure(true);
// WHEN
underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN no exception thrown
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testValidateBlueprintForStackShouldNotThrowAnyExceptionWhenBlueprintIsValid.
@Test
public void testValidateBlueprintForStackShouldNotThrowAnyExceptionWhenBlueprintIsValid() throws IOException {
// GIVEN
Blueprint blueprint = createBlueprint();
Set<InstanceGroup> instanceGroups = createInstanceGroups();
Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
instanceGroups.add(createInstanceGroup("gateway", 1));
JsonNode blueprintJsonTree = createJsonTree();
BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
// WHEN
underTest.validateBlueprintForStack(blueprint, hostGroups, instanceGroups);
// THEN doesn't throw exception
}
Aggregations