MAPREDUCE-6914. Tests use assertTrue(....equals(...)) instead of assertEquals()). (Daniel Templeton via Yufei Gu)

This commit is contained in:
Yufei Gu 2017-08-03 11:44:34 -07:00
parent c617fe02b3
commit b8e8241854
5 changed files with 22 additions and 23 deletions

View File

@ -124,20 +124,20 @@ private void testProxyConfiguration(Configuration conf) {
proxyToUse.type() == Proxy.Type.DIRECT); proxyToUse.type() == Proxy.Type.DIRECT);
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost:1000"); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost:1000");
setConf(conf); setConf(conf);
Assert.assertTrue("Proxy should have been set but wasn't ", Assert.assertEquals("Proxy should have been set but wasn't ",
proxyToUse.toString().equals("HTTP @ somehost:1000")); "HTTP @ somehost:1000", proxyToUse.toString());
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000"); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000");
setConf(conf); setConf(conf);
Assert.assertTrue("Proxy should have been socks but wasn't ", Assert.assertEquals("Proxy should have been socks but wasn't ",
proxyToUse.toString().equals("SOCKS @ somehost:1000")); "SOCKS @ somehost:1000", proxyToUse.toString());
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000"); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000");
setConf(conf); setConf(conf);
Assert.assertTrue("Proxy should have been socks but wasn't ", Assert.assertEquals("Proxy should have been socks but wasn't ",
proxyToUse.toString().equals("SOCKS @ somehost:1000")); "SOCKS @ somehost:1000", proxyToUse.toString());
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000"); conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000");
setConf(conf); setConf(conf);
Assert.assertTrue("Proxy should have been http but wasn't ", Assert.assertEquals("Proxy should have been http but wasn't ",
proxyToUse.toString().equals("HTTP @ somehost:1000")); "HTTP @ somehost:1000", proxyToUse.toString());
} }

View File

@ -329,8 +329,7 @@ public void testMapNodeLocality() throws Exception {
for(TaskAttemptContainerAssignedEvent event : assigned) { for(TaskAttemptContainerAssignedEvent event : assigned) {
if(event.getTaskAttemptID().equals(event3.getAttemptID())) { if(event.getTaskAttemptID().equals(event3.getAttemptID())) {
assigned.remove(event); assigned.remove(event);
Assert.assertTrue( Assert.assertEquals("h3", event.getContainer().getNodeId().getHost());
event.getContainer().getNodeId().getHost().equals("h3"));
break; break;
} }
} }

View File

@ -74,13 +74,13 @@ public void testQueue() throws IOException {
assertTrue(root.getChildren().size() == 2); assertTrue(root.getChildren().size() == 2);
Iterator<Queue> iterator = root.getChildren().iterator(); Iterator<Queue> iterator = root.getChildren().iterator();
Queue firstSubQueue = iterator.next(); Queue firstSubQueue = iterator.next();
assertTrue(firstSubQueue.getName().equals("first")); assertEquals("first", firstSubQueue.getName());
assertEquals( assertEquals(
firstSubQueue.getAcls().get("mapred.queue.first.acl-submit-job") firstSubQueue.getAcls().get("mapred.queue.first.acl-submit-job")
.toString(), .toString(),
"Users [user1, user2] and members of the groups [group1, group2] are allowed"); "Users [user1, user2] and members of the groups [group1, group2] are allowed");
Queue secondSubQueue = iterator.next(); Queue secondSubQueue = iterator.next();
assertTrue(secondSubQueue.getName().equals("second")); assertEquals("second", secondSubQueue.getName());
assertEquals(secondSubQueue.getProperties().getProperty("key"), "value"); assertEquals(secondSubQueue.getProperties().getProperty("key"), "value");
assertEquals(secondSubQueue.getProperties().getProperty("key1"), "value1"); assertEquals(secondSubQueue.getProperties().getProperty("key1"), "value1");
// test status // test status
@ -207,13 +207,13 @@ public void test2Queue() throws IOException {
assertTrue(root.getChildren().size() == 2); assertTrue(root.getChildren().size() == 2);
Iterator<Queue> iterator = root.getChildren().iterator(); Iterator<Queue> iterator = root.getChildren().iterator();
Queue firstSubQueue = iterator.next(); Queue firstSubQueue = iterator.next();
assertTrue(firstSubQueue.getName().equals("first")); assertEquals("first", firstSubQueue.getName());
assertEquals( assertEquals(
firstSubQueue.getAcls().get("mapred.queue.first.acl-submit-job") firstSubQueue.getAcls().get("mapred.queue.first.acl-submit-job")
.toString(), .toString(),
"Users [user1, user2] and members of the groups [group1, group2] are allowed"); "Users [user1, user2] and members of the groups [group1, group2] are allowed");
Queue secondSubQueue = iterator.next(); Queue secondSubQueue = iterator.next();
assertTrue(secondSubQueue.getName().equals("second")); assertEquals("second", secondSubQueue.getName());
assertEquals(firstSubQueue.getState().getStateName(), "running"); assertEquals(firstSubQueue.getState().getStateName(), "running");
assertEquals(secondSubQueue.getState().getStateName(), "stopped"); assertEquals(secondSubQueue.getState().getStateName(), "stopped");

View File

@ -871,10 +871,10 @@ public void testSendJobConf() throws IOException {
Configuration confSent = BuilderUtils.parseTokensConf(submissionContext); Configuration confSent = BuilderUtils.parseTokensConf(submissionContext);
// configs that match regex should be included // configs that match regex should be included
Assert.assertTrue(confSent.get("dfs.namenode.rpc-address.mycluster2.nn1") Assert.assertEquals("123.0.0.1",
.equals("123.0.0.1")); confSent.get("dfs.namenode.rpc-address.mycluster2.nn1"));
Assert.assertTrue(confSent.get("dfs.namenode.rpc-address.mycluster2.nn2") Assert.assertEquals("123.0.0.2",
.equals("123.0.0.2")); confSent.get("dfs.namenode.rpc-address.mycluster2.nn2"));
// configs that aren't matching regex should not be included // configs that aren't matching regex should not be included
Assert.assertTrue(confSent.get("hadoop.tmp.dir") == null || !confSent Assert.assertTrue(confSent.get("hadoop.tmp.dir") == null || !confSent

View File

@ -134,11 +134,11 @@ public void testDoMultipleInputs() throws IOException {
BufferedReader output = new BufferedReader(new InputStreamReader(fs BufferedReader output = new BufferedReader(new InputStreamReader(fs
.open(new Path(outDir, "part-r-00000")))); .open(new Path(outDir, "part-r-00000"))));
// reducer should have counted one key from each file // reducer should have counted one key from each file
assertTrue(output.readLine().equals("a 2")); assertEquals("a 2", output.readLine());
assertTrue(output.readLine().equals("b 2")); assertEquals("b 2", output.readLine());
assertTrue(output.readLine().equals("c 2")); assertEquals("c 2", output.readLine());
assertTrue(output.readLine().equals("d 2")); assertEquals("d 2", output.readLine());
assertTrue(output.readLine().equals("e 2")); assertEquals("e 2", output.readLine());
} }
@Test @Test