public TemplateBuilder apply(TemplateBuilder b) { return b.minCores(minCores); }}); return (T)this;
public void testParse_minCores() { TemplateBuilderSpec spec = parse("minCores=32"); assertNull(spec.hardwareId); assertEquals(32, spec.minCores.intValue()); assertNull(spec.minRam); assertNull(spec.minDisk); assertNull(spec.hypervisorMatches); assertNull(spec.imageId); assertNull(spec.imageNameMatches); assertNull(spec.osFamily); assertNull(spec.osVersionMatches); assertNull(spec.os64Bit); assertNull(spec.osArchMatches); assertNull(spec.osDescriptionMatches); assertNull(spec.loginUser); assertNull(spec.authenticateSudo); assertNull(spec.locationId); assertTemplateBuilderEquivalence(templateBuilders.get().minCores(32), templateBuilders.get().from(spec)); }
public void testParse_minCores() { TemplateBuilderSpec spec = parse("minCores=32"); assertNull(spec.hardwareId); assertEquals(32, spec.minCores.intValue()); assertNull(spec.minRam); assertNull(spec.minDisk); assertNull(spec.hypervisorMatches); assertNull(spec.imageId); assertNull(spec.imageNameMatches); assertNull(spec.osFamily); assertNull(spec.osVersionMatches); assertNull(spec.os64Bit); assertNull(spec.osArchMatches); assertNull(spec.osDescriptionMatches); assertNull(spec.loginUser); assertNull(spec.authenticateSudo); assertNull(spec.locationId); assertNull(spec.forceCacheReload); assertTemplateBuilderEquivalence(templateBuilders.get().minCores(32), templateBuilders.get().from(spec)); }
public void testTemplateBuilderFrom_string() { TemplateBuilder fromString = templateBuilders.get().from("minRam=10,osFamily=UBUNTU"); TemplateBuilder expected = templateBuilders.get().minCores(30).minRam(10).osFamily(OsFamily.UBUNTU); assertTemplateBuilderEquivalence(expected, fromString); }
public void testTemplateBuilderFrom_string() { TemplateBuilder fromString = templateBuilders.get().from("minRam=10,osFamily=UBUNTU"); TemplateBuilder expected = templateBuilders.get().minCores(30).minRam(10).osFamily(OsFamily.UBUNTU); assertTemplateBuilderEquivalence(expected, fromString); }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}, expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "No hardware profile matching the given criteria was found. " + "If you want to use exact values, please set the minCores and minRam values") public void testAutoGeneratedHardwareWithOnlyMinCoresNotMatchHardwareProfile() { if (view.getComputeService().listHardwareProfiles().isEmpty()) { view.getComputeService().templateBuilder().minCores(4).build(); } else { throw new SkipException("Hardware profile list not empty."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareWithOnlyMinCoresMatchHardwareProfile() { if (!view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder().minCores(4).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isFalse(); assertThat(template.getHardware().getProcessors().get(0).getCores()).isGreaterThanOrEqualTo(4); } else { throw new SkipException("Hardware profile list is empty, this provider can not match any hardware profile" + "to the specified minRam and minCores."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareWithMinCoresAndMinRam() { if (view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder() .minRam(2048).minCores(2).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isTrue(); assertThat(template.getHardware().getRam()).isEqualTo(2048); assertThat(template.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); } else { throw new SkipException("Hardware profile list not empty."); } }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testCreateNodeWithCustomHardwareUsingMins() throws Exception { Template template = buildTemplate(templateBuilder() .minCores(2).minRam(2048).minDisk(10)); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); assertThat(node.getHardware().getId()).isEqualTo("cpu=2,ram=2048,disk=10"); } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }
/** * Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based * on physical attributes (# of cores, ram, etc). * * Expected size: CC1_4XLARGE */ @Test public void testTemplateChoiceForInstanceByAttributes() throws Exception { Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.5).smallest().locationId( "us-east-1").build(); assert template != null : "The returned template was null, but it should have a value."; assertEquals(template.getHardware().getId(), "cc1.4xlarge"); }
@Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareMatchHardwareProfile() { if (!view.getComputeService().listHardwareProfiles().isEmpty()) { Template template = view.getComputeService().templateBuilder() .minRam(2048).minCores(2).build(); assertThat(AutomaticHardwareIdSpec.isAutomaticId(template.getHardware().getId())).isFalse(); assertThat(template.getHardware().getRam()).isGreaterThanOrEqualTo(2048); assertThat(template.getHardware().getProcessors().get(0).getCores()).isGreaterThanOrEqualTo(2); } else { throw new SkipException("Hardware profile list is empty, this provider can not match any hardware profile" + "to the specified minRam and minCores."); } }
/** * Negative test version of {@link #testTemplateChoiceForInstanceByAttributes}. * * Verifies that {@link TemplateBuilderImpl} would not choose the insufficient size of the * instance, based on physical attributes (# of cores, ram, etc). * * Expected size: anything but m2.xlarge */ @Test public void testNegativeTemplateChoiceForInstanceByAttributes() throws Exception { Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.7).smallest().locationId( "us-east-1").build(); assert template != null : "The returned template was null, but it should have a value."; assert !m2_xlarge().build().equals(template.getHardware()) : format( "Incorrect image determined by the template. Expected: not %s. Found: %s.", "m2.xlarge", template .getHardware().getId()); }
/** * Negative test version of {@link #testTemplateChoiceForInstanceByAttributes}. * * Verifies that {@link TemplateBuilderImpl} would not choose the insufficient size of the * instance, based on physical attributes (# of cores, ram, etc). * * Expected size: anything but m2.xlarge */ @Test public void testNegativeTemplateChoiceForInstanceByAttributes() throws Exception { Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.7).smallest().locationId( "us-east-1").build(); assert template != null : "The returned template was null, but it should have a value."; assert !m2_xlarge().build().equals(template.getHardware()) : format( "Incorrect image determined by the template. Expected: not %s. Found: %s.", "m2.xlarge", template .getHardware().getId()); }
/** * Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based * on physical attributes (# of cores, ram, etc). * * Expected size: CC1_4XLARGE */ @Test public void testTemplateChoiceForInstanceByAttributes() throws Exception { Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.5).smallest().locationId( "us-east-1").build(); assert template != null : "The returned template was null, but it should have a value."; assertEquals(template.getHardware().getId(), m2_4xlarge().build().getId()); }
builder.minCores(minCores);
builder.minCores(minCores);
builder.minCores(minCores);
builder.minCores(minCores);
templateBuilder.minRam(vm.getMinRam()); if (vm.getMinCores() > 0) templateBuilder.minCores(vm.getMinCores());
templateBuilder.minRam(node.getMinRam()); if (node.getMinCore() > 0) templateBuilder.minCores(node.getMinCore()); if (!node.getLocation().equals("")) templateBuilder.locationId(node.getLocation());