Merge r1600644 from trunk: YARN-1977. Add tests on getApplicationRequest with filtering start time range. (Contributed by Junping Du)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1600648 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Junping Du 2014-06-05 13:24:22 +00:00
parent fa57c0f5b8
commit 3438bf531d
2 changed files with 23 additions and 1 deletions

View File

@ -122,6 +122,8 @@ Release 2.5.0 - UNRELEASED
YARN-2061. Revisit logging levels in ZKRMStateStore. (Ray Chiang via kasha)
YARN-1977. Add tests on getApplicationRequest with filtering start time range. (junping_du)
OPTIMIZATIONS
BUG FIXES

View File

@ -646,7 +646,8 @@ public class TestClientRMService {
ApplicationId[] appIds =
{getApplicationId(101), getApplicationId(102), getApplicationId(103)};
List<String> tags = Arrays.asList("Tag1", "Tag2", "Tag3");
long[] submitTimeMillis = new long[3];
// Submit applications
for (int i = 0; i < appIds.length; i++) {
ApplicationId appId = appIds[i];
@ -656,6 +657,7 @@ public class TestClientRMService {
appId, appNames[i], queues[i % queues.length],
new HashSet<String>(tags.subList(0, i + 1)));
rmService.submitApplication(submitRequest);
submitTimeMillis[i] = System.currentTimeMillis();
}
// Test different cases of ClientRMService#getApplications()
@ -667,6 +669,24 @@ public class TestClientRMService {
request.setLimit(1L);
assertEquals("Failed to limit applications", 1,
rmService.getApplications(request).getApplicationList().size());
// Check start range
request = GetApplicationsRequest.newInstance();
request.setStartRange(submitTimeMillis[0], System.currentTimeMillis());
// 2 applications are submitted after first timeMills
assertEquals("Incorrect number of matching start range",
2, rmService.getApplications(request).getApplicationList().size());
// 1 application is submitted after the second timeMills
request.setStartRange(submitTimeMillis[1], System.currentTimeMillis());
assertEquals("Incorrect number of matching start range",
1, rmService.getApplications(request).getApplicationList().size());
// no application is submitted after the third timeMills
request.setStartRange(submitTimeMillis[2], System.currentTimeMillis());
assertEquals("Incorrect number of matching start range",
0, rmService.getApplications(request).getApplicationList().size());
// Check queue
request = GetApplicationsRequest.newInstance();