aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [1/2] aurora git commit: Replacing IResourceAggregate in resource calculations.
Date Fri, 06 May 2016 19:14:10 GMT
Repository: aurora
Updated Branches:
  refs/heads/master d702587d2 -> 3687c6a1a


http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
index d591d0f..2e97a33 100644
--- a/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/quota/QuotaManagerImplTest.java
@@ -38,7 +38,7 @@ import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.quota.QuotaManager.QuotaException;
 import org.apache.aurora.scheduler.quota.QuotaManager.QuotaManagerImpl;
-import org.apache.aurora.scheduler.resources.ResourceTestUtil;
+import org.apache.aurora.scheduler.resources.ResourceType;
 import org.apache.aurora.scheduler.storage.JobUpdateStore;
 import org.apache.aurora.scheduler.storage.Storage.StoreProvider;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
@@ -54,10 +54,16 @@ import org.easymock.IExpectationSetters;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.aurora.gen.Resource.diskMb;
+import static org.apache.aurora.gen.Resource.namedPort;
+import static org.apache.aurora.gen.Resource.numCpus;
+import static org.apache.aurora.gen.Resource.ramMb;
 import static org.apache.aurora.scheduler.quota.QuotaCheckResult.Result.INSUFFICIENT_QUOTA;
 import static org.apache.aurora.scheduler.quota.QuotaCheckResult.Result.SUFFICIENT_QUOTA;
 import static org.apache.aurora.scheduler.quota.QuotaManager.QuotaManagerImpl.updateQuery;
