You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/10/08 01:59:48 UTC

[09/18] git commit: couchbase 3.0 support

couchbase 3.0 support


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

Branch: refs/heads/master
Commit: 5697c1a92e8bbd85938384728dfb57eb391af79d
Parents: eb4b14f
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Oct 6 21:16:35 2014 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Oct 6 22:42:54 2014 -0700

----------------------------------------------------------------------
 .../downloads/BasicDownloadRequirement.java     |  2 +-
 .../nosql/couchbase/CouchbaseCluster.java       |  6 ++
 .../nosql/couchbase/CouchbaseClusterImpl.java   | 52 ++++++------
 .../entity/nosql/couchbase/CouchbaseNode.java   |  9 ++-
 .../nosql/couchbase/CouchbaseNodeDriver.java    |  3 +
 .../nosql/couchbase/CouchbaseNodeImpl.java      |  5 ++
 .../nosql/couchbase/CouchbaseNodeSshDriver.java | 84 ++++++++++++++++----
 .../nosql/couchbase/CouchbaseOfflineTest.java   | 62 +++++++++++++++
 .../couchbase-replication-w-pillowfight.yaml    |  9 +++
 9 files changed, 186 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/core/src/main/java/brooklyn/entity/drivers/downloads/BasicDownloadRequirement.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/drivers/downloads/BasicDownloadRequirement.java b/core/src/main/java/brooklyn/entity/drivers/downloads/BasicDownloadRequirement.java
