name: Getting Started Blueprint Test

location:
  jclouds:aws-ec2:
    identity: ABCDEFGHIJKLMNOPQRST
    credential: s3cr3tsq1rr3ls3cr3tsq1rr3ls3cr3tsq1rr3l

services:
- type: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster
  name: My Web
  id: webappcluster
  brooklyn.config:
    wars.root: http://search.maven.org/remotecontent?filepath=org/apache/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.8.0-incubating/brooklyn-example-hello-world-sql-webapp-0.8.0-incubating.war
    java.sysprops:
      brooklyn.example.db.url: >
        $brooklyn:formatString("jdbc:%s%s?user=%s&password=%s",
        entity("db").attributeWhenReady("datastore.url"),
        "visitors", "brooklyn", $brooklyn:external("brooklyn-demo-sample", "hidden-brooklyn-password"))
- type: org.apache.brooklyn.entity.database.mysql.MySqlNode
  id: db
  name: My DB
  brooklyn.config:
    creation.script.password: $brooklyn:external("brooklyn-demo-sample", "hidden-brooklyn-password")
    datastore.creation.script.url: https://bit.ly/brooklyn-visitors-creation-script
- type: org.apache.brooklyn.test.framework.TestHttpCall
  name: Check HTTP Response Status Code
  brooklyn.config:
    url: >
      $brooklyn:formatString("http://%s:%s",
      $brooklyn:entity("webappcluster").attributeWhenReady("host.address"),
      $brooklyn:entity("webappcluster").attributeWhenReady("proxy.http.port"))
    timeout: 10m
    applyAssertionTo: status
    assert:
    - isEqualTo: 200
- type: org.apache.brooklyn.test.framework.TestHttpCall
  name: Check HTTP Response Body
  brooklyn.config:
    url: >
      $brooklyn:formatString("http://%s:%s",
      $brooklyn:entity("webappcluster").attributeWhenReady("host.address"),
      $brooklyn:entity("webappcluster").attributeWhenReady("proxy.http.port"))
    timeout: 10m
    applyAssertionTo: body
    assert:
    - matches: "(?s).*Br[o]{2}klyn Deployed.*"
- type: org.apache.brooklyn.test.framework.TestCase
  name: Check Deploy Effector
  brooklyn.children:
  - type: org.apache.brooklyn.test.framework.TestSensor
    name: Check webappcluster isUp
    brooklyn.config:
      targetId: webappcluster
      sensor: service.isUp
      timeout: 10m
      assert:
      - equals: true
  - type: org.apache.brooklyn.test.framework.TestEffector
    name: Invoke Deploy Effector
    brooklyn.config:
      targetId: webappcluster
      effector: deploy
      timeout: 5m
      params:
        url: http://search.maven.org/remotecontent?filepath=org/apache/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.8.0-incubating/brooklyn-example-hello-world-sql-webapp-0.8.0-incubating.war
        targetName: newcontext
  - type: org.apache.brooklyn.test.framework.TestHttpCall
    name: Check Deployed Webapp Status Code
    brooklyn.config:
      timeout: 5m
      url: >
        $brooklyn:formatString("http://%s:%s/newcontext/",
        $brooklyn:entity("webappcluster").attributeWhenReady("host.address"),
        $brooklyn:entity("webappcluster").attributeWhenReady("proxy.http.port"))
      applyAssertionTo: status
      assert:
      - isEqualTo: 200