-import static org.apache.aurora.scheduler.resources.ResourceAggregates.EMPTY;
+import static org.apache.aurora.scheduler.resources.ResourceBag.EMPTY;
+import static org.apache.aurora.scheduler.resources.ResourceTestUtil.aggregate;
+import static org.apache.aurora.scheduler.resources.ResourceTestUtil.bag;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
@@ -92,9 +98,8 @@ public class QuotaManagerImplTest extends EasyMockTest {
     IScheduledTask prodDedicatedTask = prodDedicatedTask("foo2", 5, 5, 5);
     IScheduledTask nonProdSharedTask = nonProdTask("bar1", 2, 2, 2);
     IScheduledTask nonProdDedicatedTask = nonProdDedicatedTask("bar2", 7, 7, 7);
-    IResourceAggregate quota = aggregate(4, 4, 4);
 
-    expectQuota(quota);
+    expectQuota(aggregate(4, 4, 4));
     expectTasks(prodSharedTask, nonProdSharedTask, prodDedicatedTask, nonProdDedicatedTask);
     expectJobUpdates(taskConfig(1, 1, 1, true), taskConfig(1, 1, 1, true));
     expectCronJobs(
@@ -104,12 +109,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     control.replay();
 
     assertEquals(
-        new QuotaInfo(
-            aggregate(4, 4, 4),
-            aggregate(6, 6, 6),
-            aggregate(5, 5, 5),
-            aggregate(9, 9, 9),
-            aggregate(7, 7, 7)),
+        new QuotaInfo(bag(4, 4, 4), bag(6, 6, 6), bag(5, 5, 5), bag(9, 9, 9), bag(7, 7, 7)),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -117,9 +117,8 @@ public class QuotaManagerImplTest extends EasyMockTest {
   public void testGetQuotaInfoWithCronTasks() {
     IScheduledTask prodTask = prodTask("pc", 6, 6, 6);
     IScheduledTask nonProdTask = prodTask("npc", 7, 7, 7);
-    IResourceAggregate quota = aggregate(4, 4, 4);
 
-    expectQuota(quota);
+    expectQuota(aggregate(4, 4, 4));
     expectTasks(prodTask, nonProdTask);
     expectJobUpdates(taskConfig(1, 1, 1, true), taskConfig(1, 1, 1, true));
 
@@ -142,7 +141,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     control.replay();
 
     assertEquals(
-        new QuotaInfo(aggregate(4, 4, 4), aggregate(7, 7, 7), EMPTY, aggregate(10, 10, 10),
EMPTY),
+        new QuotaInfo(bag(4, 4, 4), bag(7, 7, 7), EMPTY, bag(10, 10, 10), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -152,9 +151,8 @@ public class QuotaManagerImplTest extends EasyMockTest {
     IScheduledTask updatingProdTask = createTask(JOB_NAME, "id1", 3, 3, 3, true, 1);
     IScheduledTask updatingFilteredProdTask = createTask(JOB_NAME, "id0", 3, 3, 3, true,
0);
     IScheduledTask nonProdTask = createTask("bar", "id1", 2, 2, 2, false, 0);
-    IResourceAggregate quota = aggregate(4, 4, 4);
 
-    expectQuota(quota);
+    expectQuota(aggregate(4, 4, 4));
     expectTasks(prodTask, updatingProdTask, updatingFilteredProdTask, nonProdTask);
     expectJobUpdates(taskConfig(1, 1, 1, true), taskConfig(1, 1, 1, true));
     expectNoCronJobs();
@@ -163,15 +161,13 @@ public class QuotaManagerImplTest extends EasyMockTest {
 
     // Expected consumption from: prodTask + updatingProdTask + job update.
     assertEquals(
-        new QuotaInfo(aggregate(4, 4, 4), aggregate(7, 7, 7), EMPTY, aggregate(2, 2, 2),
EMPTY),
+        new QuotaInfo(bag(4, 4, 4), bag(7, 7, 7), EMPTY, bag(2, 2, 2), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
   @Test
   public void testGetQuotaInfoNoTasksNoUpdatesNoCronJobs() {
-    IResourceAggregate quota = aggregate(4, 4, 4);
-
-    expectQuota(quota);
+    expectQuota(aggregate(4, 4, 4));
     expectNoTasks();
     expectNoJobUpdates();
     expectNoCronJobs();
@@ -179,7 +175,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     control.replay();
 
     assertEquals(
-        new QuotaInfo(aggregate(4, 4, 4), aggregate(0, 0, 0), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(4, 4, 4), bag(0, 0, 0), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -332,7 +328,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     QuotaCheckResult checkQuota =
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 2, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
-    assertTrue(checkQuota.getDetails().get().contains("DISK"));
+    assertTrue(checkQuota.getDetails().get().contains(ResourceType.DISK_MB.getAuroraName()));
   }
 
   @Test
@@ -350,7 +346,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(2, 2, 2, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, aggregate(7, 7, 7),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, bag(7, 7, 7), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -369,7 +365,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -387,7 +383,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, aggregate(8, 8, 8),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, bag(8, 8, 8), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -405,7 +401,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, aggregate(7, 7, 7),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, bag(7, 7, 7), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -423,7 +419,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(5, 5, 5), EMPTY, aggregate(1, 1, 1),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(5, 5, 5), EMPTY, bag(1, 1, 1), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -440,7 +436,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(6, 6, 6), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(6, 6, 6), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -457,7 +453,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(6, 6, 6), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(6, 6, 6), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -474,7 +470,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(6, 6, 6), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(6, 6, 6), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -503,7 +499,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(4, 4, 4), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(4, 4, 4), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -532,7 +528,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(4, 4, 4), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(4, 4, 4), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -561,7 +557,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkInstanceAddition(taskConfig(1, 1, 1, true), 1, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(6, 6, 6), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(6, 6, 6), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -589,7 +585,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     QuotaCheckResult checkQuota = quotaManager.checkJobUpdate(update, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(6, 6, 6), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(6, 6, 6), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -614,7 +610,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     QuotaCheckResult checkQuota = quotaManager.checkJobUpdate(update, storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(4, 4, 4), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(4, 4, 4), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -642,7 +638,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     QuotaCheckResult checkQuota = quotaManager.checkJobUpdate(update, storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(6, 6, 6), aggregate(6, 6, 6), EMPTY, aggregate(0, 0, 0),
EMPTY),
+        new QuotaInfo(bag(6, 6, 6), bag(6, 6, 6), EMPTY, bag(0, 0, 0), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -721,7 +717,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
     expectNoTasks();
     expectQuota(aggregate(1, 1, 1));
 
-    storageUtil.quotaStore.saveQuota(ROLE, EMPTY);
+    storageUtil.quotaStore.saveQuota(ROLE, aggregate(0, 0, 0));
 
     control.replay();
     quotaManager.saveQuota(ROLE, aggregate(0, 0, 0), storageUtil.mutableStoreProvider);
@@ -762,7 +758,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkCronUpdate(createJob(prodTask("pc", 1, 1, 1), 2), storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, aggregate(7, 7, 7),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, bag(7, 7, 7), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -782,7 +778,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkCronUpdate(createJob(prodTask("pc", 5, 5, 5), 1), storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, aggregate(7, 7, 7),
EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, bag(7, 7, 7), EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -802,7 +798,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkCronUpdate(createJob(prodTask("pc", 5, 5, 5), 2), storeProvider);
     assertEquals(INSUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), aggregate(4, 4, 4), EMPTY, EMPTY, EMPTY),
+        new QuotaInfo(bag(5, 5, 5), bag(4, 4, 4), EMPTY, EMPTY, EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -820,7 +816,7 @@ public class QuotaManagerImplTest extends EasyMockTest {
         quotaManager.checkCronUpdate(createJob(prodTask("pc", 5, 5, 5), 1), storeProvider);
     assertEquals(SUFFICIENT_QUOTA, checkQuota.getResult());
     assertEquals(
-        new QuotaInfo(aggregate(5, 5, 5), EMPTY, EMPTY, EMPTY, EMPTY),
+        new QuotaInfo(bag(5, 5, 5), EMPTY, EMPTY, EMPTY, EMPTY),
         quotaManager.getQuotaInfo(ROLE, storeProvider));
   }
 
@@ -968,9 +964,12 @@ public class QuotaManagerImplTest extends EasyMockTest {
     ScheduledTask builder = TaskTestUtil.makeTask(taskId, JobKeys.from(ROLE, ENV, jobName))
         .newBuilder();
     builder.getAssignedTask().setInstanceId(instanceId);
-    builder.getAssignedTask().getTask().setNumCpus(cpus)
+    builder.getAssignedTask().getTask()
+        .setNumCpus(cpus)
         .setRamMb(ramMb)
         .setDiskMb(diskMb)
+        .setRequestedPorts(ImmutableSet.of("a"))
+        .setResources(ImmutableSet.of(numCpus(cpus), ramMb(ramMb), diskMb(diskMb), namedPort("a")))
         .setProduction(production);
     return IScheduledTask.build(builder);
   }
@@ -982,8 +981,4 @@ public class QuotaManagerImplTest extends EasyMockTest {
         .setTaskConfig(task)
         .setInstanceCount(instanceCount));
   }
-
-  private static IResourceAggregate aggregate(double numCpus, long ramMb, long diskMb) {
-    return ResourceTestUtil.nonBackfilledAggregate(numCpus, ramMb, diskMb);
-  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/resources/ResourceBagTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/ResourceBagTest.java b/src/test/java/org/apache/aurora/scheduler/resources/ResourceBagTest.java
new file mode 100644
index 0000000..48724d5
--- /dev/null
+++ b/src/test/java/org/apache/aurora/scheduler/resources/ResourceBagTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aurora.scheduler.resources;
+
+import com.google.common.collect.ImmutableMap;
+
+import org.junit.Test;
+
+import static org.apache.aurora.scheduler.resources.ResourceBag.LARGE;
+import static org.apache.aurora.scheduler.resources.ResourceBag.MEDIUM;
+import static org.apache.aurora.scheduler.resources.ResourceBag.SMALL;
+import static org.apache.aurora.scheduler.resources.ResourceBag.XLARGE;
+import static org.apache.aurora.scheduler.resources.ResourceTestUtil.bag;
+import static org.apache.aurora.scheduler.resources.ResourceType.CPUS;
+import static org.apache.aurora.scheduler.resources.ResourceType.DISK_MB;
+import static org.apache.aurora.scheduler.resources.ResourceType.RAM_MB;
+import static org.junit.Assert.assertEquals;
+
+public class ResourceBagTest {
+  @Test
+  public void testAdd() {
+    assertEquals(LARGE, MEDIUM.add(MEDIUM));
+  }
+
+  @Test
+  public void testSubtract() {
+    assertEquals(MEDIUM, LARGE.subtract(MEDIUM));
+  }
+
+  @Test
+  public void testDivide() {
+    assertEquals(bag(16.0, 32, 16), XLARGE.divide(SMALL));
+  }
+
+  @Test
+  public void testMax() {
+    assertEquals(bag(2.0, 32, 256), bag(1.0, 32, 128).max(bag(2.0, 16, 256)));
+  }
+
+  @Test
+  public void testScale() {
+    assertEquals(bag(8.0, 128, 1024), bag(2.0, 32, 256).scale(4));
+  }
+
+  @Test
+  public void testKeyMismatch() {
+    assertEquals(
+        new ResourceBag(ImmutableMap.of(CPUS, 9.0)),
+        new ResourceBag(ImmutableMap.of(CPUS, 1.0)).add(LARGE));
+
+    assertEquals(
+        LARGE.add(new ResourceBag(ImmutableMap.of(CPUS, 1.0))),
+        new ResourceBag(ImmutableMap.of(CPUS, 9.0, RAM_MB, 16384.0, DISK_MB, 32768.0)));
+  }
+}

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
b/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
index 914e553..333db30 100644
--- a/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/resources/ResourceManagerTest.java
@@ -16,6 +16,7 @@ package org.apache.aurora.scheduler.resources;
 import java.util.EnumSet;
 import java.util.Set;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
@@ -27,10 +28,14 @@ import org.apache.mesos.Protos.Offer;
 import org.apache.mesos.Protos.Value.Scalar;
 import org.junit.Test;
 
+import static org.apache.aurora.gen.Resource.diskMb;
 import static org.apache.aurora.gen.Resource.namedPort;
 import static org.apache.aurora.gen.Resource.numCpus;
+import static org.apache.aurora.gen.Resource.ramMb;
 import static org.apache.aurora.scheduler.base.TaskTestUtil.JOB;
 import static org.apache.aurora.scheduler.base.TaskTestUtil.makeTask;
+import static org.apache.aurora.scheduler.resources.ResourceTestUtil.aggregate;
+import static org.apache.aurora.scheduler.resources.ResourceTestUtil.bag;
 import static org.apache.aurora.scheduler.resources.ResourceTestUtil.mesosRange;
 import static org.apache.aurora.scheduler.resources.ResourceTestUtil.mesosScalar;
 import static org.apache.aurora.scheduler.resources.ResourceType.CPUS;
@@ -51,6 +56,13 @@ public class ResourceManagerTest {
 
     Protos.Resource resource2 = Protos.Resource.newBuilder()
         .setType(SCALAR)
+        .setName(CPUS.getMesosName())
+        .setRevocable(Protos.Resource.RevocableInfo.getDefaultInstance())
+        .setScalar(Scalar.newBuilder().setValue(1.0).build())
+        .build();
+
+    Protos.Resource resource3 = Protos.Resource.newBuilder()
+        .setType(SCALAR)
         .setName(RAM_MB.getMesosName())
         .setScalar(Scalar.newBuilder().setValue(64).build())
         .build();
@@ -60,14 +72,20 @@ public class ResourceManagerTest {
         .setFrameworkId(Protos.FrameworkID.newBuilder().setValue("framework-id"))
         .setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-id"))
         .setHostname("hostname")
-        .addAllResources(ImmutableSet.of(resource1, resource2)).build();
+        .addAllResources(ImmutableSet.of(resource1, resource2, resource3)).build();
 
     assertEquals(
-        resource1,
-        Iterables.getOnlyElement(ResourceManager.getOfferResources(offer, CPUS)));
+        ImmutableSet.of(resource1, resource2),
+        ImmutableSet.copyOf(ResourceManager.getOfferResources(offer, CPUS)));
     assertEquals(
-        resource2,
+        resource3,
         Iterables.getOnlyElement(ResourceManager.getOfferResources(offer, RAM_MB)));
+    assertEquals(
+        ImmutableSet.of(resource1, resource3),
+        ImmutableSet.copyOf(ResourceManager.getNonRevocableOfferResources(offer)));
+    assertEquals(
+        ImmutableSet.of(resource2, resource3),
+        ImmutableSet.copyOf(ResourceManager.getRevocableOfferResources(offer)));
   }
 
   @Test
@@ -78,6 +96,11 @@ public class ResourceManagerTest {
     assertEquals(
         IResource.build(namedPort("http")),
         Iterables.getOnlyElement(ResourceManager.getTaskResources(makeTask("id", JOB), PORTS)));
+    assertEquals(
+        ImmutableSet.of(IResource.build(numCpus(1.0)), IResource.build(ramMb(1024))),
+        ImmutableSet.copyOf(ResourceManager.getTaskResources(
+            makeTask("id", JOB).getAssignedTask().getTask(),
+            EnumSet.of(CPUS, RAM_MB))));
   }
 
   @Test
@@ -98,9 +121,46 @@ public class ResourceManagerTest {
         mesosScalar(RAM_MB, 64),
         mesosRange(PORTS, 1, 3));
 
-    assertEquals(7.0, ResourceManager.quantityOf(resources, CPUS), 0.0);
-    assertEquals(64, ResourceManager.quantityOf(resources, RAM_MB), 0.0);
-    assertEquals(0.0, ResourceManager.quantityOf(resources, DISK_MB), 0.0);
-    assertEquals(2, ResourceManager.quantityOf(resources, PORTS), 0.0);
+    assertEquals(7.0, ResourceManager.quantityOfMesosResource(resources, CPUS), 0.0);
+    assertEquals(64, ResourceManager.quantityOfMesosResource(resources, RAM_MB), 0.0);
+    assertEquals(0.0, ResourceManager.quantityOfMesosResource(resources, DISK_MB), 0.0);
+    assertEquals(2, ResourceManager.quantityOfMesosResource(resources, PORTS), 0.0);
+  }
+
+  @Test
+  public void testResourceQuantity() {
+    assertEquals(
+        8.0,
+        ResourceManager.quantityOf(ImmutableSet.of(
+            IResource.build(numCpus(3.0)),
+            IResource.build(numCpus(5.0)))),
+        0.0);
+  }
+
+  @Test
+  public void testBagFromResources() {
+    assertEquals(
+        bag(2.0, 32, 64),
+        ResourceManager.bagFromResources(ImmutableSet.of(
+            IResource.build(numCpus(2.0)),
+            IResource.build(ramMb(32)),
+            IResource.build(diskMb(64)))));
+  }
+
+  @Test
+  public void testBagFromMesosResources() {
+    assertEquals(
+        new ResourceBag(ImmutableMap.of(CPUS, 3.0)),
+        ResourceManager.bagFromMesosResources(ImmutableSet.of(mesosScalar(CPUS, 3.0))));
+  }
+
+  @Test
+  public void testBagFromAggregate() {
+    assertEquals(bag(1.0, 32, 64), ResourceManager.bagFromAggregate(aggregate(1.0, 32, 64)));
+  }
+
+  @Test
+  public void testAggregateFromBag() {
+    assertEquals(aggregate(1.0, 1024, 4096), ResourceManager.aggregateFromBag(ResourceBag.SMALL));
   }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/resources/ResourceSlotTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/ResourceSlotTest.java b/src/test/java/org/apache/aurora/scheduler/resources/ResourceSlotTest.java
index 0e6a5ac..842572c 100644
--- a/src/test/java/org/apache/aurora/scheduler/resources/ResourceSlotTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/resources/ResourceSlotTest.java
@@ -56,18 +56,6 @@ public class ResourceSlotTest {
       .setRequestedPorts(ImmutableSet.of("http", "debug")));
 
   @Test
-  public void testMaxElements() {
-    ResourceSlot highRAM = new ResourceSlot(1, Amount.of(8L, Data.GB), Amount.of(10L, Data.MB),
0);
-    ResourceSlot rest = new ResourceSlot(10, Amount.of(1L, Data.MB), Amount.of(10L, Data.GB),
1);
-
-    ResourceSlot result = ResourceSlot.maxElements(highRAM, rest);
-    assertEquals(result.getNumCpus(), 10, 0.001);
-    assertEquals(result.getRam(), Amount.of(8L, Data.GB));
-    assertEquals(result.getDisk(), Amount.of(10L, Data.GB));
-    assertEquals(result.getNumPorts(), 1);
-  }
-
-  @Test
   public void testSubtract() {
     assertEquals(ONE, TWO.subtract(ONE));
     assertEquals(TWO, THREE.subtract(ONE));

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/resources/ResourceTestUtil.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/ResourceTestUtil.java b/src/test/java/org/apache/aurora/scheduler/resources/ResourceTestUtil.java
index 821c47f..e0cca4b 100644
--- a/src/test/java/org/apache/aurora/scheduler/resources/ResourceTestUtil.java
+++ b/src/test/java/org/apache/aurora/scheduler/resources/ResourceTestUtil.java
@@ -13,6 +13,7 @@
  */
 package org.apache.aurora.scheduler.resources;
 
+import java.util.Map;
 import java.util.Set;
 
 import com.google.common.base.Optional;
@@ -44,6 +45,14 @@ public final class ResourceTestUtil {
     // Utility class.
   }
 
+  public static ResourceBag bag(Map<ResourceType, Double> resources) {
+    return new ResourceBag(resources);
+  }
+
+  public static ResourceBag bag(double numCpus, long ramMb, long diskMb) {
+    return ResourceManager.bagFromAggregate(aggregate(numCpus, ramMb, diskMb));
+  }
+
   public static IResourceAggregate aggregate(double numCpus, long ramMb, long diskMb) {
     return IResourceAggregate.build(new ResourceAggregate(numCpus, ramMb, diskMb, ImmutableSet.of(
         numCpus(numCpus),
@@ -52,13 +61,6 @@ public final class ResourceTestUtil {
     )));
   }
 
-  public static IResourceAggregate nonBackfilledAggregate(double numCpus, long ramMb, long
diskMb) {
-    return IResourceAggregate.build(new ResourceAggregate()
-        .setNumCpus(numCpus)
-        .setRamMb(ramMb)
-        .setDiskMb(diskMb));
-  }
-
   public static ITaskConfig resetPorts(ITaskConfig config, Set<String> portNames) {
     TaskConfig builder = config.newBuilder()
         .setRequestedPorts(portNames);

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/resources/ResourcesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/resources/ResourcesTest.java b/src/test/java/org/apache/aurora/scheduler/resources/ResourcesTest.java
index 185338e..716769f 100644
--- a/src/test/java/org/apache/aurora/scheduler/resources/ResourcesTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/resources/ResourcesTest.java
@@ -55,7 +55,7 @@ public class ResourcesTest {
 
     assertEquals(
         new ResourceSlot(8.0, Amount.of(1024L, MB), Amount.of(0L, MB), 0),
-        Resources.from(offer).filter(Resources.REVOCABLE).slot());
+        Resources.from(offer).filter(ResourceManager.REVOCABLE).slot());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/stats/AsyncStatsModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/stats/AsyncStatsModuleTest.java b/src/test/java/org/apache/aurora/scheduler/stats/AsyncStatsModuleTest.java
index 7fcf47a..75bac6f 100644
--- a/src/test/java/org/apache/aurora/scheduler/stats/AsyncStatsModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/stats/AsyncStatsModuleTest.java
@@ -17,16 +17,18 @@ import com.google.common.collect.ImmutableList;
 
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
 import org.apache.aurora.gen.HostAttributes;
-import org.apache.aurora.gen.ResourceAggregate;
 import org.apache.aurora.scheduler.HostOffer;
 import org.apache.aurora.scheduler.offers.OfferManager;
-import org.apache.aurora.scheduler.resources.ResourceType;
+import org.apache.aurora.scheduler.resources.ResourceTestUtil;
 import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResource;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
-import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
 import org.apache.mesos.Protos;
 import org.junit.Test;
 
+import static org.apache.aurora.scheduler.resources.ResourceTestUtil.mesosScalar;
+import static org.apache.aurora.scheduler.resources.ResourceType.CPUS;
+import static org.apache.aurora.scheduler.resources.ResourceType.DISK_MB;
+import static org.apache.aurora.scheduler.resources.ResourceType.RAM_MB;
 import static org.apache.aurora.scheduler.stats.AsyncStatsModule.OfferAdapter;
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
@@ -41,8 +43,10 @@ public class AsyncStatsModuleTest extends EasyMockTest {
             .setFrameworkId(Protos.FrameworkID.newBuilder().setValue("frameworkId"))
             .setSlaveId(Protos.SlaveID.newBuilder().setValue("slaveId"))
             .setHostname("hostName")
-            .addResources(getCpuResource(true, 2.0))
-            .addResources(getCpuResource(false, 4.0))
+            .addResources(mesosScalar(CPUS, 2.0, true))
+            .addResources(mesosScalar(CPUS, 4.0, false))
+            .addResources(mesosScalar(RAM_MB, 1024))
+            .addResources(mesosScalar(DISK_MB, 2048))
             .build(),
             IHostAttributes.build(new HostAttributes()))));
 
@@ -55,21 +59,8 @@ public class AsyncStatsModuleTest extends EasyMockTest {
 
   private static MachineResource resource(boolean revocable, double cpu) {
     return new MachineResource(
-        IResourceAggregate.build(new ResourceAggregate().setNumCpus(cpu)),
+        ResourceTestUtil.bag(cpu, 1024, 2048),
         false,
         revocable);
   }
-
-  private static Protos.Resource getCpuResource(boolean revocable, double value) {
-    Protos.Resource.Builder builder = Protos.Resource.newBuilder()
-        .setName(ResourceType.CPUS.getMesosName())
-        .setType(Protos.Value.Type.SCALAR)
-        .setScalar(Protos.Value.Scalar.newBuilder().setValue(value));
-
-    if (revocable) {
-      builder.setRevocable(Protos.Resource.RevocableInfo.newBuilder());
-    }
-
-    return builder.build();
-  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java b/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
index b1c8f75..e529e67 100644
--- a/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/stats/SlotSizeCounterTest.java
@@ -21,23 +21,25 @@ import com.google.common.collect.ImmutableMap;
 
 import org.apache.aurora.common.stats.StatsProvider;
 import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.scheduler.resources.ResourceAggregates;
+import org.apache.aurora.scheduler.resources.ResourceBag;
+import org.apache.aurora.scheduler.resources.ResourceTestUtil;
 import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResource;
 import org.apache.aurora.scheduler.stats.SlotSizeCounter.MachineResourceProvider;
-import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.apache.aurora.scheduler.resources.ResourceTestUtil.aggregate;
+import static org.apache.aurora.scheduler.resources.ResourceBag.SMALL;
+import static org.apache.aurora.scheduler.resources.ResourceType.CPUS;
+import static org.apache.aurora.scheduler.resources.ResourceType.DISK_MB;
+import static org.apache.aurora.scheduler.resources.ResourceType.PORTS;
+import static org.apache.aurora.scheduler.resources.ResourceType.RAM_MB;
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
 
 public class SlotSizeCounterTest extends EasyMockTest {
+  private static final ResourceBag LARGE = SMALL.scale(4);
 
-  private static final IResourceAggregate SMALL = aggregate(1.0, 1024, 4096);
-  private static final IResourceAggregate LARGE = ResourceAggregates.scale(SMALL, 4);
-
-  private static final Map<String, IResourceAggregate> SLOT_SIZES = ImmutableMap.of(
+  private static final Map<String, ResourceBag> SLOT_SIZES = ImmutableMap.of(
       "small", SMALL,
       "large", LARGE);
 
@@ -105,7 +107,7 @@ public class SlotSizeCounterTest extends EasyMockTest {
   @Test
   public void testTinyOffers() {
     expectStatExport();
-    expectGetSlots(new MachineResource(aggregate(0.1, 1, 1), false, false));
+    expectGetSlots(new MachineResource(bag(0.1, 1, 1), false, false));
 
     control.replay();
 
@@ -124,7 +126,7 @@ public class SlotSizeCounterTest extends EasyMockTest {
   public void testStarvedResourceVector() {
     expectStatExport();
     expectGetSlots(
-        new MachineResource(aggregate(1000, 16384, 1), false, false));
+        new MachineResource(bag(1000, 16384, 1), false, false));
 
     control.replay();
 
@@ -148,11 +150,11 @@ public class SlotSizeCounterTest extends EasyMockTest {
         new MachineResource(LARGE, false, false),
         new MachineResource(LARGE, false, true),
         new MachineResource(LARGE, true, true),
-        new MachineResource(ResourceAggregates.scale(LARGE, 4), false, false),
-        new MachineResource(aggregate(1, 1, 1), false, false),
+        new MachineResource(LARGE.scale(4), false, false),
+        new MachineResource(bag(1, 1, 1), false, false),
         new MachineResource(SMALL, true, false),
         new MachineResource(SMALL, true, false),
-        new MachineResource(ResourceAggregates.scale(SMALL, 2), true, false));
+        new MachineResource(SMALL.scale(2), true, false));
 
     control.replay();
 
@@ -166,4 +168,10 @@ public class SlotSizeCounterTest extends EasyMockTest {
     assertEquals(1, largeRevocableCounter.get());
     assertEquals(1, largeDedicatedRevocableCounter.get());
   }
+
+  private static ResourceBag bag(double cpus, double ram, double disk) {
+    // Add default port count to simulate actual machine resources.
+    return ResourceTestUtil.bag(
+        ImmutableMap.of(CPUS, cpus, RAM_MB, ram, DISK_MB, disk, PORTS, 3.0));
+  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
index aeab07d..e0cf602 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/log/SnapshotStoreImplIT.java
@@ -51,7 +51,7 @@ import org.apache.aurora.gen.storage.StoredCronJob;
 import org.apache.aurora.gen.storage.StoredJobUpdateDetails;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
-import org.apache.aurora.scheduler.resources.ResourceAggregates;
+import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.storage.SnapshotStore;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.db.MigrationManager;
@@ -69,6 +69,7 @@ import org.junit.Test;
 
 import static org.apache.aurora.common.inject.Bindings.KeyFactory.PLAIN;
 import static org.apache.aurora.common.util.testing.FakeBuildInfo.generateBuildInfo;
+import static org.apache.aurora.scheduler.resources.ResourceManager.aggregateFromBag;
 import static org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import static org.apache.aurora.scheduler.storage.db.DbModule.testModuleWithWorkQueue;
 import static org.apache.aurora.scheduler.storage.db.DbUtil.createStorage;
@@ -194,7 +195,7 @@ public class SnapshotStoreImplIT {
       .setTaskConfig(TASK_CONFIG.newBuilder()));
   private static final String ROLE = "role";
   private static final IResourceAggregate QUOTA =
-      ThriftBackfill.backfillResourceAggregate(ResourceAggregates.LARGE.newBuilder());
+      ThriftBackfill.backfillResourceAggregate(aggregateFromBag(ResourceBag.LARGE).newBuilder());
   private static final IHostAttributes ATTRIBUTES = IHostAttributes.build(
       new HostAttributes("host", ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value"))))
           .setMode(MaintenanceMode.NONE)

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java b/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
index a2e2395..4f81585 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/Fixtures.java
@@ -45,11 +45,11 @@ import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.quota.QuotaCheckResult;
+import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.resources.ResourceTestUtil;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.storage.entities.IJobUpdateKey;
 import org.apache.aurora.scheduler.storage.entities.ILockKey;
-import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
 import org.apache.aurora.scheduler.storage.entities.IResult;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 
@@ -74,7 +74,7 @@ final class Fixtures {
   private static final Function<String, ResponseDetail> MESSAGE_TO_DETAIL =
       message -> new ResponseDetail().setMessage(message);
   static final String CRON_SCHEDULE = "0 * * * *";
-  static final IResourceAggregate QUOTA = ResourceTestUtil.aggregate(10.0, 1024, 2048);
+  static final ResourceBag QUOTA = ResourceTestUtil.bag(10.0, 1024, 2048);
   static final QuotaCheckResult ENOUGH_QUOTA = new QuotaCheckResult(SUFFICIENT_QUOTA);
   static final QuotaCheckResult NOT_ENOUGH_QUOTA = new QuotaCheckResult(INSUFFICIENT_QUOTA);
   static final InstanceKey INSTANCE_KEY = new InstanceKey(JOB_KEY.newBuilder(), 0);

http://git-wip-us.apache.org/repos/asf/aurora/blob/3687c6a1/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
index 3a2b3f3..2122f74 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
@@ -91,10 +91,11 @@ import org.junit.Test;
 import static org.apache.aurora.gen.ResponseCode.INVALID_REQUEST;
 import static org.apache.aurora.scheduler.base.Numbers.convertRanges;
 import static org.apache.aurora.scheduler.base.Numbers.toRanges;
-import static org.apache.aurora.scheduler.resources.ResourceAggregates.LARGE;
-import static org.apache.aurora.scheduler.resources.ResourceAggregates.MEDIUM;
-import static org.apache.aurora.scheduler.resources.ResourceAggregates.SMALL;
-import static org.apache.aurora.scheduler.resources.ResourceAggregates.XLARGE;
+import static org.apache.aurora.scheduler.resources.ResourceBag.LARGE;
+import static org.apache.aurora.scheduler.resources.ResourceBag.MEDIUM;
+import static org.apache.aurora.scheduler.resources.ResourceBag.SMALL;
+import static org.apache.aurora.scheduler.resources.ResourceBag.XLARGE;
+import static org.apache.aurora.scheduler.resources.ResourceManager.aggregateFromBag;
 import static org.apache.aurora.scheduler.thrift.Fixtures.CRON_JOB;
 import static org.apache.aurora.scheduler.thrift.Fixtures.CRON_SCHEDULE;
 import static org.apache.aurora.scheduler.thrift.Fixtures.IDENTITY;
@@ -323,11 +324,11 @@ public class ReadOnlySchedulerImplTest extends EasyMockTest {
     control.replay();
 
     GetQuotaResult expected = new GetQuotaResult()
-        .setQuota(QUOTA.newBuilder())
-        .setProdSharedConsumption(XLARGE.newBuilder())
-        .setProdDedicatedConsumption(LARGE.newBuilder())
-        .setNonProdSharedConsumption(MEDIUM.newBuilder())
-        .setNonProdDedicatedConsumption(SMALL.newBuilder());
+        .setQuota(aggregateFromBag(QUOTA).newBuilder())
+        .setProdSharedConsumption(aggregateFromBag(XLARGE).newBuilder())
+        .setProdDedicatedConsumption(aggregateFromBag(LARGE).newBuilder())
+        .setNonProdSharedConsumption(aggregateFromBag(MEDIUM).newBuilder())
+        .setNonProdDedicatedConsumption(aggregateFromBag(SMALL).newBuilder());
 
     Response response = assertOkResponse(thrift.getQuota(ROLE));
     assertEquals(expected, response.getResult().getGetQuotaResult());


Mime
View raw message