Author: edwardyoon Date: Sun Mar 13 07:02:55 2011 New Revision: 1081042 URL: http://svn.apache.org/viewvc?rev=1081042&view=rev Log: Fix unit test fails
Removed: incubator/hama/trunk/src/test/org/apache/hama/bsp/Client.java incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPMaster.java Modified: incubator/hama/trunk/CHANGES.txt incubator/hama/trunk/src/docs/src/documentation/content/xdocs/docs/r0.2.0/ApacheHama-0.2_UserGuide.pdf incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJob.java incubator/hama/trunk/src/test/org/apache/hama/HamaCluster.java incubator/hama/trunk/src/test/org/apache/hama/HamaClusterTestCase.java incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPPeer.java Modified: incubator/hama/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=1081042&r1=1081041&r2=1081042&view=diff ============================================================================== --- incubator/hama/trunk/CHANGES.txt (original) +++ incubator/hama/trunk/CHANGES.txt Sun Mar 13 07:02:55 2011 @@ -52,6 +52,8 @@ Trunk (unreleased changes) IMPROVEMENTS + HAMA-365: TestBSPPeer doesn't check if the correct + number of messages have been received (Miklos Erdelyi via edwardyoon) HAMA-298: Implement the kill method for JobInProgress (edwardyoon) HAMA-353: Add "random communication benchmark" tool (edwardyoon) HAMA-351: Improvement of lack of info- about the output of examples (edwardyoon) @@ -202,7 +204,7 @@ Trunk (unreleased changes) HAMA-360: HAMA_MANAGES_ZK option doesn't work (edwardyoon) HAMA-355: Intermittent conflicts of enterBarrier() and leaveBarrier() (edwardyoon) - HAMA-352: Can't send one more messages on to same server in bsp() method (edwardyoon) + HAMA-352: Can't send one more messages on to same server in bsp method (edwardyoon) HAMA-350: Add task log appender and Fix log4j rootLogger (edwardyoon) HAMA-345: Add execution time calculator to Pi job (edwardyoon) HAMA-344: Task successfully finished but system re-attempt (edwardyoon) Modified: incubator/hama/trunk/src/docs/src/documentation/content/xdocs/docs/r0.2.0/ApacheHama-0.2_UserGuide.pdf URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/docs/src/documentation/content/xdocs/docs/r0.2.0/ApacheHama-0.2_UserGuide.pdf?rev=1081042&r1=1081041&r2=1081042&view=diff ============================================================================== Binary files - no diff available. Modified: incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJob.java URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJob.java?rev=1081042&r1=1081041&r2=1081042&view=diff ============================================================================== --- incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJob.java (original) +++ incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJob.java Sun Mar 13 07:02:55 2011 @@ -62,6 +62,11 @@ public class BSPJob extends BSPJobContex setJarByClass(exampleClass); } + public BSPJob(HamaConfiguration conf, int numPeer) { + super(conf, null); + this.setNumBspTask(numPeer); + } + private void ensureState(JobState state) throws IllegalStateException { if (state != this.state) { throw new IllegalStateException("Job in state " + this.state Modified: incubator/hama/trunk/src/test/org/apache/hama/HamaCluster.java URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/HamaCluster.java?rev=1081042&r1=1081041&r2=1081042&view=diff ============================================================================== --- incubator/hama/trunk/src/test/org/apache/hama/HamaCluster.java (original) +++ incubator/hama/trunk/src/test/org/apache/hama/HamaCluster.java Sun Mar 13 07:02:55 2011 @@ -33,16 +33,8 @@ public abstract class HamaCluster extend super(); } - public HamaCluster(int groomServers) { - this(groomServers, true, 10); - } - - public HamaCluster(int groomServers, int threadpool) { - this(groomServers, true, threadpool); - } - - public HamaCluster(int groomServers, boolean startDfs, int threadpool) { - super(groomServers, startDfs, threadpool); + public HamaCluster(boolean startDfs) { + super(startDfs); } protected void setUp() throws Exception { Modified: incubator/hama/trunk/src/test/org/apache/hama/HamaClusterTestCase.java URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/HamaClusterTestCase.java?rev=1081042&r1=1081041&r2=1081042&view=diff ============================================================================== --- incubator/hama/trunk/src/test/org/apache/hama/HamaClusterTestCase.java (original) +++ incubator/hama/trunk/src/test/org/apache/hama/HamaClusterTestCase.java Sun Mar 13 07:02:55 2011 @@ -18,42 +18,27 @@ package org.apache.hama; import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.MiniDFSCluster; -import org.apache.hadoop.util.ReflectionUtils; public abstract class HamaClusterTestCase extends HamaTestCase { public static final Log LOG = LogFactory.getLog(HamaClusterTestCase.class); - public MiniBSPCluster cluster; protected MiniDFSCluster dfsCluster; protected MiniZooKeeperCluster zooKeeperCluster; - protected int groomServers; protected boolean startDfs; /** default constructor */ public HamaClusterTestCase() { - this(1); + this(false); } - public HamaClusterTestCase(int groomServers) { - this(groomServers, true, 10); - } - - public HamaClusterTestCase(int groomServers, boolean startDfs, int threadpool) { + public HamaClusterTestCase(boolean startDfs) { super(); this.startDfs = startDfs; - this.groomServers = groomServers; - conf.setInt("bsp.test.threadpool", threadpool); - } - - public MiniBSPCluster getCluster(){ - return this.cluster; } /** @@ -67,9 +52,6 @@ public abstract class HamaClusterTestCas this.zooKeeperCluster = new MiniZooKeeperCluster(); int clientPort = this.zooKeeperCluster.startup(testDir); conf.set("hama.zookeeper.property.clientPort", Integer.toString(clientPort)); - - // start the mini cluster - this.cluster = new MiniBSPCluster(conf, groomServers); } @Override @@ -96,9 +78,6 @@ public abstract class HamaClusterTestCas // start the instance hamaClusterSetup(); } catch (Exception e) { - if (cluster != null) { - cluster.shutdown(); - } if (zooKeeperCluster != null) { zooKeeperCluster.shutdown(); } @@ -113,19 +92,6 @@ public abstract class HamaClusterTestCas protected void tearDown() throws Exception { super.tearDown(); try { - if (this.cluster != null) { - try { - - this.cluster.shutdown(); - } catch (Exception e) { - LOG.warn("Closing mini dfs", e); - } - try { - this.zooKeeperCluster.shutdown(); - } catch (IOException e) { - LOG.warn("Shutting down ZooKeeper cluster", e); - } - } if (startDfs) { shutdownDfs(dfsCluster); } @@ -133,39 +99,4 @@ public abstract class HamaClusterTestCas LOG.error(e); } } - - - /** - * Use this utility method debugging why cluster won't go down. On a - * period it throws a thread dump. Method ends when all cluster - * groomservers and master threads are no long alive. - */ - public void threadDumpingJoin() { - if (this.cluster.getGroomServerThreads() != null) { - for(Thread t: this.cluster.getGroomServerThreads()) { - threadDumpingJoin(t); - } - } - threadDumpingJoin(this.cluster.getMaster()); - } - - protected void threadDumpingJoin(final Thread t) { - if (t == null) { - return; - } - long startTime = System.currentTimeMillis(); - while (t.isAlive()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - LOG.info("Continuing...", e); - } - if (System.currentTimeMillis() - startTime > 60000) { - startTime = System.currentTimeMillis(); - ReflectionUtils.printThreadInfo(new PrintWriter(System.out), - "Automatic Stack Trace every 60 seconds waiting on " + - t.getName()); - } - } - } } Modified: incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPPeer.java URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPPeer.java?rev=1081042&r1=1081041&r2=1081042&view=diff ============================================================================== --- incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPPeer.java (original) +++ incubator/hama/trunk/src/test/org/apache/hama/bsp/TestBSPPeer.java Sun Mar 13 07:02:55 2011 @@ -98,8 +98,7 @@ public class TestBSPPeer extends HamaClu TaskStatus currentTaskStatus = new TaskStatus(new BSPJobID(), new TaskAttemptID(), 0, null, null, null, null); peer.setCurrentTaskStatus(currentTaskStatus); - BSPJob jobConf = new BSPJob(conf); - jobConf.setNumBspTask(NUM_PEER); + BSPJob jobConf = new BSPJob(conf, NUM_PEER); peer.setJobConf((BSPJob) jobConf); } @@ -157,16 +156,19 @@ public class TestBSPPeer extends HamaClu } BSPMessage msg = null; - + int messageCounter = 0; + try { while ((msg = peer.getCurrentMessage()) != null) { assertEquals(Bytes.compareTo(msg.tag, 0, 128, msg.data, msg.data.length - 128, 128), 0); + ++messageCounter; } } catch (IOException e) { LOG.error(e); } - + assertEquals(numMessages, messageCounter); + peer.clearLocalQueue(); }