use of com.sequenceiq.cloudbreak.domain.FailurePolicy in project cloudbreak by hortonworks.
the class TestUtil method failurePolicy.
public static FailurePolicy failurePolicy() {
FailurePolicy failurePolicy = new FailurePolicy();
failurePolicy.setId(1L);
failurePolicy.setThreshold(10L);
failurePolicy.setAdjustmentType(AdjustmentType.BEST_EFFORT);
return failurePolicy;
}
use of com.sequenceiq.cloudbreak.domain.FailurePolicy in project cloudbreak by hortonworks.
the class FailurePolicyRequestToFailurePolicyConverter method convert.
@Override
public FailurePolicy convert(FailurePolicyRequest json) {
FailurePolicy stackFailurePolicy = new FailurePolicy();
stackFailurePolicy.setAdjustmentType(json.getAdjustmentType());
stackFailurePolicy.setThreshold(json.getThreshold() == null ? Long.valueOf(0L) : json.getThreshold());
return stackFailurePolicy;
}
use of com.sequenceiq.cloudbreak.domain.FailurePolicy 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.FailurePolicy 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.FailurePolicy in project cloudbreak by hortonworks.
the class StackToStackResponseConverterTest method createSource.
@Override
public Stack createSource() {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster(TestUtil.blueprint(), stack, 1L);
stack.setCluster(cluster);
stack.setAvailabilityZone("avZone");
Network network = new Network();
network.setId(1L);
stack.setNetwork(network);
stack.setFailurePolicy(new FailurePolicy());
Orchestrator orchestrator = new Orchestrator();
orchestrator.setId(1L);
orchestrator.setApiEndpoint("endpoint");
orchestrator.setType("type");
stack.setOrchestrator(orchestrator);
stack.setParameters(new HashMap<>());
stack.setCloudPlatform("OPENSTACK");
stack.setGatewayPort(9443);
stack.setCustomDomain("custom.domain");
stack.setCustomHostname("hostname");
stack.setStackAuthentication(new StackAuthentication());
stack.getStackAuthentication().setPublicKey("rsakey");
stack.getStackAuthentication().setLoginUserName("cloudbreak");
stack.setHostgroupNameAsHostname(false);
stack.setClusterNameAsSubdomain(false);
Resource s3ArnResource = new Resource(ResourceType.S3_ACCESS_ROLE_ARN, "s3Arn", stack);
stack.setResources(Collections.singleton(s3ArnResource));
return stack;
}
Aggregations