[
https://issues.apache.org/jira/browse/BROOKLYN-264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15385439#comment-15385439
]
ASF GitHub Bot commented on BROOKLYN-264:
-----------------------------------------
Github user bostko commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/266#discussion_r71472214
--- Diff:
software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessStopsDuringStartJcloudsLiveTest.java
---
@@ -0,0 +1,231 @@
+/*
+ * 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 org.apache.brooklyn.entity.software.base;
+
+import static org.apache.brooklyn.test.Asserts.assertEquals;
+import static org.apache.brooklyn.test.Asserts.assertNotNull;
+import static org.apache.brooklyn.test.Asserts.assertTrue;
+import static org.apache.brooklyn.test.Asserts.fail;
+
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
+
+import javax.annotation.Nullable;
+
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.MachineLocation;
+import org.apache.brooklyn.api.location.ProvisioningLocation;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.location.LocationConfigKeys;
+import org.apache.brooklyn.core.location.Machines;
+import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.entity.AbstractEc2LiveTest;
+import
org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks;
+import
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+import
org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
+import org.apache.brooklyn.util.time.Duration;
+import org.jclouds.aws.ec2.compute.AWSEC2ComputeService;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Stopwatch;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+public class SoftwareProcessStopsDuringStartJcloudsLiveTest extends
BrooklynAppLiveTestSupport {
+ private static final Logger LOG =
LoggerFactory.getLogger(SoftwareProcessStopsDuringStartJcloudsLiveTest.class);
+
+ // same image as in AbstractEc2LiveTest.test_CentOS_6_3
+ // Image: {id=us-east-1/ami-a96b01c0, providerId=ami-a96b01c0,
name=CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1,
location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2,
iso3166Codes=[US-VA]}, os={family=centos, arch=paravirtual, version=6.3,
description=aws-marketplace/CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1,
is64Bit=true}, description=CentOS-6.3-x86_64-GA-EBS-02 on EBS x86_64
20130527:1219, version=bb9af1d2.1, status=AVAILABLE[available], loginUser=root,
userMetadata={owner=679593333241, rootDeviceType=ebs,
virtualizationType=paravirtual, hypervisor=xen}})
+ public static final String PROVIDER = "aws-ec2";
+ public static final String REGION_NAME = "us-east-1";
+ public static final String IMAGE_ID = "us-east-1/ami-a96b01c0";
+ public static final String HARDWARE_ID =
AbstractEc2LiveTest.SMALL_HARDWARE_ID;
+ public static final String LOCATION_SPEC = PROVIDER + (REGION_NAME ==
null ? "" : ":" + REGION_NAME);
+
+ protected BrooklynProperties brooklynProperties;
+
+ protected ExecutorService executor;
+
+ @BeforeMethod(alwaysRun=true)
+ @Override
+ public void setUp() throws Exception {
+ // Don't let any defaults from brooklyn.properties (except
credentials) interfere with test
+ brooklynProperties = BrooklynProperties.Factory.newDefault();
+
+ // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `.
~/.profile`, then that can cause "stdin: is not a tty")
+ brooklynProperties.remove("brooklyn.ssh.config.scriptHeader");
+
+ mgmt = new LocalManagementContextForTests(brooklynProperties);
+ super.setUp();
+
+ executor = Executors.newCachedThreadPool();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ if (executor != null) {
+ executor.shutdownNow();
+ }
+ super.tearDown();
+ }
+
+ // Integration because takes approx 1 seconds
+ @Test(groups = "Integration")
+ public void testStartStopSequentiallyIsQuickInLocalhost() throws
Exception {
+ LocalhostMachineProvisioningLocation localLoc =
mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+ .configure(SshMachineLocation.SSH_TOOL_CLASS,
RecordingSshTool.class.getName()));
+ runStartStopSequentiallyIsQuick(localLoc);
+ }
+
+ // Integration because takes approx 1 seconds
+ @Test(groups = "Integration")
+ public void testStartStopSequentiallyIsQuickInByon() throws Exception {
+ FixedListMachineProvisioningLocation<?> byonLoc =
mgmt.getLocationManager().createLocation(LocationSpec.create(FixedListMachineProvisioningLocation.class)
+
.configure(FixedListMachineProvisioningLocation.MACHINE_SPECS,
ImmutableList.<LocationSpec<? extends MachineLocation>>of(
+ LocationSpec.create(SshMachineLocation.class)
+ .configure("address", "1.2.3.4")
+
.configure(SshMachineLocation.SSH_TOOL_CLASS,
RecordingSshTool.class.getName()))));
+ runStartStopSequentiallyIsQuick(byonLoc);
+ }
+
+ protected void runStartStopSequentiallyIsQuick(final
ProvisioningLocation<?> loc) throws Exception {
+ final EmptySoftwareProcess entity =
app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class)
+
.configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true));
+
+ executeInLimitedTime(new Callable<Void>() {
+ public Void call() {
+ app.start(ImmutableList.of(loc));
+ return null;
+ }
+ }, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(),
TimeUnit.MILLISECONDS);
+ EntityAsserts.assertEntityHealthy(entity);
+
assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONING_TASK_STATE),
MachineLifecycleEffectorTasks.ProvisioningTaskState.DONE);
+
assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE),
Machines.findUniqueMachineLocation(entity.getLocations(),
SshMachineLocation.class).get());
+
+ executeInLimitedTime(new Callable<Void>() {
+ public Void call() {
+ Entities.destroy(app);
+ return null;
+ }
+ }, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(),
TimeUnit.MILLISECONDS);
--- End diff --
Isn't this too big value?
> Stop app while VM still being provisioned: vm is left running when app is
> expunged
> ----------------------------------------------------------------------------------
>
> Key: BROOKLYN-264
> URL: https://issues.apache.org/jira/browse/BROOKLYN-264
> Project: Brooklyn
> Issue Type: Bug
> Affects Versions: 0.9.0
> Reporter: Aled Sage
>
> A customer deployed an app to AWS, but while the VM was still starting up
> they stopped (and thus expunged) the app. The app disappeared from the
> Brooklyn web-console, but the starting VM was left behind in AWS.
> This is simple to reproduce:
> 1. deploy a simple blueprint, such as:
> {noformat}
> location: aws-ec2:us-east-1
> services:
> - type: org.apache.brooklyn.entity.machine.MachineEntity
> {noformat}
> 2. wait for the VM to appear in the AWS web-console (with state
> "initialising")
> 3. call the {{stop}} effector on the top-level app.
> ---
> Looking at the {{start}} task that was executing at the time when {{stop}}
> was called, below is the thread's stack trace:
> {noformat}
> Provisioning machine in JcloudsLocation[AWS
> Virginia:AAAAAAAAAAAAAAAAAAAA/aws-ec2:us-east-1@eyNrLIo5]
> Task[provisioning (AWS Virginia)]@MJITkjw0
> Submitted by SoftlyPresent[value=Task[start]@tKw0qJET]
> In progress, thread waiting (notify) on
> java.util.concurrent.CountDownLatch$Sync@2ed5be36
> At:
> org.jclouds.concurrent.FutureIterables.awaitCompletion(FutureIterables.java:149)
>
> org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:214)
>
> org.jclouds.ec2.compute.EC2ComputeService.createNodesInGroup(EC2ComputeService.java:149)
>
> org.apache.brooklyn.location.jclouds.JcloudsLocation.obtainOnce(JcloudsLocation.java:726)
>
> org.apache.brooklyn.location.jclouds.JcloudsLocation.obtain(JcloudsLocation.java:616)
>
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ObtainLocationTask.call(MachineLifecycleEffectorTasks.java:406)
>
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ObtainLocationTask.call(MachineLifecycleEffectorTasks.java:396)
>
> org.apache.brooklyn.util.core.task.Tasks.withBlockingDetails(Tasks.java:98)
>
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ProvisionMachineTask.call(MachineLifecycleEffectorTasks.java:380)
>
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ProvisionMachineTask.call(MachineLifecycleEffectorTasks.java:364)
>
> org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:359)
>
> org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
> {noformat}
> From this, we can see that we are still calling jclouds. This means that
> jclouds has not yet returned to Brooklyn the VM's id. It also means that the
> {{MachineEntity}} will not have been given a {{JcloudsSshMachineLocation}}
> instance.
> When {{stop}} is called on the {{MachineEntity}}, it doesn't have a machine
> location instance so it doesn't have anything to ask to stop. This is why the
> VM is left running.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)