[6/8] brooklyn-server git commit: TestSensor: support abortConditions
TestSensor: support abortConditions Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3e1171f7 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3e1171f7 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3e1171f7 Branch: refs/heads/master Commit: 3e1171f7f8023da97d041d0f5dd5953182430a31 Parents: 967c2f0 Author: Aled SageAuthored: Tue Jul 26 22:16:30 2016 +0100 Committer: Aled Sage Committed: Mon Aug 8 14:48:25 2016 +0100 -- .../brooklyn/test/framework/AbortError.java | 31 .../test/framework/TestFrameworkAssertions.java | 155 --- ...leShellCommandDeprecatedIntegrationTest.java | 13 +- .../framework/TestFrameworkAssertionsTest.java | 54 ++- .../brooklyn/test/framework/TestSensorTest.java | 128 +-- .../brooklyn/util/exceptions/Exceptions.java| 24 +++ .../apache/brooklyn/util/repeat/Repeater.java | 20 ++- 7 files changed, 368 insertions(+), 57 deletions(-) -- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3e1171f7/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbortError.java -- diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbortError.java b/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbortError.java new file mode 100644 index 000..dd82d01 --- /dev/null +++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbortError.java @@ -0,0 +1,31 @@ +/* + * 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.test.framework; + +public class AbortError extends Error { +private static final long serialVersionUID = -2922419711728467414L; + +public AbortError(String msg) { +super(msg); +} + +public AbortError(String msg, Throwable cause) { +super(msg, cause); +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3e1171f7/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestFrameworkAssertions.java -- diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestFrameworkAssertions.java b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestFrameworkAssertions.java index 0227bf1..e1ed825 100644 --- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestFrameworkAssertions.java +++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestFrameworkAssertions.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.concurrent.Callable; import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.config.ConfigKey; @@ -32,14 +33,17 @@ import org.apache.brooklyn.util.core.flags.TypeCoercions; import org.apache.brooklyn.util.exceptions.CompoundRuntimeException; import org.apache.brooklyn.util.exceptions.Exceptions; import org.apache.brooklyn.util.exceptions.FatalConfigurationRuntimeException; +import org.apache.brooklyn.util.exceptions.RuntimeInterruptedException; import org.apache.brooklyn.util.guava.Maybe; +import org.apache.brooklyn.util.repeat.Repeater; import org.apache.brooklyn.util.text.Strings; import org.apache.brooklyn.util.time.Duration; import com.google.common.base.Joiner; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.reflect.TypeToken; @@ -62,9 +66,9 @@ public class TestFrameworkAssertions { public static final String UNKNOWN_CONDITION = "unknown condition"; public static class AssertionOptions { -protected Map flags; -protected
[8/8] brooklyn-server git commit: This closes #277
This closes #277 Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/1a878964 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/1a878964 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/1a878964 Branch: refs/heads/master Commit: 1a87896410b7b7c5c79e23d965c42df0464c209f Parents: da14297 3d5833d Author: Aled SageAuthored: Tue Aug 9 20:44:10 2016 +0100 Committer: Aled Sage Committed: Tue Aug 9 20:44:10 2016 +0100 -- ...ntoPersisterInMemorySizeIntegrationTest.java | 42 ++- ...essPersisterInMemorySizeIntegrationTest.java | 5 +- .../brooklyn/test/framework/AbortError.java | 31 ++ .../LoopOverGroupMembersTestCaseImpl.java | 18 +- .../framework/RelativeEntityTestCaseImpl.java | 11 +- .../framework/TargetableTestComponentImpl.java | 21 +- .../test/framework/TestEffectorImpl.java| 60 ++-- .../framework/TestEndpointReachableImpl.java| 9 +- .../test/framework/TestFrameworkAssertions.java | 302 ++ .../test/framework/TestHttpCallImpl.java| 53 ++-- .../brooklyn/test/framework/TestSensor.java | 10 + .../brooklyn/test/framework/TestSensorImpl.java | 61 ++-- .../test/framework/TestSshCommandImpl.java | 5 - ...leShellCommandDeprecatedIntegrationTest.java | 13 +- .../test/framework/TestEffectorTest.java| 154 ++--- .../framework/TestFrameworkAssertionsTest.java | 64 +++- .../brooklyn/test/framework/TestSensorTest.java | 312 --- .../test/framework/entity/TestEntity.java | 6 + .../test/framework/entity/TestEntityImpl.java | 12 + .../brooklyn/util/exceptions/Exceptions.java| 24 ++ .../apache/brooklyn/util/repeat/Repeater.java | 20 +- 21 files changed, 879 insertions(+), 354 deletions(-) -- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1a878964/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java --
[7/8] brooklyn-server git commit: Code tidy for test BrooklynMementoPersisterInMemorySize
Code tidy for test BrooklynMementoPersisterInMemorySize And increase persistPeriod to decrease risk of failure on jenkins Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3d5833d1 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3d5833d1 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3d5833d1 Branch: refs/heads/master Commit: 3d5833d17c2ca8033b9e794817dd0a8b73dbd33c Parents: 3e1171f Author: Aled SageAuthored: Tue Aug 9 18:15:56 2016 +0100 Committer: Aled Sage Committed: Tue Aug 9 18:18:45 2016 +0100 -- ...ntoPersisterInMemorySizeIntegrationTest.java | 42 ++-- ...essPersisterInMemorySizeIntegrationTest.java | 5 +-- 2 files changed, 31 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3d5833d1/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java -- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java index fff4cf6..873370e 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java @@ -18,9 +18,6 @@ */ package org.apache.brooklyn.core.mgmt.persist; -import java.io.IOException; -import java.util.concurrent.TimeoutException; - import org.apache.brooklyn.api.mgmt.ManagementContext; import org.apache.brooklyn.core.entity.EntityInternal; import org.apache.brooklyn.core.mgmt.persist.ListeningObjectStore.RecordingTransactionListener; @@ -29,6 +26,8 @@ import org.apache.brooklyn.core.test.entity.TestEntity; import org.apache.brooklyn.util.text.Identifiers; import org.apache.brooklyn.util.time.Duration; import org.apache.brooklyn.util.time.Time; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.Test; @@ -36,6 +35,16 @@ import org.testng.annotations.Test; @Test public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends BrooklynMementoPersisterTestFixture { +// TODO If you decrease persistPeriod to 1ms (from 100ms) then +// SoftwareProcessPersisterInMemorySizeIntegrationTest.testPersistenceVolumeFastNoTrigger +// will fail: "Phase one recorded 234239 bytes, 123 files". +// It fails non-deterministically on Apache Jenkins (with 100ms persistPeriod) because that +// machine can be very slow sometimes. +// Increased persistPeriod to 250ms to improve chances of it working on jenkins, but really we +// need to revisit how this test is written! + +private static final Logger LOG = LoggerFactory.getLogger(BrooklynMementoPersisterInMemorySizeIntegrationTest.class); + protected static int pass1MaxFiles = 30; protected static int pass1MaxKb = 30; protected static int pass2MaxFiles = 40; @@ -48,36 +57,43 @@ public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends Brookly recorder = new RecordingTransactionListener("in-mem-test-"+Identifiers.makeRandomId(4)); return RebindTestUtils.managementContextBuilder(classLoader, new ListeningObjectStore(new InMemoryObjectStore(), recorder)) -.persistPeriod(Duration.millis(100)).buildStarted(); +.persistPeriod(Duration.millis(250)).buildStarted(); } -public void testPersistenceVolumeFast() throws IOException, TimeoutException, InterruptedException { +@Test +public void testPersistenceVolumeFast() throws Exception { doTestPersistenceVolume(false, true); } + @Test(groups="Integration",invocationCount=20) -public void testPersistenceVolumeFastManyTimes() throws IOException, TimeoutException, InterruptedException { +public void testPersistenceVolumeFastManyTimes() throws Exception { doTestPersistenceVolume(false, true); } + @Test(groups="Integration") -public void testPersistenceVolumeWaiting() throws IOException, TimeoutException, InterruptedException { +public void testPersistenceVolumeWaiting() throws Exception { // by waiting we ensure there aren't extra writes going on doTestPersistenceVolume(true, true); } -public void testPersistenceVolumeFastNoTrigger() throws IOException, TimeoutException, InterruptedException { + +@Test +public void
[1/3] brooklyn-server git commit: Add Exceptions.propagateIfInterrupt
Repository: brooklyn-server Updated Branches: refs/heads/master ddb6acc92 -> da14297bb Add Exceptions.propagateIfInterrupt Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/9f2f17f9 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/9f2f17f9 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/9f2f17f9 Branch: refs/heads/master Commit: 9f2f17f9c3fad19506341aa6b4e486b7f88eeb03 Parents: e1c310f Author: Aled SageAuthored: Tue Aug 2 18:53:17 2016 +0100 Committer: Aled Sage Committed: Thu Aug 4 09:10:47 2016 +0100 -- .../brooklyn/util/exceptions/Exceptions.java| 23 .../util/exceptions/ExceptionsTest.java | 39 2 files changed, 55 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9f2f17f9/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java -- diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java index 2997f49..c517eed 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java +++ b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java @@ -164,20 +164,29 @@ public class Exceptions { } throw new PropagatedRuntimeException(msg, throwable); } - + /** - * Propagate exceptions which are fatal. - * - * Propagates only those exceptions which one rarely (if ever) wants to capture, - * such as {@link InterruptedException} and {@link Error}s. + * Propagate exceptions which are interrupts (be it {@link InterruptedException} + * or {@link RuntimeInterruptedException}. */ -public static void propagateIfFatal(Throwable throwable) { +public static void propagateIfInterrupt(Throwable throwable) { if (throwable instanceof InterruptedException) { throw new RuntimeInterruptedException((InterruptedException) throwable); } else if (throwable instanceof RuntimeInterruptedException) { Thread.currentThread().interrupt(); throw (RuntimeInterruptedException) throwable; -} else if (throwable instanceof Error) { +} +} + +/** + * Propagate exceptions which are fatal. + * + * Propagates only those exceptions which one rarely (if ever) wants to capture, + * such as {@link InterruptedException} and {@link Error}s. + */ +public static void propagateIfFatal(Throwable throwable) { +propagateIfInterrupt(throwable); +if (throwable instanceof Error) { throw (Error) throwable; } } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9f2f17f9/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java -- diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java b/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java index d5dcd04..65b5d91 100644 --- a/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java +++ b/utils/common/src/test/java/org/apache/brooklyn/util/exceptions/ExceptionsTest.java @@ -127,6 +127,45 @@ public class ExceptionsTest { Throwable t = new Throwable(); Exceptions.propagateIfFatal(t); } + +@Test +public void testPropagateIfInterruptPropagatesInterruptedException() throws Exception { +InterruptedException tothrow = new InterruptedException("simulated"); +try { +Exceptions.propagateIfInterrupt(tothrow); +fail(); +} catch (RuntimeException e) { +assertTrue(Thread.interrupted()); // note this clears the interrupted flag as well +assertEquals(e.getCause(), tothrow); +} +} + +@Test +public void testPropagateIfInterruptPropagatesRuntimeInterruptedException() throws Exception { +RuntimeInterruptedException tothrow = new RuntimeInterruptedException(new InterruptedException("simulated")); +try { +Exceptions.propagateIfInterrupt(tothrow); +fail(); +} catch (RuntimeInterruptedException e) { +assertTrue(Thread.interrupted()); // note this clears the interrupted flag as well +assertEquals(e, tothrow); +} +} + +@Test +public void testPropagateIfInterruptDoesNotPropagateOtherExceptions() throws Exception { +Exception e = new
[3/3] brooklyn-server git commit: This closes #284
This closes #284 Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/da14297b Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/da14297b Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/da14297b Branch: refs/heads/master Commit: da14297bb41cc9591f59bd625c2dab4bc999284e Parents: ddb6acc 19b55ce Author: Aled SageAuthored: Tue Aug 9 11:10:38 2016 +0100 Committer: Aled Sage Committed: Tue Aug 9 11:10:38 2016 +0100 -- .../core/effector/EffectorBasicTest.java| 4 +- .../core/entity/trait/FailingEntityImpl.java| 2 +- .../brooklyn/test/framework/TestCase.java | 14 ++ .../brooklyn/test/framework/TestCaseImpl.java | 30 +++- .../brooklyn/test/framework/TestCaseTest.java | 169 +++ .../brooklyn/util/exceptions/Exceptions.java| 23 ++- .../util/exceptions/ExceptionsTest.java | 39 + 7 files changed, 266 insertions(+), 15 deletions(-) --