Repository: incubator-brooklyn Updated Branches: refs/heads/master 9a80ebe3b -> 9a441be8f
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/CarrenzaLocationLiveTest.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/CarrenzaLocationLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/CarrenzaLocationLiveTest.java new file mode 100644 index 0000000..235c725 --- /dev/null +++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/CarrenzaLocationLiveTest.java @@ -0,0 +1,135 @@ +/* + * 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.location.jclouds.provider; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.apache.brooklyn.api.location.NoMachinesAvailableException; +import org.apache.brooklyn.core.internal.BrooklynProperties; +import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; +import org.apache.brooklyn.location.jclouds.JcloudsLocation; +import org.apache.brooklyn.location.jclouds.JcloudsSshMachineLocation; +import org.apache.brooklyn.location.ssh.SshMachineLocation; +import org.apache.brooklyn.util.collections.MutableMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +/** + * Tests vcloud, with Carrenza. Uses the cloudsoft test account (hard-coding its NAT Mapping, + * and one of its private vApp templates). Note that the template is for a Windows 2008 + * machine with winsshd installed. + * + * TODO Will only work with >= jclouds 1.5, due to jclouds issues 994 and 995. Therefore it + * will not work in brooklyn 0.4.0-M2 etc. + */ +class CarrenzaLocationLiveTest { + private static final Logger LOG = LoggerFactory.getLogger(CarrenzaLocationLiveTest.class); + + private static final String PROVIDER = "vcloud"; + private static final String ENDPOINT = "https://myvdc.carrenza.net/api"; + private static final String LOCATION_ID = "jclouds:"+PROVIDER+":"+ENDPOINT; + private static final String WINDOWS_IMAGE_ID = "https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-2bd5b0ff-ecd9-405e-8306-2f4f6c092a1b"; + + private BrooklynProperties brooklynProperties; + private LocalManagementContext managementContext; + private JcloudsLocation loc; + private Collection<SshMachineLocation> machines = new ArrayList<>(); + + // TODO Has not been tested since updating ot remove use of deleted LocationRegistry! + @BeforeMethod(groups = "Live") + public void setUp() { + System.out.println("classpath="+System.getProperty("java.class.path")); + + brooklynProperties = BrooklynProperties.Factory.newDefault(); + brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-description-regex"); + brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-name-regex"); + brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-id"); + brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".inboundPorts"); + brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".hardware-id"); + + // 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"); + + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".jclouds.endpoint", ENDPOINT); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".imageId", WINDOWS_IMAGE_ID); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".noDefaultSshKeys", true); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".userName", "Administrator"); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".dontCreateUser", true); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".overrideLoginUser", "Administrator"); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".waitForSshable", false); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".runAsRoot", false); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".inboundPorts", ImmutableList.of(22, 3389)); + brooklynProperties.put("brooklyn.jclouds."+PROVIDER+".natMapping", ImmutableMap.of("192.168.0.100", "195.3.186.200", "192.168.0.101", "195.3.186.42")); + + managementContext = new LocalManagementContext(brooklynProperties); + loc = (JcloudsLocation) managementContext.getLocationRegistry().resolve(LOCATION_ID); + } + + @AfterMethod(groups = "Live") + public void tearDown() throws Exception { + List<Exception> exceptions = new ArrayList<>(); + for (SshMachineLocation machine : machines) { + try { + loc.release(machine); + } catch (Exception e) { + LOG.warn("Error releasing machine $it; continuing...", e); + exceptions.add(e); + } + } + if (!exceptions.isEmpty()) { + throw exceptions.get(0); + } + machines.clear(); + } + + // FIXME Disabled because of jclouds issues #994 and #995 (fixed in jclouds 1.5, so not in brooklyn 0.4.0-M2 etc) + // Note the careful settings in setUp (e.g. so don't try to install ssh-keys etc + // Also, the windows image used has winsshd installed + @Test(enabled=false, groups = "Live") + public void testProvisionWindowsVm() throws NoMachinesAvailableException { + JcloudsSshMachineLocation machine = (JcloudsSshMachineLocation) obtainMachine(MutableMap.of( + "imageId", WINDOWS_IMAGE_ID)); + + LOG.info("Provisioned Windows VM {}; checking if has password", machine); + String password = machine.waitForPassword(); + assertNotNull(password); + + LOG.info("Checking can ssh to windows machine {} using password {}", machine, password); + assertEquals(machine.execCommands(MutableMap.of("password", password), "check-reachable", ImmutableList.of("hostname")), 0); + } + + // Use this utility method to ensure machines are released on tearDown + protected SshMachineLocation obtainMachine(Map<?, ?> flags) throws NoMachinesAvailableException { + SshMachineLocation result = (SshMachineLocation) loc.obtain(flags); + machines.add(result); + return result; + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.groovy ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.groovy b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.groovy deleted file mode 100644 index 5276302..0000000 --- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.groovy +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.location.jclouds.provider - -import org.testng.annotations.DataProvider - -public class GoGridLocationLiveTest extends AbstractJcloudsLocationTest { - - private static final String PROVIDER = "gogrid" - private static final String USWEST_REGION_NAME = "1"//"us-west-1" - private static final String USWEST_IMAGE_ID = "1532" - private static final String IMAGE_NAME_PATTERN = "CentOS 5.3 (64-bit) w/ None" - private static final String IMAGE_OWNER = null - - public GoGridLocationLiveTest() { - super(PROVIDER) - } - - @Override - @DataProvider(name = "fromImageId") - public Object[][] cloudAndImageIds() { - return [ [USWEST_REGION_NAME, USWEST_IMAGE_ID, IMAGE_OWNER] ] - } - - @Override - @DataProvider(name = "fromImageNamePattern") - public Object[][] cloudAndImageNamePatterns() { - return [ [USWEST_REGION_NAME, IMAGE_NAME_PATTERN, IMAGE_OWNER] ] - } - - @Override - @DataProvider(name = "fromImageDescriptionPattern") - public Object[][] cloudAndImageDescriptionPatterns() { - return [] - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.java new file mode 100644 index 0000000..c8ab1fe --- /dev/null +++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GoGridLocationLiveTest.java @@ -0,0 +1,52 @@ +/* + * 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.location.jclouds.provider; + +import org.testng.annotations.DataProvider; + +public class GoGridLocationLiveTest extends AbstractJcloudsLocationTest { + + private static final String PROVIDER = "gogrid"; + private static final String USWEST_REGION_NAME = "1";//"us-west-1" + private static final String USWEST_IMAGE_ID = "1532"; + private static final String IMAGE_NAME_PATTERN = "CentOS 5.3 (64-bit) w/ None"; + private static final String IMAGE_OWNER = null; + + public GoGridLocationLiveTest() { + super(PROVIDER); + } + + @Override + @DataProvider(name = "fromImageId") + public Object[][] cloudAndImageIds() { + return new Object[][] {{USWEST_REGION_NAME, USWEST_IMAGE_ID, IMAGE_OWNER}}; + } + + @Override + @DataProvider(name = "fromImageNamePattern") + public Object[][] cloudAndImageNamePatterns() { + return new Object[][] {{USWEST_REGION_NAME, IMAGE_NAME_PATTERN, IMAGE_OWNER}}; + } + + @Override + @DataProvider(name = "fromImageDescriptionPattern") + public Object[][] cloudAndImageDescriptionPatterns() { + return new Object[][] {}; + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/pom.xml ---------------------------------------------------------------------- diff --git a/policy/pom.xml b/policy/pom.xml index 0843753..c28e39f 100644 --- a/policy/pom.xml +++ b/policy/pom.xml @@ -23,8 +23,8 @@ <packaging>jar</packaging> <name>Brooklyn Policies</name> <description> - General policies and enrichers for managing entities - </description> + General policies and enrichers for managing entities + </description> <parent> <groupId>org.apache.brooklyn</groupId> @@ -44,10 +44,6 @@ <artifactId>guava</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - <dependency> <groupId>org.apache.brooklyn</groupId> <artifactId>brooklyn-utils-common</artifactId> <version>${project.version}</version> @@ -96,21 +92,4 @@ <scope>test</scope> </dependency> </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <inherited>true</inherited> - <executions> - <execution> - <id>default-testCompile</id> - <configuration> - <compilerId>groovy-eclipse-compiler</compilerId> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> </project> http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.groovy ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.groovy b/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.groovy deleted file mode 100644 index 3c5f192..0000000 --- a/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.groovy +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.policy.enricher - -import static org.testng.Assert.assertEquals - -import org.apache.brooklyn.api.entity.EntityLocal; -import org.apache.brooklyn.api.mgmt.SubscriptionContext -import org.apache.brooklyn.api.sensor.Sensor -import org.apache.brooklyn.core.entity.AbstractApplication -import org.apache.brooklyn.core.entity.AbstractEntity -import org.apache.brooklyn.core.entity.Entities -import org.apache.brooklyn.core.sensor.BasicAttributeSensor -import org.testng.annotations.AfterMethod -import org.testng.annotations.BeforeMethod -import org.testng.annotations.Test - -class DeltaEnrichersTests { - - AbstractApplication app - - EntityLocal producer - - Sensor<Integer> intSensor, deltaSensor - Sensor<Double> avgSensor - SubscriptionContext subscription - - @BeforeMethod - public void before() { - app = new AbstractApplication() {} - producer = new AbstractEntity(app) {} - Entities.startManagement(app); - - intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor") - deltaSensor = new BasicAttributeSensor<Double>(Double.class, "delta sensor") - } - - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (app != null) Entities.destroyAll(app.getManagementContext()); - } - - @Test - public void testDeltaEnricher() { - DeltaEnricher delta = new DeltaEnricher<Integer>(producer, intSensor, deltaSensor) - producer.enrichers().add(delta) - - delta.onEvent(intSensor.newEvent(producer, 0)) - delta.onEvent(intSensor.newEvent(producer, 0)) - assertEquals(producer.getAttribute(deltaSensor), 0d) - delta.onEvent(intSensor.newEvent(producer, 1)) - assertEquals(producer.getAttribute(deltaSensor), 1d) - delta.onEvent(intSensor.newEvent(producer, 3)) - assertEquals(producer.getAttribute(deltaSensor), 2d) - delta.onEvent(intSensor.newEvent(producer, 8)) - assertEquals(producer.getAttribute(deltaSensor), 5d) - } - - @Test - public void testMonospaceTimeWeightedDeltaEnricher() { - TimeWeightedDeltaEnricher delta = - TimeWeightedDeltaEnricher.<Integer>getPerSecondDeltaEnricher(producer, intSensor, deltaSensor) - producer.enrichers().add(delta) - - delta.onEvent(intSensor.newEvent(producer, 0), 0) - assertEquals(producer.getAttribute(deltaSensor), null) - delta.onEvent(intSensor.newEvent(producer, 0), 1000) - assertEquals(producer.getAttribute(deltaSensor), 0d) - delta.onEvent(intSensor.newEvent(producer, 1), 2000) - assertEquals(producer.getAttribute(deltaSensor), 1d) - delta.onEvent(intSensor.newEvent(producer, 3), 3000) - assertEquals(producer.getAttribute(deltaSensor), 2d) - delta.onEvent(intSensor.newEvent(producer, 8), 4000) - assertEquals(producer.getAttribute(deltaSensor), 5d) - } - - @Test - public void testVariableTimeWeightedDeltaEnricher() { - TimeWeightedDeltaEnricher delta = - TimeWeightedDeltaEnricher.<Integer>getPerSecondDeltaEnricher(producer, intSensor, deltaSensor) - producer.enrichers().add(delta) - - delta.onEvent(intSensor.newEvent(producer, 0), 0) - delta.onEvent(intSensor.newEvent(producer, 0), 2000) - assertEquals(producer.getAttribute(deltaSensor), 0d) - delta.onEvent(intSensor.newEvent(producer, 3), 5000) - assertEquals(producer.getAttribute(deltaSensor), 1d) - delta.onEvent(intSensor.newEvent(producer, 7), 7000) - assertEquals(producer.getAttribute(deltaSensor), 2d) - delta.onEvent(intSensor.newEvent(producer, 12), 7500) - assertEquals(producer.getAttribute(deltaSensor), 10d) - delta.onEvent(intSensor.newEvent(producer, 15), 9500) - assertEquals(producer.getAttribute(deltaSensor), 1.5d) - } - - @Test - public void testPostProcessorCalledForDeltaEnricher() { - TimeWeightedDeltaEnricher delta = new TimeWeightedDeltaEnricher(producer, intSensor, deltaSensor, 1000, {it+123}) - producer.enrichers().add(delta) - - delta.onEvent(intSensor.newEvent(producer, 0), 0) - delta.onEvent(intSensor.newEvent(producer, 0), 1000) - assertEquals(producer.getAttribute(deltaSensor), 123+0d) - delta.onEvent(intSensor.newEvent(producer, 1), 2000) - assertEquals(producer.getAttribute(deltaSensor), 123+1d) - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.java ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.java b/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.java new file mode 100644 index 0000000..3722bcd --- /dev/null +++ b/policy/src/test/java/org/apache/brooklyn/policy/enricher/DeltaEnrichersTests.java @@ -0,0 +1,144 @@ +/* + * 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.policy.enricher; + +import static org.testng.Assert.assertEquals; + +import org.apache.brooklyn.api.entity.EntityLocal; +import org.apache.brooklyn.api.mgmt.SubscriptionContext; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.api.sensor.Sensor; +import org.apache.brooklyn.core.entity.AbstractApplication; +import org.apache.brooklyn.core.entity.AbstractEntity; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.sensor.BasicAttributeSensor; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.google.common.base.Function; + +public class DeltaEnrichersTests { + + AbstractApplication app; + + EntityLocal producer; + + Sensor<Integer> intSensor; + Sensor<Double> avgSensor; + SubscriptionContext subscription; + + @BeforeMethod + public void before() { + app = new AbstractApplication() {}; + producer = new AbstractEntity(app) {}; + producer.setParent(app); + Entities.startManagement(app); + + intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor"); + } + + @AfterMethod(alwaysRun=true) + public void tearDown() throws Exception { + if (app != null) Entities.destroyAll(app.getManagementContext()); + } + + @Test + public void testDeltaEnricher() { + AttributeSensor<Integer> deltaSensor = new BasicAttributeSensor<Integer>(Integer.class, "delta sensor"); + DeltaEnricher<Integer> delta = new DeltaEnricher<Integer>(producer, intSensor, deltaSensor); + producer.enrichers().add(delta); + + delta.onEvent(intSensor.newEvent(producer, 0)); + delta.onEvent(intSensor.newEvent(producer, 0)); + assertEquals(producer.getAttribute(deltaSensor), (Integer)0); + delta.onEvent(intSensor.newEvent(producer, 1)); + assertEquals(producer.getAttribute(deltaSensor), (Integer)1); + delta.onEvent(intSensor.newEvent(producer, 3)); + assertEquals(producer.getAttribute(deltaSensor), (Integer)2); + delta.onEvent(intSensor.newEvent(producer, 8)); + assertEquals(producer.getAttribute(deltaSensor), (Integer)5); + } + + @Test + public void testMonospaceTimeWeightedDeltaEnricher() { + AttributeSensor<Double> deltaSensor = new BasicAttributeSensor<Double>(Double.class, "per second delta delta sensor"); + TimeWeightedDeltaEnricher<Integer> delta = + TimeWeightedDeltaEnricher.<Integer>getPerSecondDeltaEnricher(producer, intSensor, deltaSensor); + producer.enrichers().add(delta); + + delta.onEvent(intSensor.newEvent(producer, 0), 0); + assertEquals(producer.getAttribute(deltaSensor), null); + delta.onEvent(intSensor.newEvent(producer, 0), 1000); + assertEquals(producer.getAttribute(deltaSensor), 0d); + delta.onEvent(intSensor.newEvent(producer, 1), 2000); + assertEquals(producer.getAttribute(deltaSensor), 1d); + delta.onEvent(intSensor.newEvent(producer, 3), 3000); + assertEquals(producer.getAttribute(deltaSensor), 2d); + delta.onEvent(intSensor.newEvent(producer, 8), 4000); + assertEquals(producer.getAttribute(deltaSensor), 5d); + } + + @Test + public void testVariableTimeWeightedDeltaEnricher() { + AttributeSensor<Double> deltaSensor = new BasicAttributeSensor<Double>(Double.class, "per second delta delta sensor"); + TimeWeightedDeltaEnricher<Integer> delta = + TimeWeightedDeltaEnricher.<Integer>getPerSecondDeltaEnricher(producer, intSensor, deltaSensor); + producer.enrichers().add(delta); + + delta.onEvent(intSensor.newEvent(producer, 0), 0); + delta.onEvent(intSensor.newEvent(producer, 0), 2000); + assertEquals(producer.getAttribute(deltaSensor), 0d); + delta.onEvent(intSensor.newEvent(producer, 3), 5000); + assertEquals(producer.getAttribute(deltaSensor), 1d); + delta.onEvent(intSensor.newEvent(producer, 7), 7000); + assertEquals(producer.getAttribute(deltaSensor), 2d); + delta.onEvent(intSensor.newEvent(producer, 12), 7500); + assertEquals(producer.getAttribute(deltaSensor), 10d); + delta.onEvent(intSensor.newEvent(producer, 15), 9500); + assertEquals(producer.getAttribute(deltaSensor), 1.5d); + } + + @Test + public void testPostProcessorCalledForDeltaEnricher() { + AttributeSensor<Double> deltaSensor = new BasicAttributeSensor<Double>(Double.class, "per second delta delta sensor"); + TimeWeightedDeltaEnricher<Integer> delta = new TimeWeightedDeltaEnricher<Integer>(producer, intSensor, deltaSensor, 1000, new AddConstant(123d)); + producer.enrichers().add(delta); + + delta.onEvent(intSensor.newEvent(producer, 0), 0); + delta.onEvent(intSensor.newEvent(producer, 0), 1000); + assertEquals(producer.getAttribute(deltaSensor), 123+0d); + delta.onEvent(intSensor.newEvent(producer, 1), 2000); + assertEquals(producer.getAttribute(deltaSensor), 123+1d); + } + + private static class AddConstant implements Function<Double, Double> { + private Double constant; + + public AddConstant(Double constant) { + super(); + this.constant = constant; + } + + @Override + public Double apply(Double input) { + return input + constant; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.groovy ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.groovy b/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.groovy deleted file mode 100644 index bb7d2b7..0000000 --- a/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.groovy +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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.policy.enricher - -import static org.testng.Assert.assertEquals; - -import org.apache.brooklyn.api.entity.EntityLocal; -import org.apache.brooklyn.api.mgmt.SubscriptionContext -import org.apache.brooklyn.api.sensor.Sensor -import org.apache.brooklyn.core.entity.AbstractApplication -import org.apache.brooklyn.core.entity.AbstractEntity -import org.apache.brooklyn.core.entity.Entities -import org.apache.brooklyn.core.sensor.BasicAttributeSensor -import org.testng.annotations.AfterMethod -import org.testng.annotations.BeforeMethod -import org.testng.annotations.Test - -class RollingMeanEnricherTest { - - AbstractApplication app - - EntityLocal producer - - Sensor<Integer> intSensor, deltaSensor - Sensor<Double> avgSensor - SubscriptionContext subscription - - RollingMeanEnricher<Integer> averager - - @BeforeMethod(alwaysRun=true) - public void before() { - app = new AbstractApplication() {} - producer = new AbstractEntity(app) {} - Entities.startManagement(app); - - intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor") - deltaSensor = new BasicAttributeSensor<Integer>(Integer.class, "delta sensor") - avgSensor = new BasicAttributeSensor<Double>(Integer.class, "avg sensor") - - producer.enrichers().add(new DeltaEnricher<Integer>(producer, intSensor, deltaSensor)) - averager = new RollingMeanEnricher<Integer>(producer, deltaSensor, avgSensor, 4) - producer.enrichers().add(averager) - } - - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (app != null) Entities.destroyAll(app.getManagementContext()); - } - - @Test - public void testDefaultAverage() { - assertEquals(averager.getAverage(), null) - } - - @Test - public void testZeroWindowSize() { - averager = new RollingMeanEnricher<Integer>(producer, deltaSensor, avgSensor, 0) - producer.enrichers().add(averager) - - averager.onEvent(intSensor.newEvent(producer, 10)) - assertEquals(averager.getAverage(), null) - } - - @Test - public void testSingleValueAverage() { - averager.onEvent(intSensor.newEvent(producer, 10)) - assertEquals(averager.getAverage(), 10d) - } - - @Test - public void testMultipleValueAverage() { - averager.onEvent(intSensor.newEvent(producer, 10)) - averager.onEvent(intSensor.newEvent(producer, 20)) - averager.onEvent(intSensor.newEvent(producer, 30)) - averager.onEvent(intSensor.newEvent(producer, 40)) - assertEquals(averager.getAverage(), (10+20+30+40)/4d) - } - - @Test - public void testWindowSizeCulling() { - averager.onEvent(intSensor.newEvent(producer, 10)) - averager.onEvent(intSensor.newEvent(producer, 20)) - averager.onEvent(intSensor.newEvent(producer, 30)) - averager.onEvent(intSensor.newEvent(producer, 40)) - averager.onEvent(intSensor.newEvent(producer, 50)) - averager.onEvent(intSensor.newEvent(producer, 60)) - assertEquals(averager.getAverage(), (30+40+50+60)/4d) - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.java ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.java b/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.java new file mode 100644 index 0000000..071b5c3 --- /dev/null +++ b/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingMeanEnricherTest.java @@ -0,0 +1,106 @@ +/* + * 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.policy.enricher; + +import static org.testng.Assert.assertEquals; + +import org.apache.brooklyn.api.entity.EntityLocal; +import org.apache.brooklyn.api.mgmt.SubscriptionContext; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.api.sensor.Sensor; +import org.apache.brooklyn.core.entity.AbstractApplication; +import org.apache.brooklyn.core.entity.AbstractEntity; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.sensor.BasicAttributeSensor; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class RollingMeanEnricherTest { + + AbstractApplication app; + + EntityLocal producer; + + Sensor<Integer> intSensor; + AttributeSensor<Integer> deltaSensor; + AttributeSensor<Double> avgSensor; + RollingMeanEnricher<Integer> averager; + + @BeforeMethod(alwaysRun=true) + public void before() { + app = new AbstractApplication() {}; + producer = new AbstractEntity(app) {}; + producer.setParent(app); + Entities.startManagement(app); + + intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor"); + deltaSensor = new BasicAttributeSensor<Integer>(Integer.class, "delta sensor"); + avgSensor = new BasicAttributeSensor<Double>(Double.class, "avg sensor"); + + producer.enrichers().add(new DeltaEnricher<Integer>(producer, intSensor, deltaSensor)); + averager = new RollingMeanEnricher<Integer>(producer, deltaSensor, avgSensor, 4); + producer.enrichers().add(averager); + } + + @AfterMethod(alwaysRun=true) + public void tearDown() throws Exception { + if (app != null) Entities.destroyAll(app.getManagementContext()); + } + + @Test + public void testDefaultAverage() { + assertEquals(averager.getAverage(), null); + } + + @Test + public void testZeroWindowSize() { + averager = new RollingMeanEnricher<Integer>(producer, deltaSensor, avgSensor, 0); + producer.enrichers().add(averager); + + averager.onEvent(intSensor.newEvent(producer, 10)); + assertEquals(averager.getAverage(), null); + } + + @Test + public void testSingleValueAverage() { + averager.onEvent(intSensor.newEvent(producer, 10)); + assertEquals(averager.getAverage(), 10d); + } + + @Test + public void testMultipleValueAverage() { + averager.onEvent(intSensor.newEvent(producer, 10)); + averager.onEvent(intSensor.newEvent(producer, 20)); + averager.onEvent(intSensor.newEvent(producer, 30)); + averager.onEvent(intSensor.newEvent(producer, 40)); + assertEquals(averager.getAverage(), (10+20+30+40)/4d); + } + + @Test + public void testWindowSizeCulling() { + averager.onEvent(intSensor.newEvent(producer, 10)); + averager.onEvent(intSensor.newEvent(producer, 20)); + averager.onEvent(intSensor.newEvent(producer, 30)); + averager.onEvent(intSensor.newEvent(producer, 40)); + averager.onEvent(intSensor.newEvent(producer, 50)); + averager.onEvent(intSensor.newEvent(producer, 60)); + assertEquals(averager.getAverage(), (30+40+50+60)/4d); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.groovy ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.groovy b/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.groovy deleted file mode 100644 index 492d672..0000000 --- a/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.groovy +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.policy.enricher - -import static org.testng.Assert.assertEquals - -import org.apache.brooklyn.api.entity.EntityLocal; -import org.apache.brooklyn.api.mgmt.SubscriptionContext -import org.apache.brooklyn.api.sensor.Sensor -import org.apache.brooklyn.core.entity.AbstractApplication -import org.apache.brooklyn.core.entity.AbstractEntity -import org.apache.brooklyn.core.entity.Entities -import org.apache.brooklyn.core.sensor.BasicAttributeSensor -import org.apache.brooklyn.policy.enricher.RollingTimeWindowMeanEnricher.ConfidenceQualifiedNumber -import org.testng.annotations.AfterMethod -import org.testng.annotations.BeforeMethod -import org.testng.annotations.Test - -class RollingTimeWindowMeanEnricherTest { - - AbstractApplication app - - EntityLocal producer - - Sensor<Integer> intSensor, deltaSensor - Sensor<Double> avgSensor - SubscriptionContext subscription - - RollingTimeWindowMeanEnricher<Integer> averager - ConfidenceQualifiedNumber average - - private final long timePeriod = 1000 - - @BeforeMethod - public void before() { - app = new AbstractApplication() {} - producer = new AbstractEntity(app) {} - Entities.startManagement(app); - - intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor") - deltaSensor = new BasicAttributeSensor<Integer>(Integer.class, "delta sensor") - avgSensor = new BasicAttributeSensor<Double>(Integer.class, "avg sensor") - - producer.enrichers().add(new DeltaEnricher<Integer>(producer, intSensor, deltaSensor)) - averager = new RollingTimeWindowMeanEnricher<Integer>(producer, deltaSensor, avgSensor, timePeriod) - producer.enrichers().add(averager) - } - - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (app != null) Entities.destroyAll(app.getManagementContext()); - } - - @Test - public void testDefaultAverageWhenEmpty() { - average = averager.getAverage(0) - assertEquals(average.value, 0d) - assertEquals(average.confidence, 0.0d) - } - - @Test - public void testNoRecentValuesAverage() { - averager.onEvent(intSensor.newEvent(producer, 10), 0L) - average = averager.getAverage(timePeriod+1000) - assertEquals(average.value, 10d) - assertEquals(average.confidence, 0d) - } - - @Test - public void testNoRecentValuesUsesLastForAverage() { - averager.onEvent(intSensor.newEvent(producer, 10), 0L) - averager.onEvent(intSensor.newEvent(producer, 20), 10L) - average = averager.getAverage(timePeriod+1000) - assertEquals(average.value, 20d) - assertEquals(average.confidence, 0d) - } - - @Test - public void testSingleValueTimeAverage() { - averager.onEvent(intSensor.newEvent(producer, 10), 1000) - average = averager.getAverage(1000) - assertEquals(average.confidence, 0d) - } - - @Test - public void testTwoValueAverageForPeriod() { - averager.onEvent(intSensor.newEvent(producer, 10), 1000) - averager.onEvent(intSensor.newEvent(producer, 10), 2000) - average = averager.getAverage(2000) - assertEquals(average.value, 10 /1d) - assertEquals(average.confidence, 1d) - } - - @Test - public void testMonospacedAverage() { - averager.onEvent(intSensor.newEvent(producer, 10), 1000) - averager.onEvent(intSensor.newEvent(producer, 20), 1250) - averager.onEvent(intSensor.newEvent(producer, 30), 1500) - averager.onEvent(intSensor.newEvent(producer, 40), 1750) - averager.onEvent(intSensor.newEvent(producer, 50), 2000) - average = averager.getAverage(2000) - assertEquals(average.value, (20+30+40+50)/4d) - assertEquals(average.confidence, 1d) - } - - @Test - public void testWeightedAverage() { - averager.onEvent(intSensor.newEvent(producer, 10), 1000) - averager.onEvent(intSensor.newEvent(producer, 20), 1100) - averager.onEvent(intSensor.newEvent(producer, 30), 1300) - averager.onEvent(intSensor.newEvent(producer, 40), 1600) - averager.onEvent(intSensor.newEvent(producer, 50), 2000) - average = averager.getAverage(2000) - assertEquals(average.value, (20*0.1d)+(30*0.2d)+(40*0.3d)+(50*0.4d)) - assertEquals(average.confidence, 1d) - } - - @Test - public void testConfidenceDecay() { - averager.onEvent(intSensor.newEvent(producer, 10), 1000) - averager.onEvent(intSensor.newEvent(producer, 20), 1250) - averager.onEvent(intSensor.newEvent(producer, 30), 1500) - averager.onEvent(intSensor.newEvent(producer, 40), 1750) - averager.onEvent(intSensor.newEvent(producer, 50), 2000) - - average = averager.getAverage(2250) - assertEquals(average.value, (30+40+50)/3d) - assertEquals(average.confidence, 0.75d) - average = averager.getAverage(2500) - assertEquals(average.value, (40+50)/2d) - assertEquals(average.confidence, 0.5d) - average = averager.getAverage(2750) - assertEquals(average.value, 50d) - assertEquals(average.confidence, 0.25d) - average = averager.getAverage(3000) - assertEquals(average.value, 50d) - assertEquals(average.confidence, 0d) - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.java ---------------------------------------------------------------------- diff --git a/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.java b/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.java new file mode 100644 index 0000000..162833d --- /dev/null +++ b/policy/src/test/java/org/apache/brooklyn/policy/enricher/RollingTimeWindowMeanEnricherTest.java @@ -0,0 +1,156 @@ +/* + * 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.policy.enricher; + +import static org.testng.Assert.assertEquals; + +import org.apache.brooklyn.api.entity.EntityLocal; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.api.sensor.Sensor; +import org.apache.brooklyn.core.entity.AbstractApplication; +import org.apache.brooklyn.core.entity.AbstractEntity; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.sensor.BasicAttributeSensor; +import org.apache.brooklyn.policy.enricher.RollingTimeWindowMeanEnricher.ConfidenceQualifiedNumber; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@SuppressWarnings("deprecation") +public class RollingTimeWindowMeanEnricherTest { + + AbstractApplication app; + + EntityLocal producer; + + Sensor<Integer> intSensor; + AttributeSensor<Integer> deltaSensor; + AttributeSensor<Double> avgSensor; + + RollingTimeWindowMeanEnricher<Integer> averager; + ConfidenceQualifiedNumber average; + + private final long timePeriod = 1000; + + @BeforeMethod + public void before() { + app = new AbstractApplication() {}; + producer = new AbstractEntity(app) {}; + Entities.startManagement(app); + + intSensor = new BasicAttributeSensor<Integer>(Integer.class, "int sensor"); + deltaSensor = new BasicAttributeSensor<Integer>(Integer.class, "delta sensor"); + avgSensor = new BasicAttributeSensor<Double>(Double.class, "avg sensor"); + + producer.enrichers().add(new DeltaEnricher<Integer>(producer, intSensor, deltaSensor)); + averager = new RollingTimeWindowMeanEnricher<Integer>(producer, deltaSensor, avgSensor, timePeriod); + producer.enrichers().add(averager); + } + + @AfterMethod(alwaysRun=true) + public void tearDown() throws Exception { + if (app != null) Entities.destroyAll(app.getManagementContext()); + } + + @Test + public void testDefaultAverageWhenEmpty() { + average = averager.getAverage(0); + assertEquals(average.value, 0d); + assertEquals(average.confidence, 0.0d); + } + + @Test + public void testNoRecentValuesAverage() { + averager.onEvent(intSensor.newEvent(producer, 10), 0L); + average = averager.getAverage(timePeriod+1000); + assertEquals(average.value, 10d); + assertEquals(average.confidence, 0d); + } + + @Test + public void testNoRecentValuesUsesLastForAverage() { + averager.onEvent(intSensor.newEvent(producer, 10), 0L); + averager.onEvent(intSensor.newEvent(producer, 20), 10L); + average = averager.getAverage(timePeriod+1000); + assertEquals(average.value, 20d); + assertEquals(average.confidence, 0d); + } + + @Test + public void testSingleValueTimeAverage() { + averager.onEvent(intSensor.newEvent(producer, 10), 1000); + average = averager.getAverage(1000); + assertEquals(average.confidence, 0d); + } + + @Test + public void testTwoValueAverageForPeriod() { + averager.onEvent(intSensor.newEvent(producer, 10), 1000); + averager.onEvent(intSensor.newEvent(producer, 10), 2000); + average = averager.getAverage(2000); + assertEquals(average.value, 10 /1d); + assertEquals(average.confidence, 1d); + } + + @Test + public void testMonospacedAverage() { + averager.onEvent(intSensor.newEvent(producer, 10), 1000); + averager.onEvent(intSensor.newEvent(producer, 20), 1250); + averager.onEvent(intSensor.newEvent(producer, 30), 1500); + averager.onEvent(intSensor.newEvent(producer, 40), 1750); + averager.onEvent(intSensor.newEvent(producer, 50), 2000); + average = averager.getAverage(2000); + assertEquals(average.value, (20+30+40+50)/4d); + assertEquals(average.confidence, 1d); + } + + @Test + public void testWeightedAverage() { + averager.onEvent(intSensor.newEvent(producer, 10), 1000); + averager.onEvent(intSensor.newEvent(producer, 20), 1100); + averager.onEvent(intSensor.newEvent(producer, 30), 1300); + averager.onEvent(intSensor.newEvent(producer, 40), 1600); + averager.onEvent(intSensor.newEvent(producer, 50), 2000); + average = averager.getAverage(2000); + assertEquals(average.value, (20*0.1d)+(30*0.2d)+(40*0.3d)+(50*0.4d)); + assertEquals(average.confidence, 1d); + } + + @Test + public void testConfidenceDecay() { + averager.onEvent(intSensor.newEvent(producer, 10), 1000); + averager.onEvent(intSensor.newEvent(producer, 20), 1250); + averager.onEvent(intSensor.newEvent(producer, 30), 1500); + averager.onEvent(intSensor.newEvent(producer, 40), 1750); + averager.onEvent(intSensor.newEvent(producer, 50), 2000); + + average = averager.getAverage(2250); + assertEquals(average.value, (30+40+50)/3d); + assertEquals(average.confidence, 0.75d); + average = averager.getAverage(2500); + assertEquals(average.value, (40+50)/2d); + assertEquals(average.confidence, 0.5d); + average = averager.getAverage(2750); + assertEquals(average.value, 50d); + assertEquals(average.confidence, 0.25d); + average = averager.getAverage(3000); + assertEquals(average.value, 50d); + assertEquals(average.confidence, 0d); + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.groovy ---------------------------------------------------------------------- diff --git a/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.groovy b/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.groovy deleted file mode 100644 index 4e0ce53..0000000 --- a/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.groovy +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.database - -import org.apache.brooklyn.core.config.BasicConfigKey - -/** - * Intended to represent a SQL relational database service. - * - * TODO work in progress - */ -public interface Database { - BasicConfigKey<String> SQL_VERSION = [ String, "database.sql.version", "SQL version" ] - - Collection<Schema> getSchemas(); - - void createSchema(String name, Map properties); - - void addSchema(Schema schema); - - void removeSchema(String schemaName); -} - -/** - * Intended to represent a SQL database schema. - * - * TODO work in progress - */ -public interface Schema { - BasicConfigKey<String> SCHEMA_NAME = [ String, "database.schema", "Database schema name" ] - - void create(); - - void remove(); - - String getName(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.java ---------------------------------------------------------------------- diff --git a/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.java b/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.java new file mode 100644 index 0000000..fccb760 --- /dev/null +++ b/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Database.java @@ -0,0 +1,42 @@ +/* + * 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.database; + +import java.util.Collection; +import java.util.Map; + +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; + +/** + * Intended to represent a SQL relational database service. + * + * TODO work in progress + */ +public interface Database { + ConfigKey<String> SQL_VERSION = ConfigKeys.newStringConfigKey("database.sql.version", "SQL version"); + + Collection<Schema> getSchemas(); + + void createSchema(String name, Map properties); + + void addSchema(Schema schema); + + void removeSchema(String schemaName); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Schema.java ---------------------------------------------------------------------- diff --git a/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Schema.java b/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Schema.java new file mode 100644 index 0000000..a032adc --- /dev/null +++ b/sandbox/database/src/main/java/org/apache/brooklyn/entity/database/Schema.java @@ -0,0 +1,37 @@ +/* + * 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.database; + +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; + +/** + * Intended to represent a SQL database schema. + * + * TODO work in progress + */ +public interface Schema { + ConfigKey<String> SCHEMA_NAME = ConfigKeys.newStringConfigKey("database.schema", "Database schema name"); + + void create(); + + void remove(); + + String getName(); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.groovy ---------------------------------------------------------------------- diff --git a/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.groovy b/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.groovy deleted file mode 100644 index 70d8f06..0000000 --- a/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.groovy +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.nosql.infinispan - -import static org.apache.brooklyn.test.TestUtils.* -import static java.util.concurrent.TimeUnit.* -import static org.testng.Assert.* - -import java.util.concurrent.TimeUnit - -import org.apache.brooklyn.entity.nosql.infinispan.Infinispan5Server; -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.testng.annotations.AfterMethod -import org.testng.annotations.BeforeMethod -import org.testng.annotations.Test - -import org.apache.brooklyn.api.entity.Application -import org.apache.brooklyn.core.entity.Entities -import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation -import org.apache.brooklyn.core.test.entity.TestApplicationImpl -import org.apache.brooklyn.util.groovy.TimeExtras; -import org.apache.brooklyn.util.net.Networking -import org.apache.brooklyn.util.repeat.Repeater - -class Infinispan5ServerIntegrationTest { - private static final Logger logger = LoggerFactory.getLogger(Infinispan5ServerIntegrationTest.class) - - static String DEFAULT_PROTOCOL = "memcached" - static int DEFAULT_PORT = 11219 - - static boolean portLeftOpen = false; - - static { TimeExtras.init() } - - @BeforeMethod(groups = [ "Integration" ]) - public void failIfPortInUse() { - if (isPortInUse(DEFAULT_PORT, 5000L)) { - portLeftOpen = true; - fail "someone is already listening on port $DEFAULT_PORT; tests assume that port $DEFAULT_PORT is free on localhost" - } - } - - @AfterMethod(groups = [ "Integration" ]) - public void ensureIsShutDown() { - Socket shutdownSocket = null; - SocketException gotException = null; - - boolean socketClosed = new Repeater("Checking Infinispan has shut down") - .repeat { - if (shutdownSocket) shutdownSocket.close(); - try { shutdownSocket = new Socket(Networking.localHost, DEFAULT_PORT); } - catch (SocketException e) { gotException = e; return; } - gotException = null - } - .every(100 * MILLISECONDS) - .until { gotException } - .limitIterationsTo(25) - .run(); - - if (socketClosed == false) { - logger.error "Infinispan did not shut down"; - throw new Exception("Infinispan did not shut down") - } - } - - public void ensureIsUp() { - Socket socket = new Socket(Networking.localHost, DEFAULT_PORT); - socket.close(); - } - - @Test(groups = [ "Integration", "WIP" ]) - public void testInfinispanStartsAndStops() { - Application app = new TestApplicationImpl(); - try { - final Infinispan5Server infini = new Infinispan5Server(parent:app) - infini.config().set(Infinispan5Server.PORT.getConfigKey(), DEFAULT_PORT) - infini.start([ new LocalhostMachineProvisioningLocation(name:'london') ]) - - executeUntilSucceeds { - assertTrue infini.getAttribute(Infinispan5Server.SERVICE_UP) - } - } finally { - Entities.destroy(app); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.java ---------------------------------------------------------------------- diff --git a/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.java b/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.java new file mode 100644 index 0000000..a541c7a --- /dev/null +++ b/sandbox/nosql/src/test/java/org/apache/brooklyn/entity/nosql/infinispan/Infinispan5ServerIntegrationTest.java @@ -0,0 +1,107 @@ +/* + * 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.nosql.infinispan; + +import static org.testng.Assert.fail; + +import java.io.IOException; +import java.net.Socket; +import java.net.SocketException; +import java.util.concurrent.Callable; + +import org.apache.brooklyn.api.entity.Application; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.location.PortRanges; +import org.apache.brooklyn.core.test.entity.TestApplicationImpl; +import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation; +import org.apache.brooklyn.test.EntityTestUtils; +import org.apache.brooklyn.util.groovy.TimeExtras; +import org.apache.brooklyn.util.net.Networking; +import org.apache.brooklyn.util.repeat.Repeater; +import org.apache.brooklyn.util.time.Duration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +class Infinispan5ServerIntegrationTest { + private static final Logger logger = LoggerFactory.getLogger(Infinispan5ServerIntegrationTest.class); + + static String DEFAULT_PROTOCOL = "memcached"; + static int DEFAULT_PORT = 11219; + + static boolean portLeftOpen = false; + + static { TimeExtras.init(); } + + @BeforeMethod(groups = "Integration") + public void failIfPortInUse() { + if (Networking.isPortAvailable(DEFAULT_PORT)) { + portLeftOpen = true; + fail("someone is already listening on port $DEFAULT_PORT; tests assume that port $DEFAULT_PORT is free on localhost"); + } + } + + @AfterMethod(groups = "Integration") + public void ensureIsShutDown() { + boolean socketClosed = new Repeater("Checking Infinispan has shut down") + .every(Duration.millis(100)) + .until(new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + Socket shutdownSocket = null; + + try { shutdownSocket = new Socket(Networking.getLocalHost(), DEFAULT_PORT); } + catch (SocketException e) { return true; } + shutdownSocket.close(); + + return false; + } + }) + .limitIterationsTo(25) + .run(); + + if (socketClosed == false) { + logger.error("Infinispan did not shut down"); + throw new IllegalStateException("Infinispan did not shut down"); + } + } + + public void ensureIsUp() throws IOException { + Socket socket = new Socket(Networking.getLocalHost(), DEFAULT_PORT); + socket.close(); + } + + @Test(groups = {"Integration", "WIP"}) + public void testInfinispanStartsAndStops() { + Application app = new TestApplicationImpl(); + try { + final Infinispan5Server infini = new Infinispan5Server(ImmutableMap.of("parent", app)); + infini.config().set(Infinispan5Server.PORT.getConfigKey(), PortRanges.fromInteger(DEFAULT_PORT)); + infini.start(ImmutableList.of(new LocalhostMachineProvisioningLocation(ImmutableMap.of("name","london")))); + EntityTestUtils.assertAttributeEqualsEventually(infini, Infinispan5Server.SERVICE_UP, Boolean.TRUE); + } finally { + Entities.destroy(app); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/software/webapp/pom.xml ---------------------------------------------------------------------- diff --git a/software/webapp/pom.xml b/software/webapp/pom.xml index 8e8cae3..77c327c 100644 --- a/software/webapp/pom.xml +++ b/software/webapp/pom.xml @@ -53,20 +53,6 @@ </plugin> </plugins> </pluginManagement> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <inherited>true</inherited> - <executions> - <execution> - <id>default-testCompile</id> - <configuration> - <compilerId>groovy-eclipse-compiler</compilerId> - </configuration> - </execution> - </executions> - </plugin> - </plugins> </build> <dependencies> @@ -113,10 +99,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy ---------------------------------------------------------------------- diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy deleted file mode 100644 index 4706654..0000000 --- a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.webapp - -import static java.util.concurrent.TimeUnit.* -import static org.testng.Assert.* - -import org.apache.brooklyn.api.entity.Application -import org.apache.brooklyn.api.location.Location -import org.apache.brooklyn.core.entity.Entities -import org.apache.brooklyn.core.entity.trait.Startable -import org.apache.brooklyn.core.location.BasicLocationRegistry -import org.apache.brooklyn.core.internal.BrooklynProperties -import org.apache.brooklyn.core.test.entity.TestApplicationImpl -import org.apache.brooklyn.entity.software.base.SoftwareProcess -import org.apache.brooklyn.entity.webapp.jboss.JBoss6Server -import org.apache.brooklyn.entity.webapp.jboss.JBoss6ServerImpl -import org.apache.brooklyn.entity.webapp.jboss.JBoss7Server -import org.apache.brooklyn.entity.webapp.jboss.JBoss7ServerImpl -import org.apache.brooklyn.entity.webapp.tomcat.TomcatServer -import org.apache.brooklyn.entity.webapp.tomcat.TomcatServerImpl -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.testng.annotations.AfterMethod -import org.testng.annotations.BeforeMethod -import org.testng.annotations.DataProvider -import org.testng.annotations.Test - -/** - * This tests that we can run jboss entity on AWS. - */ -public class WebAppLiveIntegrationTest { - private static final Logger logger = LoggerFactory.getLogger(WebAppLiveIntegrationTest.class) - - public static final int DEFAULT_HTTP_PORT = 8080 - public static final int DEFAULT_JMX_PORT = 32199 - - // Port increment for JBoss 6. - public static final int PORT_INCREMENT = 400 - - // The parent application entity for these tests - Application application = new TestApplicationImpl() - - Location loc - - /** - * Provides instances of {@link TomcatServer}, {@link JBoss6Server} and {@link JBoss7Server} to the tests below. - * - * TODO combine the data provider here with the integration tests - * - * @see WebAppIntegrationTest#basicEntities() - */ - @DataProvider(name = "basicEntities") - public Object[][] basicEntities() { - TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) - JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT) - JBoss7Server jboss7 = new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) - return [ [ tomcat ], [ jboss6 ], [ jboss7 ] ] - } - - @BeforeMethod(alwaysRun = true) - public void setUp() { - Entities.manage(application) - - BrooklynProperties props = BrooklynProperties.Factory.newDefault() - props.put("brooklyn.location.jclouds.aws-ec2.imagel-id", "us-east-1/ami-2342a94a") - props.put("brooklyn.location.jclouds.aws-ec2.image-owner", "411009282317") - - loc = new BasicLocationRegistry(props).resolve("aws-ec2:us-east-1") - } - - @AfterMethod(alwaysRun = true) - public void shutdown() { - if (application != null) Entities.destroyAll(application.getManagementContext()); - } - - @Test(groups = "Live", dataProvider="basicEntities") - public void testStartsWebAppInAws(final SoftwareProcess entity) { - entity.start([ loc ]) - executeUntilSucceedsWithShutdown(entity, abortOnError:false, timeout:75*SECONDS, useGroovyTruth:true) { - assertTrue(entity.getAttribute(Startable.SERVICE_UP)) - true - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.java new file mode 100644 index 0000000..cfc33a9 --- /dev/null +++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.java @@ -0,0 +1,91 @@ +/* + * 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.webapp; + +import org.apache.brooklyn.api.entity.EntitySpec; +import org.apache.brooklyn.api.location.Location; +import org.apache.brooklyn.api.location.PortRange; +import org.apache.brooklyn.core.entity.Attributes; +import org.apache.brooklyn.core.location.PortRanges; +import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; +import org.apache.brooklyn.entity.webapp.jboss.JBoss6Server; +import org.apache.brooklyn.entity.webapp.jboss.JBoss6ServerImpl; +import org.apache.brooklyn.entity.webapp.jboss.JBoss7Server; +import org.apache.brooklyn.entity.webapp.jboss.JBoss7ServerImpl; +import org.apache.brooklyn.entity.webapp.tomcat.TomcatServer; +import org.apache.brooklyn.test.EntityTestUtils; +import org.apache.brooklyn.util.time.Duration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +/** + * This tests that we can run jboss entity on AWS. + */ +public class WebAppLiveIntegrationTest extends BrooklynAppUnitTestSupport { + public static final PortRange DEFAULT_HTTP_PORT = PortRanges.fromInteger(8080); + public static final PortRange DEFAULT_JMX_PORT = PortRanges.fromInteger(32199); + + // Port increment for JBoss 6. + public static final int PORT_INCREMENT = 400; + + // The parent application entity for these tests + Location loc; + + /** + * Provides instances of {@link TomcatServer}, {@link JBoss6Server} and {@link JBoss7Server} to the tests below. + * + * TODO combine the data provider here with the integration tests + * + * @see WebAppIntegrationTest#basicEntities() + */ + @DataProvider(name = "basicEntities") + public Object[][] basicEntities() { + return new Object[][] { + { EntitySpec.create(TomcatServer.class) + .configure(TomcatServer.HTTP_PORT, DEFAULT_HTTP_PORT) + .configure(TomcatServer.JMX_PORT, DEFAULT_JMX_PORT) }, + { EntitySpec.create(JBoss6ServerImpl.class) + .configure(JBoss6Server.PORT_INCREMENT, PORT_INCREMENT) + .configure(JBoss6Server.JMX_PORT, DEFAULT_JMX_PORT) }, + { EntitySpec.create(JBoss7ServerImpl.class) + .configure(JBoss7Server.PORT_INCREMENT, PORT_INCREMENT) } }; + } + + @Override + @BeforeMethod(alwaysRun = true) + public void setUp() { + loc = mgmt.getLocationRegistry().resolve("aws-ec2:us-east-1", ImmutableMap.of( + "imagel-id", "us-east-1/ami-2342a94a", + "image-owner", "411009282317")); + } + + @Test(groups = "Live", dataProvider="basicEntities") + public void testStartsWebAppInAws(final EntitySpec<JavaWebAppSoftwareProcess> spec) { + JavaWebAppSoftwareProcess server = app.createAndManageChild(spec); + server.start(ImmutableList.of(loc)); + EntityTestUtils.assertAttributeEqualsEventually(ImmutableMap.of("timeout", Duration.seconds(75)), + server, Attributes.SERVICE_UP, Boolean.TRUE); + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f69ade37/usage/cli/pom.xml ---------------------------------------------------------------------- diff --git a/usage/cli/pom.xml b/usage/cli/pom.xml index 507a377..dbc5d44 100644 --- a/usage/cli/pom.xml +++ b/usage/cli/pom.xml @@ -121,18 +121,6 @@ </instructions> </configuration> </plugin> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <inherited>true</inherited> - <executions> - <execution> - <id>default-testCompile</id> - <configuration> - <compilerId>groovy-eclipse-compiler</compilerId> - </configuration> - </execution> - </executions> - </plugin> <plugin> <!-- we publish the BOM in case anyone wants to access it directly.
