You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/05 21:41:27 UTC
[2/5] git commit: SLIDER-603 : NPE in AppsThroughAgentIT
SLIDER-603 : NPE in AppsThroughAgentIT
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/ecca0aad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/ecca0aad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/ecca0aad
Branch: refs/heads/releases/slider-0.52
Commit: ecca0aad72b7b4901bde60a2a24532b3ad4ca5b6
Parents: 7fb01c3
Author: Steve Loughran <st...@apache.org>
Authored: Sun Nov 2 20:59:42 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Sun Nov 2 20:59:42 2014 +0000
----------------------------------------------------------------------
.../apache/slider/test/SliderTestUtils.groovy | 12 ++++++
.../apache/slider/test/TestAssertions.groovy | 41 ++++++++++++++++++++
.../funtest/framework/CommandTestBase.groovy | 10 -----
3 files changed, 53 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/ecca0aad/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 2af0a2f..1b32471 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -475,6 +475,18 @@ class SliderTestUtils extends Assert {
assert 0 == service.serviceExitCode;
}
+ public static void assertContainersLive(ClusterDescription clusterDescription,
+ String component, int expected) {
+ log.info("Asserting component $component expected count $expected}",)
+ def instances = clusterDescription?.instances?.get(component)
+ int actual = instances != null ? instances.size() : 0
+ if (expected != actual) {
+ log.warn(
+ "$component actual=$actual, expected $expected in \n$clusterDescription")
+ }
+ assert expected == actual
+ }
+
/**
* Execute a closure, assert it fails with a given exit code and text
* @param exitCode exit code
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/ecca0aad/slider-core/src/test/groovy/org/apache/slider/test/TestAssertions.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/TestAssertions.groovy b/slider-core/src/test/groovy/org/apache/slider/test/TestAssertions.groovy
new file mode 100644
index 0000000..abfbe65
--- /dev/null
+++ b/slider-core/src/test/groovy/org/apache/slider/test/TestAssertions.groovy
@@ -0,0 +1,41 @@
+/*
+ * 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.slider.test
+
+import org.apache.slider.api.ClusterDescription
+import org.junit.Test
+
+/**
+ * Test for some of the command test base operations
+ */
+class TestAssertions {
+ @Test
+ public void testNoInstances() throws Throwable {
+ ClusterDescription clusterDescription = new ClusterDescription();
+ clusterDescription.instances = null
+ SliderTestUtils.assertContainersLive(clusterDescription, "example", 0);
+ }
+
+ @Test
+ public void testEmptyInstances() throws Throwable {
+ ClusterDescription clusterDescription = new ClusterDescription();
+ SliderTestUtils.assertContainersLive(clusterDescription, "example", 0);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/ecca0aad/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
index 9a1824d..f14e9f1 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
@@ -176,16 +176,6 @@ abstract class CommandTestBase extends SliderTestUtils {
"and YARN RM @ ${SLIDER_CONFIG.get(YarnConfiguration.RM_ADDRESS)}")
}
- public static void assertContainersLive(ClusterDescription clusterDescription,
- String component, int count) {
- log.info("Asserting component count.")
- int instanceCount = clusterDescription.instances[component].size()
- if (count != instanceCount) {
- log.warn(clusterDescription.toString())
- }
- assert count == instanceCount
- }
-
public static void logShell(SliderShell shell) {
shell.dumpOutput();
}