index 335ab86..f77cde2 100644
--- a/core/src/main/java/brooklyn/entity/drivers/downloads/BasicDownloadRequirement.java
+++ b/core/src/main/java/brooklyn/entity/drivers/downloads/BasicDownloadRequirement.java
@@ -60,7 +60,7 @@ public class BasicDownloadRequirement implements DownloadRequirement {
     public BasicDownloadRequirement(EntityDriver entityDriver, String addonName, Map<String, ?> properties) {
         this.entityDriver = checkNotNull(entityDriver, "entityDriver");
         this.addonName = checkNotNull(addonName, "addonName");
-        this.properties = checkNotNull(properties, "addonProperties");
+        this.properties = checkNotNull(properties, "properties");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
index 48860ac..5e8ec23 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseCluster.java
@@ -68,6 +68,12 @@ public interface CouchbaseCluster extends DynamicCluster {
     @SetFromFlag("postStartStabilizationDelay")
     ConfigKey<Duration> NODES_STARTED_STABILIZATION_DELAY = ConfigKeys.newConfigKey(Duration.class, "couchbase.cluster.postStartStabilizationDelay", "Delay after nodes have been started before treating it as a cluster", Duration.TEN_SECONDS);
     
+    @SetFromFlag("adminUsername")
+    ConfigKey<String> COUCHBASE_ADMIN_USERNAME = CouchbaseNode.COUCHBASE_ADMIN_USERNAME;
+
+    @SetFromFlag("adminPassword")
+    ConfigKey<String> COUCHBASE_ADMIN_PASSWORD = CouchbaseNode.COUCHBASE_ADMIN_PASSWORD;
+
     @SuppressWarnings("serial")
     AttributeSensor<List<String>> COUCHBASE_CLUSTER_UP_NODE_ADDRESSES = Sensors.newSensor(new TypeToken<List<String>>() {},
         "couchbase.cluster.node.addresses", "List of host:port of all active nodes in the cluster (http admin port, and public hostname/IP)");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
index d23c812..8adc308 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseClusterImpl.java
@@ -220,40 +220,38 @@ public class CouchbaseClusterImpl extends DynamicClusterImpl implements Couchbas
                 }
                 
                 ((CouchbaseNode)getPrimaryNode()).rebalance();
+            } else if (getQuorumSize()>1) {
+                log.warn(this+" is not quorate; will likely fail later, but proceeding for now");
+            }
                 
-                if (getConfig(CREATE_BUCKETS)!=null) {
-                    try {
-                        Tasks.setBlockingDetails("Creating buckets in Couchbase");
-
-                        createBuckets();
-                        DependentConfiguration.waitInTaskForAttributeReady(this, CouchbaseCluster.BUCKET_CREATION_IN_PROGRESS, Predicates.equalTo(false));
-                    
-                    } finally {
-                        Tasks.resetBlockingDetails();
-                    }
+            if (getConfig(CREATE_BUCKETS)!=null) {
+                try {
+                    Tasks.setBlockingDetails("Creating buckets in Couchbase");
+
+                    createBuckets();
+                    DependentConfiguration.waitInTaskForAttributeReady(this, CouchbaseCluster.BUCKET_CREATION_IN_PROGRESS, Predicates.equalTo(false));
+
+                } finally {
+                    Tasks.resetBlockingDetails();
                 }
+            }
 
-                if (getConfig(REPLICATION)!=null) {
-                    try {
-                        Tasks.setBlockingDetails("Configuring replication rules");
+            if (getConfig(REPLICATION)!=null) {
+                try {
+                    Tasks.setBlockingDetails("Configuring replication rules");
 
-                        List<Map<String, Object>> replRules = getConfig(REPLICATION);
-                        for (Map<String, Object> replRule: replRules) {
-                            DynamicTasks.queue(Effectors.invocation(getPrimaryNode(), CouchbaseNode.ADD_REPLICATION_RULE, replRule));
-                        }
-                        DynamicTasks.waitForLast();
-                    
-                    } finally {
-                        Tasks.resetBlockingDetails();
+                    List<Map<String, Object>> replRules = getConfig(REPLICATION);
+                    for (Map<String, Object> replRule: replRules) {
+                        DynamicTasks.queue(Effectors.invocation(getPrimaryNode(), CouchbaseNode.ADD_REPLICATION_RULE, replRule));
                     }
-                }
+                    DynamicTasks.waitForLast();
 
-                setAttribute(IS_CLUSTER_INITIALIZED, true);
-            } else {
-                //TODO: add a repeater to wait for a quorum of servers to be up.
-                //retry waiting for service up?
-                //check Repeater.
+                } finally {
+                    Tasks.resetBlockingDetails();
+                }
             }
+
+            setAttribute(IS_CLUSTER_INITIALIZED, true);
         } else {
             throw new IllegalStateException("No up nodes available after starting");
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
index 1337570..3a27144 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNode.java
@@ -34,7 +34,6 @@ import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensorAndConfigKey;
 import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
 import brooklyn.event.basic.Sensors;
-import brooklyn.util.config.ConfigBag;
 import brooklyn.util.flags.SetFromFlag;
 import brooklyn.util.text.ByteSizeStrings;
 
@@ -51,11 +50,15 @@ public interface CouchbaseNode extends SoftwareProcess {
 
     @SetFromFlag("version")
     ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION,
-            "2.5.1");
+            "3.0.0");
+
+    @SetFromFlag("enterprise")
+    ConfigKey<Boolean> USE_ENTERPRISE = ConfigKeys.newBooleanConfigKey("couchbase.enterprise.enabled",
+        "Whether to use Couchbase Enterprise. Defaults to false for 3.0.0 and later.");
 
     @SetFromFlag("downloadUrl")
     BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new BasicAttributeSensorAndConfigKey<String>(
-            SoftwareProcess.DOWNLOAD_URL, "http://packages.couchbase.com/releases/${version}/couchbase-server-enterprise_${version}_${driver.osTag}");
+            SoftwareProcess.DOWNLOAD_URL, "http://packages.couchbase.com/releases/${version}/couchbase-server-${driver.communityOrEnterprise}_${version}${driver.osTagWithPrefix}");
 
     @SetFromFlag("clusterInitRamSize")
     BasicAttributeSensorAndConfigKey<Integer> COUCHBASE_CLUSTER_INIT_RAM_SIZE = new BasicAttributeSensorAndConfigKey<Integer>(

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeDriver.java
index 727dbbf..54efa39 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeDriver.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeDriver.java
@@ -23,6 +23,9 @@ import brooklyn.entity.basic.SoftwareProcessDriver;
 
 public interface CouchbaseNodeDriver extends SoftwareProcessDriver {
     public String getOsTag();
+    public String getOsTagWithPrefix();
+    
+    public String getCommunityOrEnterprise();
 
     public void serverAdd(String serverToAdd, String username, String password);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
index d7feab4..e97ff3d 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeImpl.java
@@ -53,6 +53,7 @@ import brooklyn.util.guava.TypeTokens;
 import brooklyn.util.http.HttpTool;
 import brooklyn.util.http.HttpToolResponse;
 import brooklyn.util.net.Urls;
+import brooklyn.util.text.Strings;
 
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
@@ -242,6 +243,10 @@ public class CouchbaseNodeImpl extends SoftwareProcessImpl implements CouchbaseN
 
     @Override
     public void bucketCreate(String bucketName, String bucketType, Integer bucketPort, Integer bucketRamSize, Integer bucketReplica) {
+        if (Strings.isBlank(bucketType)) bucketType = "couchbase";
+        if (bucketRamSize==null || bucketRamSize<=0) bucketRamSize = 200;
+        if (bucketReplica==null || bucketReplica<0) bucketReplica = 1;
+        
         getDriver().bucketCreate(bucketName, bucketType, bucketPort, bucketRamSize, bucketReplica);
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeSshDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeSshDriver.java
index 6fecc13..17a5a5a 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeSshDriver.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeSshDriver.java
@@ -27,6 +27,7 @@ import static java.lang.String.format;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -39,6 +40,8 @@ import brooklyn.entity.Entity;
 import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.Entities;
+import brooklyn.entity.drivers.downloads.BasicDownloadRequirement;
+import brooklyn.entity.drivers.downloads.DownloadProducerFromUrlAttribute;
 import brooklyn.entity.software.SshEffectorTasks;
 import brooklyn.event.basic.DependentConfiguration;
 import brooklyn.event.feed.http.HttpValueFunctions;
@@ -53,6 +56,7 @@ import brooklyn.util.ssh.BashCommands;
 import brooklyn.util.task.DynamicTasks;
 import brooklyn.util.task.TaskTags;
 import brooklyn.util.task.Tasks;
+import brooklyn.util.text.NaturalOrderComparator;
 import brooklyn.util.time.Duration;
 
 import com.google.common.base.Function;
@@ -101,7 +105,7 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
 
     private List<String> installLinux(List<String> urls, String saveAs) {
 
-        log.info("Installing from package manager couchbase-server version: {}", getVersion());
+        log.info("Installing "+getEntity()+" using couchbase-server-{} {}", getCommunityOrEnterprise(), getVersion());
 
         String apt = chainGroup(
                 "export DEBIAN_FRONTEND=noninteractive",
@@ -123,9 +127,16 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
                 sudo("[ -f /etc/redhat-release ] && (grep -i \"red hat\" /etc/redhat-release && sudo yum install -y openssl098e) || :"),
                 sudo(format("rpm --install %s", saveAs)));
 
+        String link = new DownloadProducerFromUrlAttribute().apply(new BasicDownloadRequirement(this)).getPrimaryLocations().iterator().next();
         return ImmutableList.<String>builder()
                 .add(INSTALL_CURL)
-                .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs))
+                .addAll(Arrays.asList(INSTALL_CURL, 
+                    BashCommands.require(BashCommands.alternatives(BashCommands.simpleDownloadUrlAs(urls, saveAs),
+                        // Referer link is required for 3.0.0; note mis-spelling is correct, as per http://en.wikipedia.org/wiki/HTTP_referer
+                        "curl -f -L -k "+link
+                            + " -H 'Referer: http://www.couchbase.com/downloads'"
+                            + " -o "+saveAs),
+                        "Could not retrieve "+saveAs+" (from "+urls.size()+" sites)", 9)))
                 .add(alternatives(apt, yum))
                 .build();
     }
@@ -145,6 +156,8 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
 
     @Override
     public void launch() {
+        String clusterPrefix = "--cluster-"+(isPreV300() ? "init-" : "");
+        // in v30, the cluster arguments were changed, and it became mandatory to supply a url + password (if there is none, these are ignored)
         newScript(LAUNCHING)
                 .body.append(
                 sudo("/etc/init.d/couchbase-server start"),
@@ -155,11 +168,11 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
                 "    sleep 1\n" +
                 "done\n" +
                 couchbaseCli("cluster-init") +
-                        getCouchbaseHostnameAndPort() +
-                        " --cluster-init-username=" + getUsername() +
-                        " --cluster-init-password=" + getPassword() +
-                        " --cluster-init-port=" + getWebPort() +
-                        " --cluster-init-ramsize=" + getClusterInitRamSize())
+                        (isPreV300() ? getCouchbaseHostnameAndPort() : getCouchbaseHostnameAndCredentials()) +
+                        " "+clusterPrefix+"username=" + getUsername() +
+                        " "+clusterPrefix+"password=" + getPassword() +
+                        " "+clusterPrefix+"port=" + getWebPort() +
+                        " "+clusterPrefix+"ramsize=" + getClusterInitRamSize())
                 .execute();
     }
 
@@ -185,18 +198,54 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
 
     @Override
     public String getOsTag() {
-        OsDetails os = getLocation().getOsDetails();
+        return getOsTag(getLocation().getOsDetails(), !isPreV300());
+    }
+    
+    public static String getOsTag(OsDetails os, boolean isV30OrLater) {
         if (os == null) {
-            // Default to generic linux
-            return "x86_64.rpm";
+            // Default to 64-bit centos linux
+            if (isV30OrLater)
+                return "centos6.x86_64.rpm";
+            else
+                return "x86_64.rpm";
+            
         } else {
-            //FIXME should be a better way to check for OS name and version
+            // are there should ways to check for OS name and version
             String osName = os.getName().toLowerCase();
-            String fileExtension = osName.contains("deb") || osName.contains("ubuntu") ? ".deb" : ".rpm";
-            String arch = os.is64bit() ? "x86_64" : "x86";
-            return arch + fileExtension;
+            boolean isDebbish = osName.contains("deb") || osName.contains("ubuntu");
+            
+            // couchbase only provide certain versions; if on other platforms let's suck-it-and-see
+            String family;
+            if (osName.contains("debian")) family = "debian7_";
+            else if (osName.contains("ubuntu")) family = "ubuntu12.04_";
+            else family = "centos6.";
+
+            // 32-bit binaries aren't (yet?) available
+            String arch = !os.is64bit() ? "x86" : isDebbish && isV30OrLater ? "amd64" : "x86_64";
+            String fileExtension = isDebbish ? ".deb" : ".rpm";
+            
+            if (isV30OrLater)
+                return family + arch + fileExtension;
+            else
+                return arch + fileExtension;
         }
     }
+    /** separator after the version number used to be _ but is - in 3.0 and later */
+    public String getOsTagWithPrefix() {
+        return (isPreV300() ? "_" : "-") + getOsTag(); 
+    }
+
+    private boolean isPreV300() {
+        return NaturalOrderComparator.INSTANCE.compare(getEntity().getConfig(CouchbaseNode.SUGGESTED_VERSION), "3.0") < 0;
+    }
+
+    @Override
+    public String getCommunityOrEnterprise() {
+        Boolean isEnterprise = getEntity().getConfig(CouchbaseNode.USE_ENTERPRISE);
+        // for 3.0.0 enterprise is behind a reg wall so default to community
+        if (isEnterprise==null) isEnterprise = NaturalOrderComparator.INSTANCE.compare(getEntity().getConfig(CouchbaseNode.SUGGESTED_VERSION), "3.0") >= 0 ? false : true;
+        return isEnterprise ? "enterprise" : "community";
+    }
 
     private String getUsername() {
         return entity.getConfig(CouchbaseNode.COUCHBASE_ADMIN_USERNAME);
@@ -352,6 +401,8 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
     public void addReplicationRule(Entity toCluster, String fromBucket, String toBucket) {
         DynamicTasks.queue(DependentConfiguration.attributeWhenReady(toCluster, Attributes.SERVICE_UP)).getUnchecked();
         
+        log.info("Setting up XDCR for "+fromBucket+" from "+getEntity()+" to "+toCluster);
+        
         String destName = CouchbaseClusterImpl.getClusterName(getEntity());
         Entity destPrimaryNode = toCluster.getAttribute(CouchbaseCluster.COUCHBASE_PRIMARY_NODE);
         String destHostname = destPrimaryNode.getAttribute(Attributes.HOSTNAME);
@@ -374,8 +425,11 @@ public class CouchbaseNodeSshDriver extends AbstractSoftwareProcessSshDriver imp
             " --xdcr-password="+destPassword
             ).summary("create xdcr destination "+destName).newTask()));
 
