brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [15/21] git commit: Fix build errors caused by Brooklyn updates
Date Wed, 28 May 2014 16:05:31 GMT
Fix build errors caused by Brooklyn updates


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4f1cd535
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4f1cd535
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4f1cd535

Branch: refs/heads/master
Commit: 4f1cd535b1a006a80e5aa85b6d6e1314d11bb394
Parents: 24fb329
Author: Andrew Kennedy <andrew.kennedy@cloudsoftcorp.com>
Authored: Wed May 28 15:46:06 2014 +0100
Committer: Andrew Kennedy <andrew.kennedy@cloudsoftcorp.com>
Committed: Wed May 28 16:31:49 2014 +0100

----------------------------------------------------------------------
 sandbox/extra/pom.xml                           |  7 ++++
 .../postgresql/PostgreSqlNodeSaltImpl.java      | 37 ++++++++++++++++----
 .../entity/salt/SaltLifecycleEffectorTasks.java |  6 ++--
 .../postgresql/PostgreSqlSaltLiveTest.java      | 26 +++++++++-----
 .../entity/salt/SaltLiveTestSupport.java        |  4 +--
 5 files changed, 59 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4f1cd535/sandbox/extra/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/extra/pom.xml b/sandbox/extra/pom.xml
index 6251198..71c6795 100644
--- a/sandbox/extra/pom.xml
+++ b/sandbox/extra/pom.xml
@@ -48,6 +48,13 @@
             <classifier>tests</classifier>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>io.brooklyn</groupId>
+            <artifactId>brooklyn-software-database</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4f1cd535/sandbox/extra/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeSaltImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/extra/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeSaltImpl.java
b/sandbox/extra/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeSaltImpl.java
index 66d5b85..fee456b 100644
--- a/sandbox/extra/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeSaltImpl.java
+++ b/sandbox/extra/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeSaltImpl.java
@@ -35,7 +35,8 @@ public class PostgreSqlNodeSaltImpl extends EffectorStartableImpl implements
Pos
     public static final Effector<String> EXECUTE_SCRIPT = Effectors.effector(String.class,
"executeScript")
             .description("invokes a script")
             .parameter(ExecuteScriptEffectorBody.SCRIPT)
-            .impl(new ExecuteScriptEffectorBody()).build();
+            .impl(new ExecuteScriptEffectorBody())
+            .build();
 
     private SshFeed feed;
 
@@ -78,21 +79,23 @@ public class PostgreSqlNodeSaltImpl extends EffectorStartableImpl implements
Pos
             super.postStartCustom();
 
             // now run the creation script
-            String creationScript;
             String creationScriptUrl = entity().getConfig(PostgreSqlNode.CREATION_SCRIPT_URL);
-            if (creationScriptUrl != null)
+            String creationScript;
+            if (creationScriptUrl != null) {
                 creationScript = new ResourceUtils(entity()).getResourceAsString(creationScriptUrl);
-            else creationScript = entity().getConfig(PostgreSqlNode.CREATION_SCRIPT_CONTENTS);
+            } else {
+                creationScript = entity().getConfig(PostgreSqlNode.CREATION_SCRIPT_CONTENTS);
+            }
             entity().invoke(PostgreSqlNodeSaltImpl.EXECUTE_SCRIPT,
                     ConfigBag.newInstance().configure(ExecuteScriptEffectorBody.SCRIPT, creationScript).getAllConfig()).getUnchecked();
 
             // and finally connect sensors
-            ((PostgreSqlNodeSaltImpl)entity()).connectSensors();
+            ((PostgreSqlNodeSaltImpl) entity()).connectSensors();
         }
 
         @Override
         protected void preStopCustom() {
-            ((PostgreSqlNodeSaltImpl)entity()).disconnectSensors();
+            ((PostgreSqlNodeSaltImpl) entity()).disconnectSensors();
             super.preStopCustom();
         }
     }
@@ -111,7 +114,7 @@ public class PostgreSqlNodeSaltImpl extends EffectorStartableImpl implements
Pos
     }
 
     protected void connectSensors() {
-        setAttribute(DB_URL, String.format("postgresql://%s:%s/", getAttribute(HOSTNAME),
getAttribute(POSTGRESQL_PORT)));
+        setAttribute(DATASTORE_URL, String.format("postgresql://%s:%s/", getAttribute(HOSTNAME),
getAttribute(POSTGRESQL_PORT)));
 
         Location machine = Iterables.get(getLocations(), 0, null);
 
@@ -133,4 +136,24 @@ public class PostgreSqlNodeSaltImpl extends EffectorStartableImpl implements
Pos
         if (feed != null) feed.stop();
     }
 
