aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [3/5] git commit: Added a unit test. <Breaks>
Date Fri, 13 Dec 2013 00:40:55 GMT
Added a unit test. <Breaks>


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/78e45bfc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/78e45bfc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/78e45bfc

Branch: refs/heads/skarumuri/MESOS-4679_api_jobs_by_role
Commit: 78e45bfcd5dadeda112f10049c4db415010f924c
Parents: 9a94695
Author: Suman Karumuri <skarumuri@twitter.com>
Authored: Tue Nov 26 16:14:49 2013 -0800
Committer: Suman Karumuri <skarumuri@twitter.com>
Committed: Tue Nov 26 16:14:49 2013 -0800

----------------------------------------------------------------------
 .../thrift/SchedulerThriftInterface.java        |  4 +--
 .../thrift/SchedulerThriftInterfaceTest.java    | 33 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/78e45bfc/src/main/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 317d685..d6af11f 100644
--- a/src/main/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -377,7 +377,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
   @Override
   public Response getRoleSummary() {
-    final Function<String, RoleSummary> CREATE_ROLE = new Function<String, RoleSummary>()
{
+    final Function<String, RoleSummary> CREATE_ROLE_SUMMARY = new Function<String,
RoleSummary>() {
       @Override public RoleSummary apply(String ownerRole) {
         RoleSummary role = new RoleSummary();
         role.setRole(ownerRole);
@@ -396,7 +396,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
 
     // TODO(Suman Karumuri): Respond to this request without an expensive query.
     LoadingCache<String, RoleSummary> roleSummaries =
-        CacheBuilder.newBuilder().build(CacheLoader.from(CREATE_ROLE));
+        CacheBuilder.newBuilder().build(CacheLoader.from(CREATE_ROLE_SUMMARY));
 
     Set<IScheduledTask> tasks =
         Storage.Util.weaklyConsistentFetchTasks(storage, Query.unscoped());

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/78e45bfc/src/test/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index 1f3cd6e..4debbcc 100644
--- a/src/test/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/com/twitter/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -1034,6 +1034,39 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   @Test
+  public void testGetRoleSummary() throws Exception {
+    JobConfiguration cronJobOne = makeJob()
+        .setCronSchedule("1 * * * *")
+        .setKey(JOB_KEY.newBuilder())
+        .setTaskConfig(nonProductionTask());
+    JobKey jobKey2 = JOB_KEY.newBuilder().setRole("other_role");
+    JobConfiguration cronJobTwo = makeJob()
+        .setCronSchedule("2 * * * *")
+        .setKey(jobKey2)
+        .setTaskConfig(nonProductionTask());
+    TaskConfig immediateTaskConfig = defaultTask(false)
+        .setJobName("immediate")
+        .setOwner(ROLE_IDENTITY);
+    IScheduledTask immediateTask = IScheduledTask.build(new ScheduledTask()
+        .setAssignedTask(
+            new AssignedTask().setTask(immediateTaskConfig)));
+    JobConfiguration immediateJob = new JobConfiguration()
+        .setKey(JOB_KEY.newBuilder().setName("immediate"))
+        .setOwner(ROLE_IDENTITY)
+        .setInstanceCount(1)
+        .setTaskConfig(immediateTaskConfig);
+
+    Set<JobConfiguration> crons = ImmutableSet.of(cronJobOne, cronJobTwo);
+    expect(cronJobManager.getJobs()).andReturn(IJobConfiguration.setFromBuilders(crons));
+    storageUtil.expectTaskFetch(Query.unscoped().active(), immediateTask);
+
+    control.replay();
+
+    Response response = thrift.getRoleSummary();
+    assertEquals(ResponseCode.OK, response.getResponseCode());
+  }
+
+  @Test
   public void testSnapshot() throws Exception {
     expectAuth(ROOT, false);
 


Mime
View raw message