Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB42417A83 for ; Mon, 27 Apr 2015 20:04:35 +0000 (UTC) Received: (qmail 67903 invoked by uid 500); 27 Apr 2015 20:04:35 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 67880 invoked by uid 500); 27 Apr 2015 20:04:35 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 67871 invoked by uid 99); 27 Apr 2015 20:04:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2015 20:04:35 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [54.76.25.247] (HELO mx1-eu-west.apache.org) (54.76.25.247) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2015 20:04:10 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id D879024B1E for ; Mon, 27 Apr 2015 20:04:08 +0000 (UTC) Received: (qmail 65480 invoked by uid 99); 27 Apr 2015 20:04:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2015 20:04:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CDDC9E17BD; Mon, 27 Apr 2015 20:04:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aledsage@apache.org To: commits@brooklyn.incubator.apache.org Date: Mon, 27 Apr 2015 20:04:07 -0000 Message-Id: <52fce400dc5842ca85b5be132c03c537@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] incubator-brooklyn git commit: Support concurrent web app deploy effectors X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-brooklyn Updated Branches: refs/heads/master 6d1e7ea38 -> e38b4b757 Support concurrent web app deploy effectors Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d9a77018 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d9a77018 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d9a77018 Branch: refs/heads/master Commit: d9a770188f0437211af2d3e3f94e991d0901220a Parents: 6d1e7ea Author: Svetoslav Neykov Authored: Wed Apr 22 17:23:41 2015 +0300 Committer: Svetoslav Neykov Committed: Fri Apr 24 18:30:50 2015 +0300 ---------------------------------------------------------------------- .../entity/webapp/JavaWebAppSshDriver.java | 3 +- .../webapp/WebAppConcurrentDeployTest.java | 103 +++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d9a77018/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java index da2af62..cd32b01 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java @@ -30,6 +30,7 @@ import brooklyn.location.basic.SshMachineLocation; import brooklyn.util.task.DynamicTasks; import brooklyn.util.task.Tasks; import brooklyn.util.task.ssh.SshTasks; +import brooklyn.util.text.Strings; import com.google.common.collect.ImmutableList; @@ -153,7 +154,7 @@ public abstract class JavaWebAppSshDriver extends JavaSoftwareProcessSshDriver i final String canonicalTargetName = getFilenameContextMapper().convertDeploymentTargetNameToFilename(targetName); final String dest = getDeployDir() + "/" + canonicalTargetName; //write to a .tmp so autodeploy is not triggered during upload - final String tmpDest = dest + ".tmp"; + final String tmpDest = dest + "." + Strings.makeRandomId(8) + ".tmp"; final String msg = String.format("deploying %s to %s:%s", new Object[]{url, getHostname(), dest}); log.info(entity + " " + msg); Tasks.setBlockingDetails(msg); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d9a77018/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java new file mode 100644 index 0000000..72f36a8 --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java @@ -0,0 +1,103 @@ +/* + * 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.webapp; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.Collection; + +import org.apache.http.client.HttpClient; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import brooklyn.entity.BrooklynAppUnitTestSupport; +import brooklyn.entity.basic.Attributes; +import brooklyn.entity.basic.BrooklynConfigKeys; +import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.jboss.JBoss7Server; +import brooklyn.entity.webapp.tomcat.TomcatServer; +import brooklyn.location.Location; +import brooklyn.location.LocationSpec; +import brooklyn.location.basic.LocalhostMachineProvisioningLocation; +import brooklyn.management.Task; +import brooklyn.test.Asserts; +import brooklyn.test.EntityTestUtils; +import brooklyn.test.TestResourceUnavailableException; +import brooklyn.util.collections.MutableList; +import brooklyn.util.collections.MutableMap; +import brooklyn.util.http.HttpTool; +import brooklyn.util.http.HttpToolResponse; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +public class WebAppConcurrentDeployTest extends BrooklynAppUnitTestSupport { + private Location loc; + + @Override + @BeforeMethod(alwaysRun=true) + public void setUp() throws Exception { + super.setUp(); + app.config().set(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, false); +// tested on loc = mgmt.getLocationRegistry().resolve("byon:(hosts=\"hostname\")"); + loc = mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)); + } + + @DataProvider(name = "basicEntities") + public Object[][] basicEntities() { + return new Object[][]{ + {EntitySpec.create(TomcatServer.class)}, + // Hot Deploy not enabled? + // {EntitySpec.create(JBoss6Server.class)}, + {EntitySpec.create(JBoss7Server.class)}, + }; + } + + @Test(groups = "Live", dataProvider="basicEntities") + public void testConcurrentDeploys(EntitySpec webServerSpec) throws Exception { + JavaWebAppSoftwareProcess server = app.createAndManageChild(webServerSpec); + app.start(ImmutableList.of(loc)); + EntityTestUtils.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, Boolean.TRUE); + Collection> deploys = MutableList.of(); + for (int i = 0; i < 5; i++) { + deploys.add(server.invoke(TomcatServer.DEPLOY, MutableMap.of("url", getTestWar(), "targetName", "/"))); + } + for(Task t : deploys) { + t.getUnchecked(); + } + + final HttpClient client = HttpTool.httpClientBuilder().build(); + final URI warUrl = URI.create(server.getAttribute(JavaWebAppSoftwareProcess.ROOT_URL)); + Asserts.succeedsEventually(new Runnable() { + @Override + public void run() { + HttpToolResponse resp = HttpTool.httpGet(client, warUrl, ImmutableMap.of()); + assertEquals(resp.getResponseCode(), 200); + } + }); + } + + public String getTestWar() { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); + return "classpath://hello-world.war"; + } + +}