use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method isSchedulingPreemptibleTest.
@Test
public void isSchedulingPreemptibleTest() throws Exception {
// GIVEN
Group group = newGroupWithParams(ImmutableMap.of("preemptible", true));
List<CloudResource> buildableResources = builder.create(context, privateId, authenticatedContext, group, image);
context.addComputeResources(0L, buildableResources);
// WHEN
when(compute.instances()).thenReturn(instances);
when(instances.insert(anyString(), anyString(), instanceArg.capture())).thenReturn(insert);
when(insert.setPrettyPrint(anyBoolean())).thenReturn(insert);
when(insert.execute()).thenReturn(operation);
when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(new HashMap<>());
builder.build(context, privateId, authenticatedContext, group, image, buildableResources, Collections.emptyMap());
// THEN
verify(compute).instances();
verify(instances).insert(anyString(), anyString(), instanceArg.capture());
assertTrue(instanceArg.getValue().getScheduling().getPreemptible());
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method isSchedulingNotPreemptibleTest.
@Test
public void isSchedulingNotPreemptibleTest() throws Exception {
// GIVEN
Group group = newGroupWithParams(ImmutableMap.of("preemptible", false));
List<CloudResource> buildableResources = builder.create(context, privateId, authenticatedContext, group, image);
context.addComputeResources(0L, buildableResources);
// WHEN
when(compute.instances()).thenReturn(instances);
when(instances.insert(anyString(), anyString(), instanceArg.capture())).thenReturn(insert);
when(insert.setPrettyPrint(anyBoolean())).thenReturn(insert);
when(insert.execute()).thenReturn(operation);
when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(new HashMap<>());
builder.build(context, privateId, authenticatedContext, group, image, buildableResources, Collections.emptyMap());
// THEN
verify(compute).instances();
verify(instances).insert(anyString(), anyString(), instanceArg.capture());
assertFalse(instanceArg.getValue().getScheduling().getPreemptible());
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method preemptibleParameterNotSetTest.
@Test
public void preemptibleParameterNotSetTest() throws Exception {
// GIVEN
Group group = newGroupWithParams(ImmutableMap.of());
List<CloudResource> buildableResources = builder.create(context, privateId, authenticatedContext, group, image);
context.addComputeResources(0L, buildableResources);
// WHEN
when(compute.instances()).thenReturn(instances);
when(instances.insert(anyString(), anyString(), instanceArg.capture())).thenReturn(insert);
when(insert.setPrettyPrint(anyBoolean())).thenReturn(insert);
when(insert.execute()).thenReturn(operation);
when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(new HashMap<>());
builder.build(context, privateId, authenticatedContext, group, image, buildableResources, Collections.emptyMap());
// THEN
verify(compute).instances();
verify(instances).insert(anyString(), anyString(), instanceArg.capture());
assertFalse(instanceArg.getValue().getScheduling().getPreemptible());
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class OpenStackResourceConnector method removeDeleteRequestedInstances.
private CloudStack removeDeleteRequestedInstances(CloudStack stack) {
List<Group> groups = new ArrayList<>(stack.getGroups().size());
for (Group group : stack.getGroups()) {
List<CloudInstance> instances = new ArrayList<>(group.getInstances());
for (CloudInstance instance : group.getInstances()) {
if (InstanceStatus.DELETE_REQUESTED == instance.getTemplate().getStatus()) {
instances.remove(instance);
}
}
groups.add(new Group(group.getName(), group.getType(), instances, group.getSecurity(), null, stack.getInstanceAuthentication(), stack.getInstanceAuthentication().getLoginUserName(), stack.getInstanceAuthentication().getPublicKey()));
}
return new CloudStack(groups, stack.getNetwork(), stack.getImage(), stack.getParameters(), stack.getTags(), stack.getTemplate(), stack.getInstanceAuthentication(), stack.getInstanceAuthentication().getLoginUserName(), stack.getInstanceAuthentication().getPublicKey());
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class OpenStackFlavorVerifierTest method createGroup.
private Group createGroup(String flavor) {
InstanceTemplate template = new InstanceTemplate(flavor, null, null, new ArrayList<>(), null, null, null);
CloudInstance skeleton = new CloudInstance("id1", template, null);
Group group = new Group("name", InstanceGroupType.GATEWAY, new ArrayList<>(), null, skeleton, null, "loginUserName", "publicKey");
return group;
}
Aggregations