hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077481 - in /hadoop/common/branches/branch-0.20-security-patches/src/test/system: conf/system-test.xml java/org/apache/hadoop/mapred/TestPushConfig.java java/org/apache/hadoop/mapreduce/test/system/JTClient.java
Date Fri, 04 Mar 2011 04:19:27 GMT
Author: omalley
Date: Fri Mar  4 04:19:27 2011
New Revision: 1077481

URL: http://svn.apache.org/viewvc?rev=1077481&view=rev
Log:
commit 27609fbfb69b9025fb98b65776cb37f9d2f08202
Author: Vinay Kumar Thota <vinayt@yahoo-inc.com>
Date:   Wed May 26 05:32:49 2010 +0000

    MAPREDUCE:1713 from https://issues.apache.org/jira/secure/attachment/12445025/MAPREDUCE-1713.patch

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapred/TestPushConfig.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapreduce/test/system/JTClient.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml?rev=1077481&r1=1077480&r2=1077481&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/conf/system-test.xml
Fri Mar  4 04:19:27 2011
@@ -68,6 +68,14 @@ neutral at the forward-port stage -->
   the clusters is pointed out this directory. 
   </description>
 </property>
+<property>
+  <name>test.system.hdrc.hadoop.local.confdir</name>
+  <value>$(TO_DO_GLOBAL_TMP_DIR)/localconf</value>
+  <description>
+  It's a local conf directory where the new config file is store temporarily
+  before pushing into new config folder location in the cluster.
+  </description>
+</property>
 
 <!-- Mandatory keys to be set for the multi user support to be enabled.  -->
 

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapred/TestPushConfig.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapred/TestPushConfig.java?rev=1077481&r1=1077480&r2=1077481&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapred/TestPushConfig.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapred/TestPushConfig.java
Fri Mar  4 04:19:27 2011
@@ -1,12 +1,29 @@
+/**
+ * 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.hadoop.mapred;
-import java.io.File;
-import java.io.FileOutputStream;
+
+
+import java.util.Hashtable;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.test.system.MRCluster;
-import org.apache.hadoop.test.system.AbstractDaemonClient;
-import org.apache.hadoop.test.system.process.HadoopDaemonRemoteCluster;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -14,7 +31,6 @@ import org.junit.Test;
 
 public class TestPushConfig {
   private static MRCluster cluster;
-  private String localConfDir = "localconf";
   private static final Log LOG = LogFactory.getLog(
       TestPushConfig.class.getName());
   
@@ -40,106 +56,24 @@ public class TestPushConfig {
    * in local input directory and pushes all the files from the local to the 
    * remote conf directory. This functionality is required is change the config
    * on the fly and restart the cluster which will be used by other test cases
-   * @throws Exception is thrown if pushConfig fails. 
+   * @throws Exception if an I/O error occurs.
    */
   @Test
   public void testPushConfig() throws Exception {
     final String DUMMY_CONFIG_STRING = "mapred.newdummy.conf";
-    final String DUMMY_CONFIG_STRING_VALUE = "HerriotTestRules";
-    Configuration origconf = new Configuration(cluster.getConf());
-    origconf.set(DUMMY_CONFIG_STRING, DUMMY_CONFIG_STRING_VALUE);
-    String localDir = HadoopDaemonRemoteCluster.getDeployedHadoopConfDir() + 
-        File.separator + localConfDir;
-    File lFile = new File(localDir);
-    if(!lFile.exists()){
-      lFile.mkdir();
-    }
-    String mapredConf = localDir + File.separator + "mapred-site.xml";
-    File file = new File(mapredConf);
-    origconf.writeXml(new FileOutputStream(file));    
+    String confFile = "mapred-site.xml";
+    Hashtable<String,Long> prop = new Hashtable<String,Long>();
+    prop.put(DUMMY_CONFIG_STRING, 1L);
     Configuration daemonConf =  cluster.getJTClient().getProxy().getDaemonConf();
     Assert.assertTrue("Dummy varialble is expected to be null before restart.",
         daemonConf.get(DUMMY_CONFIG_STRING) == null);
-    String newDir = cluster.getClusterManager().pushConfig(localDir);
-    cluster.stop();
-    AbstractDaemonClient cli = cluster.getJTClient();
-    waitForClusterStop(cli);
-    // make sure the cluster has actually stopped
-    cluster.getClusterManager().start(newDir);
-    cli = cluster.getJTClient();
-    waitForClusterStart(cli);
-    // make sure the cluster has actually started
+    cluster.restartClusterWithNewConfig(prop, confFile);    
     Configuration newconf = cluster.getJTClient().getProxy().getDaemonConf();
     Assert.assertTrue("Extra varialble is expected to be set",
-        newconf.get(DUMMY_CONFIG_STRING).equals(DUMMY_CONFIG_STRING_VALUE));
-    cluster.getClusterManager().stop(newDir);
-    cli = cluster.getJTClient();
-    // make sure the cluster has actually stopped
-    waitForClusterStop(cli);
-    // start the daemons with original conf dir
-    cluster.getClusterManager().start();
-    cli = cluster.getJTClient();    
-    waitForClusterStart(cli);  
-    daemonConf =  cluster.getJTClient().getProxy().getDaemonConf();
+        newconf.get(DUMMY_CONFIG_STRING).equals("1"));
+    cluster.restart();
+    daemonConf = cluster.getJTClient().getProxy().getDaemonConf();
     Assert.assertTrue("Dummy variable is expected to be null after restart.",
-        daemonConf.get(DUMMY_CONFIG_STRING) == null);
-    lFile.delete();
-  }
-  
-  private void waitForClusterStop(AbstractDaemonClient cli) throws Exception {
-    int i=1;
-    while (i < 40) {
-      try {
-        cli.ping();
-        Thread.sleep(1000);
-        i++;
-      } catch (Exception e) {
-        break;
-      }
-    }
-    for (AbstractDaemonClient tcli : cluster.getTTClients()) {
-      i = 1;
-      while (i < 40) {
-        try {
-          tcli.ping();
-          Thread.sleep(1000);
-          i++;
-        } catch (Exception e) {
-          break;
-        }
-      }
-      if (i >= 40) {
-        Assert.fail("TT on " + tcli.getHostName() + " Should have been down.");
-      }
-    }
-  }
-  
-  private void waitForClusterStart(AbstractDaemonClient cli) throws Exception {
-    int i=1;
-    while (i < 40) {
-      try {
-        cli.ping();
-        break;
-      } catch (Exception e) {
-        i++;
-        Thread.sleep(1000);
-        LOG.info("Waiting for Jobtracker on host : "
-            + cli.getHostName() + " to come up.");
-      }
-    }
-    for (AbstractDaemonClient tcli : cluster.getTTClients()) {
-      i = 1;
-      while (i < 40) {
-        try {
-          tcli.ping();
-          break;
-        } catch (Exception e) {
-          i++;
-          Thread.sleep(1000);
-          LOG.info("Waiting for Tasktracker on host : "
-              + tcli.getHostName() + " to come up.");
-        }
-      }
-    }
-  }
-}
+        daemonConf.get(DUMMY_CONFIG_STRING) == null);   
+  }  
+ }

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapreduce/test/system/JTClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapreduce/test/system/JTClient.java?rev=1077481&r1=1077480&r2=1077481&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapreduce/test/system/JTClient.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/mapreduce/test/system/JTClient.java
Fri Mar  4 04:19:27 2011
@@ -36,6 +36,7 @@ import org.apache.hadoop.mapred.TaskStat
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.mapreduce.test.system.TaskInfo;
+import org.apache.hadoop.mapred.UtilsForTests;
 import static org.junit.Assert.*;
 
 /**
@@ -326,4 +327,49 @@ public class JTClient extends MRDaemonCl
     }
     LOG.info("Verified the job history for the jobId : " + jobId);
   }
+
+  /**
+   * It uses to check whether job is started or not.
+   * @param id job id
+   * @return true if job is running.
+   * @throws IOException if an I/O error occurs.
+   */
+  public boolean isJobStarted(JobID id) throws IOException {
+    JobInfo jInfo = getJobInfo(id);
+    int counter = 0;
+    while (counter < 60) {
+      if (jInfo.getStatus().getRunState() == JobStatus.RUNNING) {
+        break;
+      } else {
+        UtilsForTests.waitFor(1000);
+        jInfo = getJobInfo(jInfo.getID());
+        Assert.assertNotNull("Job information is null",jInfo);
+      }
+      counter++;
+    }
+    return (counter != 60)? true : false ;
+  }
+
+  /**
+   * It uses to check whether task is started or not.
+   * @param taskInfo task information
+   * @return true if task is running.
+   * @throws IOException if an I/O error occurs.
+   */
+  public boolean isTaskStarted(TaskInfo taskInfo) throws IOException { 
+    JTProtocol wovenClient = getProxy();
+    int counter = 0;
+    while (counter < 60) {
+      if (taskInfo.getTaskStatus().length > 0) {
+        if (taskInfo.getTaskStatus()[0].getRunState() == 
+            TaskStatus.State.RUNNING) {
+          break;
+        }
+      }
+      UtilsForTests.waitFor(1000);
+      taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
+      counter++;
+    }
+    return (counter != 60)? true : false;
+  }
 }



Mime
View raw message