+    @Override
+    public Integer getPostgreSqlPort() { return getAttribute(POSTGRESQL_PORT); }
+
+    @Override
+    public String getSharedMemory() { return getConfig(SHARED_MEMORY); }
+
+    @Override
+    public Integer getMaxConnections() { return getConfig(MAX_CONNECTIONS); }
+
+    @Override
+    public String getShortName() {
+        return "PostgreSQL";
+    }
+
+    @Override
+    public String executeScript(String commands) {
+        return Entities.invokeEffector(this, this, EXECUTE_SCRIPT,
+                ConfigBag.newInstance().configure(ExecuteScriptEffectorBody.SCRIPT, commands).getAllConfig()).getUnchecked();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4f1cd535/sandbox/extra/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/sandbox/extra/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
b/sandbox/extra/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
index ff114f3..a08de67 100644
--- a/sandbox/extra/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
+++ b/sandbox/extra/src/main/java/brooklyn/entity/salt/SaltLifecycleEffectorTasks.java
@@ -18,8 +18,8 @@ package brooklyn.entity.salt;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import brooklyn.config.BrooklynServerConfig;
 import brooklyn.entity.Entity;
-import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.Lifecycle;
 import brooklyn.entity.software.MachineLifecycleEffectorTasks;
@@ -91,8 +91,8 @@ public class SaltLifecycleEffectorTasks extends MachineLifecycleEffectorTasks
im
 
     protected void startMinionAsync() {
         // TODO make directories more configurable (both for ssh-drivers and for this)
-        String installDir = Urls.mergePaths(AbstractSoftwareProcessSshDriver.BROOKLYN_HOME_DIR,
"salt-install");
-        String runDir = Urls.mergePaths(AbstractSoftwareProcessSshDriver.BROOKLYN_HOME_DIR,
+        String installDir = Urls.mergePaths(BrooklynServerConfig.getMgmtBaseDir(entity().getManagementContext()),
"salt-install");
+        String runDir = Urls.mergePaths(BrooklynServerConfig.getMgmtBaseDir(entity().getManagementContext()),
                 "apps/"+entity().getApplicationId()+"/salt-entities/"+entity().getId());
 
         Boolean masterless = entity().getConfig(SaltConfig.MASTERLESS_MODE);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4f1cd535/sandbox/extra/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
----------------------------------------------------------------------
diff --git a/sandbox/extra/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
b/sandbox/extra/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
index ff760b3..c810ee0 100644
--- a/sandbox/extra/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
+++ b/sandbox/extra/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlSaltLiveTest.java
@@ -11,6 +11,8 @@ import org.testng.annotations.Test;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.database.VogellaExampleAccess;
 import brooklyn.entity.effector.EffectorTasks;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.salt.SaltConfig;
 import brooklyn.entity.salt.SaltLiveTestSupport;
 import brooklyn.entity.software.SshEffectorTasks;
 import brooklyn.location.PortRange;
@@ -22,7 +24,7 @@ import brooklyn.util.time.Duration;
 import com.google.common.collect.ImmutableList;
 
 /**
- * Tests Salt installation of PostgreSql.
+ * Tests Salt installation of {@link PostgreSqlNode} entity.
  */
 public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
 
@@ -32,13 +34,18 @@ public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
 
     @Override
     @AfterMethod(alwaysRun=true)
-    public void tearDown() {
-        // Ignore
+    public void tearDown() throws Exception {
+        try {
+            if (psql != null) psql.stop();
+        } finally {
+            super.tearDown();
+        }
     }
 
     @Test(groups="Live")
     public void testPostgresStartsAndStops() throws Exception {
-        psql = app.createAndManageChild(PostgreSqlSpecs.specSalt());
+        psql = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class, PostgreSqlNodeSaltImpl.class)
+                .configure(SaltConfig.MASTERLESS_MODE, true));
 
         app.start(ImmutableList.of(targetLocation));
 
@@ -51,8 +58,9 @@ public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
             // if host is still contactable ensure postgres is not running
             ProcessTaskWrapper<Integer> t = Entities.submit(app, SshEffectorTasks.ssh("ps
aux | grep [p]ostgres").machine(targetMachine).allowingNonZeroExitCode());
             t.getTask().blockUntilEnded(Duration.TEN_SECONDS);
-            if (!t.isDone())
+            if (!t.isDone()) {
                 Assert.fail("Task not finished yet: "+t.getTask());
+            }
             Assert.assertNotEquals(t.get(), (Integer)0, "Task ended with code "+t.get()+";
output: "+t.getStdout() );
         } catch (Exception e) {
             // host has been killed, that is fine
@@ -64,14 +72,14 @@ public class PostgreSqlSaltLiveTest extends SaltLiveTestSupport {
     public void testPostgresScriptAndAccess() throws Exception {
         SaltLiveTestSupport.createLocation(mgmt);
         PortRange randomPort = PortRanges.fromString(""+(5420+new Random().nextInt(10))+"+");
-        psql = app.createAndManageChild(PostgreSqlSpecs.specSalt()
+        psql = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class, PostgreSqlNodeSaltImpl.class)
+                .configure(SaltConfig.MASTERLESS_MODE, true)
                 .configure(PostgreSqlNode.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
-                .configure(PostgreSqlNode.POSTGRESQL_PORT, randomPort)
-            );
+                .configure(PostgreSqlNode.POSTGRESQL_PORT, randomPort));
 
         app.start(ImmutableList.of(targetLocation));
 
-        String url = psql.getAttribute(PostgreSqlNode.DB_URL);
+        String url = psql.getAttribute(PostgreSqlNode.DATASTORE_URL);
         log.info("Trying to connect to "+psql+" at "+url);
         Assert.assertNotNull(url);
         Assert.assertTrue(url.contains("542"));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4f1cd535/sandbox/extra/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
----------------------------------------------------------------------
diff --git a/sandbox/extra/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java b/sandbox/extra/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
index fabb7d7..6728ed6 100644
--- a/sandbox/extra/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
+++ b/sandbox/extra/src/test/java/brooklyn/entity/salt/SaltLiveTestSupport.java
@@ -19,13 +19,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
 
-import brooklyn.entity.BrooklynMgmtContextTestSupport;
+import brooklyn.entity.BrooklynAppLiveTestSupport;
 import brooklyn.location.Location;
 import brooklyn.location.MachineProvisioningLocation;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.management.ManagementContext;
 
-public class SaltLiveTestSupport extends BrooklynMgmtContextTestSupport {
+public class SaltLiveTestSupport extends BrooklynAppLiveTestSupport {
 
     private static final Logger log = LoggerFactory.getLogger(SaltLiveTestSupport.class);
 


Mime
View raw message