@Override public Map<String, String> getShellEnvironment() { ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder() .putAll(super.getShellEnvironment()) .put("CHECKPOINT_DISABLE", "1") .put("WEAVE_VERSION", entity.config().get(WeaveRouter.SUGGESTED_VERSION)) .put("VERSION", entity.config().get(WeaveRouter.SUGGESTED_VERSION)); return builder.build(); }
protected static void assertEnricherConfig(Enricher enricher, Map<? extends ConfigKey<?>, ?> expectedVals) { for (Map.Entry<? extends ConfigKey<?>, ?> entry : expectedVals.entrySet()) { ConfigKey<?> key = entry.getKey(); Object actual = enricher.config().get(key); assertEquals(actual, entry.getValue(), "key="+key+"; expected="+entry.getValue()+"; actual="+actual); } }
private String getAptRepository() { String debFileName = "erlang-repo.deb"; return chainGroup( INSTALL_CURL, format("curl %s -o %s", entity.config().get(RabbitBroker.ERLANG_DEB_REPO_URL), debFileName), sudo(format("dpkg -i %s", debFileName)) ); }
@Test public void testExplicitFlagsAppliesToCatalogItemImpl() throws Exception { addCatalogOSGiEntity("test", TestEntityImpl.class.getName()); String testName = "test-applies-config-on-catalog-item"; Entity app = createAndStartApplication( "services:", "- type: " + ver("test"), " brooklyn.flags:", " confName: " + testName); Entity testEntity = Iterables.getOnlyElement(app.getChildren()); assertEquals(testEntity.config().get(TestEntity.CONF_NAME), testName); }
@Test public void testExplicitFlagsAppliesToCatalogItem() throws Exception { addCatalogOSGiEntity("test", TestEntity.class.getName()); String testName = "test-applies-config-on-catalog-item"; Entity app = createAndStartApplication( "services:", "- type: " + ver("test"), " brooklyn.flags:", " confName: " + testName); Entity testEntity = Iterables.getOnlyElement(app.getChildren()); assertEquals(testEntity.config().get(TestEntity.CONF_NAME), testName); }
@Test public void testBrooklynIdentityFunction() throws Exception { Iterable<? extends Entity> testEntities = setupAndCheckTestEntityInBasicYamlWith(); Entity entityOne = Iterables.find(testEntities, EntityPredicates.displayNameEqualTo("Test Entity One")); Entity entityTwo = Iterables.find(testEntities, EntityPredicates.displayNameEqualTo("Test Entity Two")); Assert.assertNotNull(entityOne, "Test entity one should be present"); Assert.assertNotNull(entityTwo, "Test entity two should be present"); Assert.assertEquals(entityOne.config().get(TEST_ENTITY_ONE_ID), entityOne.getId(), "Entity one IDs should match"); Assert.assertEquals(entityOne.config().get(TEST_ENTITY_TWO_ID), entityTwo.getId(), "Entity two IDs should match"); }
public String getBindAddress() { String host = Optional.fromNullable(getEntity().config().get(HAProxyController.BIND_ADDRESS)).or("*"); Integer port = getEntity().sensors().get(HAProxyController.PROXY_HTTP_PORT); return host + ":" + port; }
@Override public void customize() { String customizeCommand = getEntity().config().get(VanillaSoftwareProcess.CUSTOMIZE_COMMAND); if (Strings.isNonBlank(customizeCommand)) { newScript(CUSTOMIZING) .failOnNonZeroResultCode() .body.append(customizeCommand) .execute(); } }
@Override public Set<String> getPrivateAddresses() { if (dockerContainer.config().get(SdnAttributes.SDN_ENABLE)) { return ImmutableSet.copyOf(dockerContainer.sensors().get(DockerContainer.CONTAINER_ADDRESSES)); } else { return ImmutableSet.of(getSubnetIp()); } }
@Override public void createSubnet(String subnetId, Cidr subnetCidr) { boolean ipip = entity.config().get(CalicoNetwork.USE_IPIP); boolean nat = entity.config().get(CalicoNetwork.USE_NAT); newScript("createSubnet") .body.append( sudo(String.format("%s pool add %s %s %s", getCalicoCommand(), subnetCidr, ipip ? "--ipip" : "", nat ? "--nat-outgoing" : ""))) .execute(); super.createSubnet(subnetId, subnetCidr); }
@SuppressWarnings("unchecked") private void assertNoCustomizers(Entity entity) { Object object = entity.config().get(BrooklynConfigKeys.PROVISIONING_PROPERTIES.subKey( JcloudsLocationConfig.JCLOUDS_LOCATION_CUSTOMIZERS.getName())); if (object != null) { assertTrue(object instanceof Collection, "expected collection, got " + object.getClass()); Collection<JcloudsLocationCustomizer> customizers = (Collection<JcloudsLocationCustomizer>) object; assertEquals(customizers.size(), 0, "expected no entries in " + Iterables.toString(customizers)); } }
@Test public void testTargetGroupCanBeSetInYaml() throws Exception { final String resourceName = "classpath:/" + getClass().getPackage().getName().replace('.', '/') + "/geodns.yaml"; final String blueprint = loadYaml(resourceName); Application app = EntityManagementUtils.createUnstarted(mgmt(), blueprint); GeoscalingDnsService geodns = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, GeoscalingDnsService.class)); DynamicFabric fabric = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, DynamicFabric.class)); assertEquals(geodns.config().get(AbstractGeoDnsService.ENTITY_PROVIDER), fabric); }
@Test public void testConfigAppliedToCatalogItem() throws Exception { addCatalogOSGiEntity("test", TestEntity.class.getName()); String testName = "test-applies-config-on-catalog-item"; Entity app = createAndStartApplication( "services:", "- type: " + ver("test"), " brooklyn.config:", " test.confName: " + testName); Entity testEntity = Iterables.getOnlyElement(app.getChildren()); assertEquals(testEntity.config().get(TestEntity.CONF_NAME), testName); }
@Test public void testSimpleXmlPlanParse() { EntitySpec<? extends Application> appSpec = EntityManagementUtils.createEntitySpecForApplication(mgmt, "<root><a_kid foo=\"bar\"/></root>"); Application app = EntityManagementUtils.createStarting(mgmt, appSpec).get(); Entities.dumpInfo(app); Assert.assertEquals(app.getDisplayName(), "root"); Entity child = Iterables.getOnlyElement(app.getChildren()); Assert.assertEquals(child.getDisplayName(), "a_kid"); Assert.assertEquals(child.config().get(ConfigKeys.newStringConfigKey("foo")), "bar"); }
@Test public void testMachineSpecsTemporaryConfigWillNotBePersisted() throws Exception { String spec = "byon(hosts=\"1.1.1.1\")"; MachineProvisioningLocation<MachineLocation> provisioner = resolve(spec); assertEquals(provisioner.config().get(FixedListMachineProvisioningLocation.MACHINE_SPECS), null); }
@Test public void testUsingDeprecatedNameInEntityInitializer() throws Exception { Entity entity = app.addChild(EntitySpec.create(BasicEntity.class) .addInitializer(new MyEntityInitializer(ConfigBag.newInstance(ImmutableMap.of("oldKey1", "myval"))))); assertEquals(entity.config().get(MyEntityInitializer.KEY_1), "myval"); }
@Test public void testDslSensorSupplier_2016_07() throws Exception { String entityId = "klcueb1ide"; doAddEntityMemento("2016-07", entityId); rebind(); Entity newEntity = mgmt().getEntityManager().getEntity(entityId); Sensor<?> sensor = newEntity.config().get(sensorSupplier1); assertEquals(sensor.getName(), "mySensorName"); }
@Test public void testExplicitFlagsAppliesToCatalogItem() throws Exception { addCatalogEntity("test", TestEntity.class.getName()); String val = "test-applies-config-on-catalog-item"; Entity app = createAndStartApplication( "services:", "- type: " + ver("test"), " brooklyn.flags:", " confName: " + val); Entity testEntity = Iterables.getOnlyElement(app.getChildren()); assertEquals(testEntity.config().get(TestEntity.CONF_NAME), val); }
@Test public void testAppSpecXmlPlanParse() { EntitySpec<? extends Application> appSpec = EntityManagementUtils.createEntitySpecForApplication(mgmt, "<root><a_kid foo=\"bar\"/></root>"); Application app = EntityManagementUtils.createStarting(mgmt, appSpec).get(); Entities.dumpInfo(app); Assert.assertEquals(app.getDisplayName(), "root"); Entity child = Iterables.getOnlyElement(app.getChildren()); Assert.assertEquals(child.getDisplayName(), "a_kid"); Assert.assertEquals(child.config().get(ConfigKeys.newStringConfigKey("foo")), "bar"); }
@Test public void testInheritedDefault() { final Entity e1 = app.addChild(EntitySpec.create(MyBaseEntity.class)); final Entity e2 = e1.addChild(EntitySpec.create(BasicEntity.class)); Assert.assertEquals(e2.config().get(MyBaseEntity.SUPER_KEY_1), MyBaseEntity.SUPER_KEY_1.getDefaultValue()); Assert.assertEquals(e2.config().get(ConfigKeys.newStringConfigKey(MyBaseEntity.SUPER_KEY_1.getName())), MyBaseEntity.SUPER_KEY_1.getDefaultValue()); }