+        // would be nice to auto-create bucket, but we'll need to know the parameters; the port in particular is tedious
+//        ((CouchbaseNode)destPrimaryNode).bucketCreate(toBucket, "couchbase", null, 0, 0);
+        
         DynamicTasks.queue(SshEffectorTasks.ssh(
-            couchbaseCli("xdcr-setup") +
+            couchbaseCli("xdcr-replicate") +
             getCouchbaseHostnameAndCredentials() +
             " --create" +
             " --xdcr-cluster-name="+destName +

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/software/nosql/src/test/java/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java
new file mode 100644
index 0000000..1b89773
--- /dev/null
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.nosql.couchbase;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.basic.Entities;
+import brooklyn.location.basic.BasicOsDetails;
+import brooklyn.location.basic.BasicOsDetails.OsArchs;
+import brooklyn.management.internal.LocalManagementContext;
+import brooklyn.test.entity.LocalManagementContextForTests;
+
+public class CouchbaseOfflineTest {
+
+    private LocalManagementContext mgmt;
+
+    @BeforeMethod
+    public void setUp() {
+        mgmt = LocalManagementContextForTests.newInstance();
+    }
+    
+    @AfterMethod
+    public void tearDown() {
+        Entities.destroyAll(mgmt);
+    }
+    
+    @Test
+    public void testResolvingDownloadLinks() {
+        checkOsTag("linux", OsArchs.I386, "unknown", true, "centos6.x86.rpm");
+        checkOsTag("linux", OsArchs.I386, "unknown", false, "x86.rpm");
+        checkOsTag("rhel", OsArchs.X_86_64, "6", true, "centos6.x86_64.rpm");
+        checkOsTag("Ubuntu 14", OsArchs.X_86_64, "14.04", true, "ubuntu12.04_amd64.deb");
+        checkOsTag("Ubuntu 14", OsArchs.X_86_64, "14.04", false, "x86_64.deb");
+        checkOsTag("Debian 7up", OsArchs.I386, "7ish", true, "debian7_x86.deb");
+        Assert.assertEquals(CouchbaseNodeSshDriver.getOsTag(null, true), "centos6.x86_64.rpm");
+        Assert.assertEquals(CouchbaseNodeSshDriver.getOsTag(null, false), "x86_64.rpm");
+    }
+
+    protected void checkOsTag(String os, String arch, String version, boolean isV30, String expectedTag) {
+        Assert.assertEquals(CouchbaseNodeSshDriver.getOsTag(new BasicOsDetails(os, arch, version), isV30), expectedTag);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5697c1a9/usage/launcher/src/test/resources/couchbase-replication-w-pillowfight.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/couchbase-replication-w-pillowfight.yaml b/usage/launcher/src/test/resources/couchbase-replication-w-pillowfight.yaml
index 89664e9..252d58c 100644
--- a/usage/launcher/src/test/resources/couchbase-replication-w-pillowfight.yaml
+++ b/usage/launcher/src/test/resources/couchbase-replication-w-pillowfight.yaml
@@ -21,6 +21,7 @@ name: Couchbase w Replicating Cluster and Pillow Fight
 services:
 - type: brooklyn.entity.nosql.couchbase.CouchbaseCluster
   id: couchbase
+  name: Couchbase Primary Cluster
   adminUsername: Administrator
   adminPassword: Password
   initialSize: 3
@@ -30,18 +31,26 @@ services:
   replication:
   - toCluster: $brooklyn:entity("couchbase-backup")
     fromBucket: default
+    toBucket: default-backup
     
   location: aws-ec2:us-west-1
 
 
 - type: brooklyn.entity.nosql.couchbase.CouchbaseCluster
   id: couchbase-backup
+  name: Couchbase Backup Cluster
   adminUsername: Administrator
   adminPassword: Password2
   initialSize: 1
+  createBuckets:
+  - bucket: default-backup
+    bucket-port: 11222
   
   location: softlayer:ams01
 
+
 - type: "classpath://brooklyn/entity/nosql/couchbase/pillowfight.yaml"
   brooklyn.config:
     base_url: $brooklyn:entity("couchbase").attributeWhenReady("couchbase.cluster.connection.url") 
+
+  location: aws-ec2:us-west-1