use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenJsonTreeCreationIsFailed.
@Test
public void testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenJsonTreeCreationIsFailed() throws Exception {
// GIVEN
Blueprint blueprint = createBlueprint();
Set<InstanceGroup> instanceGroups = createInstanceGroups();
Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
IOException expectedException = new IOException("");
BDDMockito.given(objectMapper.readTree(BDDMockito.anyString())).willThrow(expectedException);
thrown.expect(BlueprintValidationException.class);
thrown.expectMessage("Blueprint [null] can not be parsed from JSON.");
thrown.expectCause(is(expectedException));
// WHEN
underTest.validateBlueprintForStack(blueprint, hostGroups, instanceGroups);
// THEN throw exception
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenNoInstanceGroupForAHostGroup.
@Test
public void testValidateBlueprintForStackShouldThrowBadRequestExceptionWhenNoInstanceGroupForAHostGroup() throws IOException {
// GIVEN
Blueprint blueprint = createBlueprint();
Set<InstanceGroup> instanceGroups = createInstanceGroups();
Set<HostGroup> hostGroups = createHostGroups(instanceGroups.stream().sorted().limit(instanceGroups.size() - 1).collect(Collectors.toSet()));
JsonNode blueprintJsonTree = createJsonTree();
BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
thrown.expect(BlueprintValidationException.class);
thrown.expectMessage(Matchers.startsWith("The host groups in the validation"));
// WHEN
underTest.validateBlueprintForStack(blueprint, hostGroups, instanceGroups);
// THEN throw exception
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testHostGroupScalingThrowsBadRequestExceptionWhenNodeCountIsLessThanMin.
@Test
public void testHostGroupScalingThrowsBadRequestExceptionWhenNodeCountIsLessThanMin() throws IOException {
// GIVEN
Blueprint blueprint = createBlueprint();
JsonNode blueprintJsonTree = createJsonTree();
InstanceGroup instanceGroup = createInstanceGroup(GROUP3, 1);
HostGroup hostGroup = createHostGroup(instanceGroup.getGroupName(), instanceGroup);
BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
thrown.expect(BlueprintValidationException.class);
thrown.expectMessage("The node count '0' for hostgroup 'group3' cannot be less than '1' or more than '3' because of 'mastercomp3' component");
// WHEN
underTest.validateHostGroupScalingRequest(blueprint, hostGroup, -1);
// THEN throw exception
}
use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testKnoxWithoutKerberos.
@Test
public void testKnoxWithoutKerberos() 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(false);
// 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 ContainerConstraintFactory method getAmbariAgentConstraint.
public ContainerConstraint getAmbariAgentConstraint(String ambariServerHost, String ambariAgentApp, String cloudPlatform, HostGroup hostGroup, Integer adjustment, List<String> hostBlackList, String identifier) {
String containerInstanceName;
containerInstanceName = YARN.equals(hostGroup.getCluster().getStack().getOrchestrator().getType()) ? createContainerInstanceNameForYarn(hostGroup, AMBARI_AGENT.getName(), identifier) : createContainerInstanceName(hostGroup, AMBARI_AGENT.getName(), identifier);
Constraint hgConstraint = hostGroup.getConstraint();
Builder builder = new Builder().withNamePrefix(containerInstanceName).withAppName(ambariAgentApp).networkMode(HOST_NETWORK_MODE);
if (hgConstraint.getInstanceGroup() != null) {
InstanceGroup instanceGroup = hgConstraint.getInstanceGroup();
Map<String, String> dataVolumeBinds = new HashMap<>();
dataVolumeBinds.put("/var/log/ambari-agent-container", CONTAINER_VOLUME_PATH);
dataVolumeBinds.put(HADOOP_MOUNT_DIR, HADOOP_MOUNT_DIR);
dataVolumeBinds.putAll(ImmutableMap.of("/data/jars", "/data/jars", HOST_VOLUME_PATH, CONTAINER_VOLUME_PATH));
builder.addVolumeBindings(dataVolumeBinds);
if (adjustment != null) {
List<String> candidates = collectUpscaleCandidates(hostGroup.getCluster().getId(), hostGroup.getName(), adjustment);
builder.addHosts(getHosts(candidates, instanceGroup));
} else {
builder.addHosts(getHosts(null, instanceGroup));
}
builder.cmd(new String[] { String.format("/usr/sbin/init systemd.setenv=AMBARI_SERVER_ADDR=%s systemd.setenv=CLOUD_PLATFORM=%s", ambariServerHost, cloudPlatform) });
}
if (hgConstraint.getConstraintTemplate() != null) {
builder.cpus(hgConstraint.getConstraintTemplate().getCpu());
builder.memory(hgConstraint.getConstraintTemplate().getMemory());
builder.constraints(getConstraints(hostBlackList));
if (adjustment != null) {
builder.instances(adjustment);
} else {
builder.instances(hgConstraint.getHostCount());
}
builder.withDiskSize(hgConstraint.getConstraintTemplate().getDisk());
Map<String, String> dataVolumeBinds = new HashMap<>();
dataVolumeBinds.put("/var/log/ambari-agent-container", CONTAINER_VOLUME_PATH);
builder.addVolumeBindings(dataVolumeBinds);
builder.cmd(new String[] { String.format("/usr/sbin/init systemd.setenv=AMBARI_SERVER_ADDR=%s systemd.setenv=USE_CONSUL_DNS=false", ambariServerHost) });
}
return builder.build();
}
Aggregations