You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2016/07/19 21:41:04 UTC
[04/50] hadoop git commit: MAPREDUCE-6625. TestCLI#testGetJob fails
occasionally (haibochen via rkanter)
MAPREDUCE-6625. TestCLI#testGetJob fails occasionally (haibochen via rkanter)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ef14fa6a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ef14fa6a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ef14fa6a
Branch: refs/heads/YARN-2915
Commit: ef14fa6a1a02ef3cf1291f2cb5aa5666505d5281
Parents: 4972edc
Author: Robert Kanter <rk...@apache.org>
Authored: Tue Jul 12 15:51:18 2016 -0700
Committer: Subru Krishnan <su...@apache.org>
Committed: Tue Jul 19 14:39:29 2016 -0700
----------------------------------------------------------------------
.../apache/hadoop/mapreduce/tools/TestCLI.java | 47 ++++++++++++--------
1 file changed, 28 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ef14fa6a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
index 112f585..985eea3 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
@@ -31,9 +31,10 @@ import org.apache.hadoop.mapreduce.TaskType;
import org.apache.hadoop.mapreduce.JobPriority;
import org.apache.hadoop.mapreduce.JobStatus;
import org.apache.hadoop.mapreduce.JobStatus.State;
-import org.apache.hadoop.util.Time;
import org.junit.Assert;
import org.junit.Test;
+
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.times;
@@ -162,25 +163,33 @@ public class TestCLI {
}
@Test
- public void testGetJob() throws Exception {
+ public void testGetJobWithoutRetry() throws Exception {
Configuration conf = new Configuration();
- long sleepTime = 100;
- conf.setLong(MRJobConfig.MR_CLIENT_JOB_RETRY_INTERVAL, sleepTime);
- Cluster mockCluster = mock(Cluster.class);
- JobID jobId1 = JobID.forName("job_1234654654_001");
- when(mockCluster.getJob(jobId1)).thenReturn(null);
-
- for (int i = 0; i < 2; ++i) {
- conf.setInt(MRJobConfig.MR_CLIENT_JOB_MAX_RETRIES, i);
- CLI cli = spy(new CLI(conf));
- cli.cluster = mockCluster;
- doReturn(mockCluster).when(cli).createCluster();
- long start = Time.monotonicNow();
- cli.getJob(jobId1);
- long end = Time.monotonicNow();
- Assert.assertTrue(end - start > (i * sleepTime));
- Assert.assertTrue(end - start < ((i + 1) * sleepTime));
- }
+ conf.setInt(MRJobConfig.MR_CLIENT_JOB_MAX_RETRIES, 0);
+
+ final Cluster mockCluster = mock(Cluster.class);
+ when(mockCluster.getJob(any(JobID.class))).thenReturn(null);
+ CLI cli = new CLI(conf);
+ cli.cluster = mockCluster;
+
+ Job job = cli.getJob(JobID.forName("job_1234654654_001"));
+ Assert.assertTrue("job is not null", job == null);
+ }
+
+ @Test
+ public void testGetJobWithRetry() throws Exception {
+ Configuration conf = new Configuration();
+ conf.setInt(MRJobConfig.MR_CLIENT_JOB_MAX_RETRIES, 1);
+
+ final Cluster mockCluster = mock(Cluster.class);
+ final Job mockJob = Job.getInstance(conf);
+ when(mockCluster.getJob(any(JobID.class))).thenReturn(
+ null).thenReturn(mockJob);
+ CLI cli = new CLI(conf);
+ cli.cluster = mockCluster;
+
+ Job job = cli.getJob(JobID.forName("job_1234654654_001"));
+ Assert.assertTrue("job is null", job != null);
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org