YARN-1491. Upgrade JUnit3 TestCase to JUnit 4 (Chen He via jeagles)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1550204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Turner Eagles 2013-12-11 17:50:26 +00:00
parent 94e2e78ab7
commit f3db30ccd8
5 changed files with 22 additions and 20 deletions

View File

@ -157,6 +157,8 @@ Release 2.4.0 - UNRELEASED
YARN-1481. Move internal services logic from AdminService to ResourceManager.
(vinodkv via kasha)
YARN-1491. Upgrade JUnit3 TestCase to JUnit 4 (Chen He via jeagles)
OPTIMIZATIONS
BUG FIXES

View File

@ -23,16 +23,16 @@
import java.io.IOException;
import java.util.Random;
import junit.framework.TestCase;
import org.apache.hadoop.fs.Path;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* A JUnit test to test {@link LinuxResourceCalculatorPlugin}
* Create the fake /proc/ information and verify the parsing and calculation
*/
public class TestLinuxResourceCalculatorPlugin extends TestCase {
public class TestLinuxResourceCalculatorPlugin {
/**
* LinuxResourceCalculatorPlugin with a fake timer
*/
@ -145,7 +145,7 @@ public void advanceTime(long adv) {
* @throws IOException
*/
@Test
public void testParsingProcStatAndCpuFile() throws IOException {
public void parsingProcStatAndCpuFile() throws IOException {
// Write fake /proc/cpuinfo file.
long numProcessors = 8;
long cpuFrequencyKHz = 2392781;
@ -171,7 +171,7 @@ public void testParsingProcStatAndCpuFile() throws IOException {
updateStatFile(uTime, nTime, sTime);
assertEquals(plugin.getCumulativeCpuTime(),
FAKE_JIFFY_LENGTH * (uTime + nTime + sTime));
assertEquals(plugin.getCpuUsage(), (float)(LinuxResourceCalculatorPlugin.UNAVAILABLE));
assertEquals(plugin.getCpuUsage(), (float)(LinuxResourceCalculatorPlugin.UNAVAILABLE),0.0);
// Advance the time and sample again to test the CPU usage calculation
uTime += 100L;
@ -179,13 +179,13 @@ public void testParsingProcStatAndCpuFile() throws IOException {
updateStatFile(uTime, nTime, sTime);
assertEquals(plugin.getCumulativeCpuTime(),
FAKE_JIFFY_LENGTH * (uTime + nTime + sTime));
assertEquals(plugin.getCpuUsage(), 6.25F);
assertEquals(plugin.getCpuUsage(), 6.25F, 0.0);
// Advance the time and sample again. This time, we call getCpuUsage() only.
uTime += 600L;
plugin.advanceTime(300L);
updateStatFile(uTime, nTime, sTime);
assertEquals(plugin.getCpuUsage(), 25F);
assertEquals(plugin.getCpuUsage(), 25F, 0.0);
// Advance very short period of time (one jiffy length).
// In this case, CPU usage should not be updated.
@ -194,7 +194,7 @@ public void testParsingProcStatAndCpuFile() throws IOException {
updateStatFile(uTime, nTime, sTime);
assertEquals(plugin.getCumulativeCpuTime(),
FAKE_JIFFY_LENGTH * (uTime + nTime + sTime));
assertEquals(plugin.getCpuUsage(), 25F); // CPU usage is not updated.
assertEquals(plugin.getCpuUsage(), 25F, 0.0); // CPU usage is not updated.
}
/**
@ -212,7 +212,7 @@ private void updateStatFile(long uTime, long nTime, long sTime)
* @throws IOException
*/
@Test
public void testParsingProcMemFile() throws IOException {
public void parsingProcMemFile() throws IOException {
long memTotal = 4058864L;
long memFree = 99632L;
long inactive = 567732L;

View File

@ -22,10 +22,10 @@
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.util.Shell;
import junit.framework.TestCase;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class TestWindowsBasedProcessTree extends TestCase {
public class TestWindowsBasedProcessTree {
private static final Log LOG = LogFactory
.getLog(TestWindowsBasedProcessTree.class);
@ -41,7 +41,7 @@ String getAllProcessInfoFromShell() {
}
@Test (timeout = 30000)
public void testTree() {
public void tree() {
if( !Shell.WINDOWS) {
LOG.info("Platform not Windows. Not testing");
return;

View File

@ -18,10 +18,10 @@
package org.apache.hadoop.yarn.util;
import junit.framework.TestCase;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class TestWindowsResourceCalculatorPlugin extends TestCase {
public class TestWindowsResourceCalculatorPlugin {
class WindowsResourceCalculatorPluginTester extends WindowsResourceCalculatorPlugin {
@ -33,7 +33,7 @@ String getSystemInfoInfoFromShell() {
}
@Test (timeout = 30000)
public void testParseSystemInfoString() {
public void parseSystemInfoString() {
WindowsResourceCalculatorPluginTester tester = new WindowsResourceCalculatorPluginTester();
// info str derived from windows shell command has \r\n termination
tester.infoStr = "17177038848,8589467648,15232745472,6400417792,1,2805000,6261812\r\n";
@ -51,7 +51,7 @@ public void testParseSystemInfoString() {
}
@Test (timeout = 20000)
public void testRefreshAndCpuUsage() throws InterruptedException {
public void refreshAndCpuUsage() throws InterruptedException {
WindowsResourceCalculatorPluginTester tester = new WindowsResourceCalculatorPluginTester();
// info str derived from windows shell command has \r\n termination
tester.infoStr = "17177038848,8589467648,15232745472,6400417792,1,2805000,6261812\r\n";
@ -75,7 +75,7 @@ public void testRefreshAndCpuUsage() throws InterruptedException {
}
@Test (timeout = 20000)
public void testErrorInGetSystemInfo() {
public void errorInGetSystemInfo() {
WindowsResourceCalculatorPluginTester tester = new WindowsResourceCalculatorPluginTester();
// info str derived from windows shell command has \r\n termination
tester.infoStr = null;

View File

@ -18,23 +18,23 @@
package org.apache.hadoop.yarn.util;
import junit.framework.TestCase;
import java.io.IOException;
import org.apache.hadoop.yarn.util.YarnVersionInfo;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
/**
* A JUnit test to test {@link YarnVersionInfo}
*/
public class TestYarnVersionInfo extends TestCase {
public class TestYarnVersionInfo {
/**
* Test the yarn version info routines.
* @throws IOException
*/
@Test
public void testVersionInfoGenerated() throws IOException {
public void versionInfoGenerated() throws IOException {
// can't easily know what the correct values are going to be so just
// make sure they aren't Unknown