You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/08/15 15:02:20 UTC
[jira] [Commented] (BROOKLYN-330) Can't use YAML dsl expressions
for config of HttpRequestSensor inside brooklyn.initializers
[ https://issues.apache.org/jira/browse/BROOKLYN-330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15421103#comment-15421103 ]
ASF GitHub Bot commented on BROOKLYN-330:
-----------------------------------------
GitHub user aledsage opened a pull request:
https://github.com/apache/brooklyn-server/pull/302
BROOKLYN-330: add failing test for dsl in HttpRequestSensor
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/aledsage/brooklyn-server BROOKLYN-330-test
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/brooklyn-server/pull/302.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #302
----
commit f9f7a5e8155eb105e3ec9d629fc437b5c5bfe06a
Author: Aled Sage <al...@gmail.com>
Date: 2016-08-15T14:47:19Z
BROOKLYN-330: add failing test for dsl in HttpRequestSensor
----
> Can't use YAML dsl expressions for config of HttpRequestSensor inside brooklyn.initializers
> -------------------------------------------------------------------------------------------
>
> Key: BROOKLYN-330
> URL: https://issues.apache.org/jira/browse/BROOKLYN-330
> Project: Brooklyn
> Issue Type: Bug
> Reporter: Aled Sage
>
> With 0.10.0-SNAPSHOT...
> It seems that, when using {{HttpRequestSensor}} inside a {{brooklyn.initializers}}, it does not resolve the config.
> For example, if I use {{$brooklyn:config(...)}} to set URI of the HttpRequestSensor, then it fails with the error:
> {noformat}
> Failed to create instance of class org.apache.brooklyn.core.sensor.http.HttpRequestSensor: Cannot coerce type org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent.DslConfigSupplier to java.lang.String (config("server.username")): no adapter known
> {noformat}
> I have reproduced that in the simple test case below (which I'll add to {{HttpRequestSensorYamlTest}}):
> {noformat}
> @Test(groups="Broken")
> public void testHttpSensorWithDeferredSuppliers() throws Exception {
> Entity app = createAndStartApplication(
> "services:",
> "- type: " + TestEntity.class.getName(),
> " brooklyn.config:",
> " server.username: myusername",
> " server.password: mypassword",
> " brooklyn.initializers:",
> " - type: "+HttpRequestSensor.class.getName(),
> " brooklyn.config:",
> " "+HttpRequestSensor.SENSOR_PERIOD.getName()+": 100ms",
> " "+HttpRequestSensor.SENSOR_NAME.getName()+": " + SENSOR_STRING.getName(),
> " "+HttpRequestSensor.SENSOR_TYPE.getName()+": " + TARGET_TYPE,
> " "+HttpRequestSensor.JSON_PATH.getName()+": " + "$.myKey",
> " "+HttpRequestSensor.USERNAME.getName()+": $brooklyn:config(\"server.username\")",
> " "+HttpRequestSensor.PASSWORD.getName()+": $brooklyn:config(\"server.password\")",
> " "+HttpRequestSensor.SENSOR_URI.getName()+":",
> " $brooklyn:formatString:",
> " - \"%s/myKey/myValue\"",
> " - $brooklyn:attributeWhenReady(\"main.uri\")");
> waitForApplicationTasks(app);
> Entity entity = Iterables.getOnlyElement(app.getChildren());
> entity.sensors().set(Attributes.MAIN_URI, URI.create(serverUrl));
> entity.sensors().set(Attributes.SERVICE_UP, true);
> EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_STRING, "myValue");
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)