You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by sm...@apache.org on 2014/06/18 05:42:12 UTC

[2/2] git commit: SLIDER-141. Functional test fails with [Permission denied] on cluster - additional test fixes

SLIDER-141. Functional test fails with [Permission denied] on cluster - additional test fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/1bbeebed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/1bbeebed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/1bbeebed

Branch: refs/heads/develop
Commit: 1bbeebedb891eda043f17b1c997b630770d52067
Parents: 716cdeb
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Tue Jun 17 19:23:26 2014 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Tue Jun 17 19:23:26 2014 -0700

----------------------------------------------------------------------
 .../test_command_log/resources_no_role.json     | 15 ++++
 slider-funtest/pom.xml                          |  4 +
 .../funtest/framework/CommandTestBase.groovy    |  1 +
 .../funtest/framework/FuntestProperties.groovy  |  5 ++
 .../lifecycle/TestAgentClusterLifecycle.groovy  | 84 +++++++++++---------
 .../lifecycle/TestAppsThroughAgent.groovy       | 53 ++++++------
 6 files changed, 96 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1bbeebed/slider-core/src/test/app_packages/test_command_log/resources_no_role.json
----------------------------------------------------------------------
diff --git a/slider-core/src/test/app_packages/test_command_log/resources_no_role.json b/slider-core/src/test/app_packages/test_command_log/resources_no_role.json
new file mode 100644
index 0000000..7913fe2
--- /dev/null
+++ b/slider-core/src/test/app_packages/test_command_log/resources_no_role.json
@@ -0,0 +1,15 @@
+{
+    "schema": "http://example.org/specification/v2.0.0",
+    "metadata": {
+    },
+    "global": {
+    },
+    "components": {
+        "COMMAND_LOGGER": {
+            "yarn.role.priority": "1",
+            "yarn.component.instances": "0"
+        },
+        "slider-appmaster": {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1bbeebed/slider-funtest/pom.xml
----------------------------------------------------------------------
diff --git a/slider-funtest/pom.xml b/slider-funtest/pom.xml
index e56b19d..a2231d5 100644
--- a/slider-funtest/pom.xml
+++ b/slider-funtest/pom.xml
@@ -27,6 +27,9 @@
     <artifactId>slider</artifactId>
     <version>0.31.0-incubating-SNAPSHOT</version>
   </parent>
+  <properties>
+    <slider.disable.cleanup>false</slider.disable.cleanup>
+  </properties>
 
   <build>
 
@@ -112,6 +115,7 @@
             <java.security.krb5.kdc>${slider.test.java.security.krb5.kdc}</java.security.krb5.kdc>
             <!-- this property must be supplied-->
             <slider.conf.dir>${slider.conf.dir}</slider.conf.dir>
+            <slider.disable.cleanup>${slider.disable.cleanup}</slider.disable.cleanup>
             <slider.bin.dir>../slider-assembly/target/slider-${project.version}-all/slider-${project.version}</slider.bin.dir>
           </systemPropertyVariables>
           <includes>

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1bbeebed/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 d2accbb..b95972a 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
@@ -51,6 +51,7 @@ abstract class CommandTestBase extends SliderTestUtils {
 
   public static final String SLIDER_CONF_DIR = sysprop(SLIDER_CONF_DIR_PROP)
   public static final String SLIDER_BIN_DIR = sysprop(SLIDER_BIN_DIR_PROP)
+  public static final String DISABLE_CLEAN_UP = sysprop(DISABLE_CLEAN_UP_PROP)
   public static final File SLIDER_BIN_DIRECTORY = new File(
       SLIDER_BIN_DIR).canonicalFile
   public static final File SLIDER_SCRIPT = new File(

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1bbeebed/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/FuntestProperties.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/FuntestProperties.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/FuntestProperties.groovy
index 8cbc098..a6772b4 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/FuntestProperties.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/FuntestProperties.groovy
@@ -37,6 +37,11 @@ public interface FuntestProperties extends SliderXMLConfKeysForTesting {
    */
   String SLIDER_BIN_DIR_PROP = "slider.bin.dir"
 
+  /**
+   * Maven Property to disable test cleanup
+   */
+  String DISABLE_CLEAN_UP_PROP = "slider.disable.cleanup"
+
   String KEY_SLIDER_TEST_NUM_WORKERS = "slider.test.cluster.size"
   int DEFAULT_SLIDER_NUM_WORKERS = 1
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1bbeebed/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAgentClusterLifecycle.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAgentClusterLifecycle.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAgentClusterLifecycle.groovy
index 7769ce1..0ac164f 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAgentClusterLifecycle.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAgentClusterLifecycle.groovy
@@ -28,6 +28,7 @@ import org.apache.slider.common.SliderXmlConfKeys
 import org.apache.slider.common.params.Arguments
 import org.apache.slider.common.params.SliderActions
 import org.apache.slider.funtest.framework.FuntestProperties
+import org.apache.slider.funtest.framework.SliderShell
 import org.junit.After
 import org.junit.Before
 import org.junit.Test
@@ -35,11 +36,13 @@ import org.junit.Test
 @CompileStatic
 @Slf4j
 public class TestAgentClusterLifecycle extends AgentCommandTestBase
-    implements FuntestProperties, Arguments, SliderExitCodes {
+implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
 
 
   static String CLUSTER = "test_agent_cluster_lifecycle"
 
+  static String APP_RESOURCE2 = "../slider-core/src/test/app_packages/test_command_log/resources_no_role.json"
+
 
   @Before
   public void prepareCluster() {
@@ -48,7 +51,11 @@ public class TestAgentClusterLifecycle extends AgentCommandTestBase
 
   @After
   public void destroyCluster() {
-    teardown(CLUSTER)
+    if (DISABLE_CLEAN_UP == null || !DISABLE_CLEAN_UP.equals("true")) {
+      teardown(CLUSTER)
+    } else {
+      log.info "Disabling cleanup for debugging purposes."
+    }
   }
 
   @Test
@@ -60,26 +67,25 @@ public class TestAgentClusterLifecycle extends AgentCommandTestBase
     def clusterpath = buildClusterPath(CLUSTER)
     assert !clusterFS.exists(clusterpath)
 
-/*
+    SliderShell shell = slider(EXIT_SUCCESS,
+        [
+            ACTION_CREATE, CLUSTER,
+            ARG_IMAGE, agentTarballPath.toString(),
+            ARG_TEMPLATE, APP_TEMPLATE,
+            ARG_RESOURCES, APP_RESOURCE2
+        ])
 
-    Map<String, Integer> roleMap = createHBaseCluster(CLUSTER,
-                                         0,
-                                         0,
-                                         [],
-                                         [:])
-    
-*/
+    logShell(shell)
 
     //at this point the cluster should exist.
-    assertPathExists(clusterFS,"Cluster parent directory does not exist", clusterpath.parent)
-    
-    assertPathExists(clusterFS,"Cluster directory does not exist", clusterpath)
+    assertPathExists(clusterFS, "Cluster parent directory does not exist", clusterpath.parent)
+
+    assertPathExists(clusterFS, "Cluster directory does not exist", clusterpath)
 
     // assert it exists on the command line
     exists(0, CLUSTER)
 
     //destroy will fail in use
-
     destroy(EXIT_APPLICATION_IN_USE, CLUSTER)
 
     //thaw will fail as cluster is in use
@@ -98,10 +104,10 @@ public class TestAgentClusterLifecycle extends AgentCommandTestBase
     File jsonStatus = File.createTempFile("tempfile", ".json")
     try {
       slider(0,
-           [
-               SliderActions.ACTION_STATUS, CLUSTER,
-               ARG_OUTPUT, jsonStatus.canonicalPath
-           ])
+          [
+              SliderActions.ACTION_STATUS, CLUSTER,
+              ARG_OUTPUT, jsonStatus.canonicalPath
+          ])
 
       assert jsonStatus.exists()
       ClusterDescription cd = ClusterDescription.fromFile(jsonStatus)
@@ -122,22 +128,23 @@ public class TestAgentClusterLifecycle extends AgentCommandTestBase
       //freeze
       freeze(CLUSTER, [
           ARG_WAIT, Integer.toString(FREEZE_WAIT_TIME),
-          ARG_MESSAGE, "freeze-in-test cluster lifecycle"
+          ARG_MESSAGE, "freeze-in-test-cluster-lifecycle"
       ])
+      describe " >>> Cluster is now frozen."
 
       //cluster exists if you don't want it to be live
       exists(0, CLUSTER, false)
-      // condition returns false if it is required to be live
+      //condition returns false if it is required to be live
       exists(EXIT_FALSE, CLUSTER, true)
 
-
-      // thaw then freeze the cluster
-
+      //thaw then freeze the cluster
       thaw(CLUSTER,
-           [
-               ARG_WAIT, Integer.toString(THAW_WAIT_TIME),
-           ])
+          [
+              ARG_WAIT, Integer.toString(THAW_WAIT_TIME),
+          ])
       exists(0, CLUSTER)
+      describe " >>> Cluster is now thawed."
+
       freeze(CLUSTER,
           [
               ARG_FORCE,
@@ -145,23 +152,28 @@ public class TestAgentClusterLifecycle extends AgentCommandTestBase
               ARG_MESSAGE, "forced-freeze-in-test"
           ])
 
+      describe " >>> Cluster is now frozen - 2nd time."
+
       //cluster is no longer live
       exists(0, CLUSTER, false)
-      
-      // condition returns false if it is required to be live
-      exists(EXIT_FALSE, CLUSTER, true)
 
-      // thaw with a restart count set to enable restart
+      //condition returns false if it is required to be live
+      exists(EXIT_FALSE, CLUSTER, true)
 
+      //thaw with a restart count set to enable restart
       describe "the kill/restart phase may fail if yarn.resourcemanager.am.max-attempts is too low"
       thaw(CLUSTER,
-           [
-               ARG_WAIT, Integer.toString(THAW_WAIT_TIME),
-               ARG_DEFINE, SliderXmlConfKeys.KEY_AM_RESTART_LIMIT + "=3"
-           ])
+          [
+              ARG_WAIT, Integer.toString(THAW_WAIT_TIME),
+              ARG_DEFINE, SliderXmlConfKeys.KEY_AM_RESTART_LIMIT + "=3"
+          ])
+
+      describe " >>> Cluster is now thawed - 2nd time."
 
       ClusterDescription status = killAmAndWaitForRestart(sliderClient, CLUSTER)
 
+      describe " >>> Kill AM and wait for restart."
+
       def restarted = status.getInfo(
           StatusKeys.INFO_CONTAINERS_AM_RESTART)
       assert restarted != null
@@ -176,9 +188,5 @@ public class TestAgentClusterLifecycle extends AgentCommandTestBase
     } finally {
       jsonStatus.delete()
     }
-
-
   }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/1bbeebed/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
index c56056c..ed88f20 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/TestAppsThroughAgent.groovy
@@ -25,6 +25,7 @@ import org.apache.slider.common.params.Arguments
 import org.apache.slider.common.params.SliderActions
 import org.apache.slider.funtest.framework.FuntestProperties
 import org.apache.slider.funtest.framework.SliderShell
+import org.junit.After
 import org.junit.Test
 
 @CompileStatic
@@ -35,10 +36,13 @@ public class TestAppsThroughAgent extends AgentCommandTestBase
   private static String COMMAND_LOGGER = "COMMAND_LOGGER"
   private static String APPLICATION_NAME = "agenttst"
 
-  @Test
-  public void testUsage() throws Throwable {
-    SliderShell shell = slider(EXIT_SUCCESS, [ACTION_USAGE])
-    assertSuccess(shell)
+  @After
+  public void destroyCluster() {
+    if (DISABLE_CLEAN_UP == null || !DISABLE_CLEAN_UP.equals("true")) {
+      cleanup()
+    } else {
+      log.info "Disabling cleanup for debugging purposes."
+    }
   }
 
   @Test
@@ -52,11 +56,11 @@ public class TestAppsThroughAgent extends AgentCommandTestBase
     try {
       SliderShell shell = slider(EXIT_SUCCESS,
           [
-          ACTION_CREATE, APPLICATION_NAME,
-          ARG_IMAGE, agentTarballPath.toString(),
-          ARG_TEMPLATE, APP_TEMPLATE,
-          ARG_RESOURCES, APP_RESOURCE
-      ])
+              ACTION_CREATE, APPLICATION_NAME,
+              ARG_IMAGE, agentTarballPath.toString(),
+              ARG_TEMPLATE, APP_TEMPLATE,
+              ARG_RESOURCES, APP_RESOURCE
+          ])
 
       logShell(shell)
 
@@ -79,26 +83,26 @@ public class TestAppsThroughAgent extends AgentCommandTestBase
       //flex
       slider(EXIT_SUCCESS,
           [
-          ACTION_FLEX,
-          APPLICATION_NAME,
-          ARG_COMPONENT,
-          COMMAND_LOGGER,
-          "2"])
+              ACTION_FLEX,
+              APPLICATION_NAME,
+              ARG_COMPONENT,
+              COMMAND_LOGGER,
+              "2"])
 
       // sleep till the new instance starts
       sleep(1000 * 10)
 
       shell = slider(EXIT_SUCCESS,
           [
-          ACTION_STATUS,
-          APPLICATION_NAME])
+              ACTION_STATUS,
+              APPLICATION_NAME])
 
       assertComponentCount(COMMAND_LOGGER, 2, shell)
 
       shell = slider(EXIT_SUCCESS,
           [
-          ACTION_LIST,
-          APPLICATION_NAME])
+              ACTION_LIST,
+              APPLICATION_NAME])
 
       assert isAppRunning("RUNNING", shell), 'App is not running.'
 
@@ -111,19 +115,12 @@ public class TestAppsThroughAgent extends AgentCommandTestBase
 
   public void cleanup() throws Throwable {
     log.info "Cleaning app instance, if exists, by name " + APPLICATION_NAME
-    SliderShell shell = slider([
-        ACTION_FREEZE,
-        APPLICATION_NAME])
-
-    if (shell.ret != 0 && shell.ret != EXIT_UNKNOWN_INSTANCE) {
-      logShell(shell)
-      assert fail("Old cluster either should not exist or should get frozen.")
-    }
+    teardown(APPLICATION_NAME)
 
     // sleep till the instance is frozen
-    sleep(1000 * 5)
+    sleep(1000 * 3)
 
-    shell = slider([
+    SliderShell shell = slider([
         ACTION_DESTROY,
         APPLICATION_NAME])