aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Setting revocable flag on a TaskInfo.
Date Wed, 26 Aug 2015 18:52:12 GMT
Repository: aurora
Updated Branches:
  refs/heads/master d901347cf -> 3fdbc8c16


Setting revocable flag on a TaskInfo.

Reviewed at https://reviews.apache.org/r/37776/


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

Branch: refs/heads/master
Commit: 3fdbc8c163002d397b42eb0ba219c2e75aab5a3e
Parents: d901347
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Wed Aug 26 11:49:50 2015 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Wed Aug 26 11:49:50 2015 -0700

----------------------------------------------------------------------
 .../org/apache/aurora/benchmark/Offers.java     |   4 +-
 .../apache/aurora/scheduler/ResourceSlot.java   |  38 ++++---
 .../scheduler/mesos/MesosTaskFactory.java       |  10 +-
 .../aurora/scheduler/ResourceSlotTest.java      |  31 ++++--
 .../apache/aurora/scheduler/ResourcesTest.java  |  39 ++-----
 .../mesos/MesosTaskFactoryImplTest.java         | 103 ++++++++++++++-----
 .../preemptor/PreemptionVictimFilterTest.java   |   3 +-
 7 files changed, 145 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/3fdbc8c1/src/jmh/java/org/apache/aurora/benchmark/Offers.java
----------------------------------------------------------------------
diff --git a/src/jmh/java/org/apache/aurora/benchmark/Offers.java b/src/jmh/java/org/apache/aurora/benchmark/Offers.java
index 9f3ce16..28aace7 100644
--- a/src/jmh/java/org/apache/aurora/benchmark/Offers.java
+++ b/src/jmh/java/org/apache/aurora/benchmark/Offers.java
@@ -21,6 +21,7 @@ import com.twitter.common.quantity.Data;
 
 import org.apache.aurora.scheduler.HostOffer;
 import org.apache.aurora.scheduler.ResourceSlot;
+import org.apache.aurora.scheduler.TierInfo;
 import org.apache.aurora.scheduler.offers.OfferManager;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.mesos.Protos;
@@ -88,7 +89,8 @@ final class Offers {
       int id = 0;
       for (IHostAttributes attributes : hostAttributes) {
         Protos.Offer offer = Protos.Offer.newBuilder()
-            .addAllResources(new ResourceSlot(cpu, ram, disk, ports).toResourceList())
+            .addAllResources(new ResourceSlot(cpu, ram, disk, ports)
+                .toResourceList(new TierInfo(false)))
             .setId(Protos.OfferID.newBuilder().setValue(String.format(OFFER_ID_FORMAT, id++)))
             .setFrameworkId(Protos.FrameworkID.newBuilder().setValue(FRAMEWORK_ID))
             .setSlaveId(Protos.SlaveID.newBuilder().setValue(attributes.getSlaveId()))

http://git-wip-us.apache.org/repos/asf/aurora/blob/3fdbc8c1/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java b/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
index e5953bb..b0e20ce 100644
--- a/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
+++ b/src/main/java/org/apache/aurora/scheduler/ResourceSlot.java
@@ -100,17 +100,18 @@ public final class ResourceSlot {
   }
 
   /**
-   * Adapts this slot object to a list of mesos resources.
+   * Adapts this slot object to a list of Mesos resources.
    *
    * @param selectedPorts The ports selected, to be applied as concrete task ranges.
+   * @param tierInfo Task tier info.
    * @return Mesos resources.
    */
-  public List<Protos.Resource> toResourceList(Set<Integer> selectedPorts) {
+  public List<Protos.Resource> toResourceList(Set<Integer> selectedPorts, TierInfo
tierInfo) {
     ImmutableList.Builder<Protos.Resource> resourceBuilder =
         ImmutableList.<Protos.Resource>builder()
-            .add(makeMesosResource(CPUS, numCpus))
-            .add(makeMesosResource(DISK_MB, disk.as(Data.MB)))
-            .add(makeMesosResource(RAM_MB, ram.as(Data.MB)));
+            .add(makeMesosResource(CPUS, numCpus, tierInfo.isRevocable()))
+            .add(makeMesosResource(DISK_MB, disk.as(Data.MB), false))
+            .add(makeMesosResource(RAM_MB, ram.as(Data.MB), false));
     if (!selectedPorts.isEmpty()) {
       resourceBuilder.add(makeMesosRangeResource(PORTS, selectedPorts));
     }
@@ -119,13 +120,14 @@ public final class ResourceSlot {
   }
 
   /**
-   * Convenience method for adapting to mesos resources without applying a port range.
+   * Convenience method for adapting to Mesos resources without applying a port range.
    *
-   * @see {@link #toResourceList(java.util.Set)}
+   * @see {@link #toResourceList(java.util.Set, TierInfo)}
+   * @param tierInfo Task tier info.
    * @return Mesos resources.
    */
-  public List<Protos.Resource> toResourceList() {
-    return toResourceList(ImmutableSet.of());
+  public List<Protos.Resource> toResourceList(TierInfo tierInfo) {
+    return toResourceList(ImmutableSet.of(), tierInfo);
   }
 
   /**
@@ -167,15 +169,25 @@ public final class ResourceSlot {
    *
    * @param resourceType Resource type.
    * @param value Value for the resource.
+   * @param revocable Flag indicating if this resource is revocable.
    * @return A mesos resource.
    */
   @VisibleForTesting
-  static Protos.Resource makeMesosResource(ResourceType resourceType, double value) {
-    return Protos.Resource.newBuilder()
+  static Protos.Resource makeMesosResource(
+      ResourceType resourceType,
+      double value,
+      boolean revocable) {
+
+    Protos.Resource.Builder builder = Protos.Resource.newBuilder()
         .setName(resourceType.getName())
         .setType(Protos.Value.Type.SCALAR)
-        .setScalar(Protos.Value.Scalar.newBuilder().setValue(value))
-        .build();
+        .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/3fdbc8c1/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
index ff6eb98..ddf51ef 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosTaskFactory.java
@@ -30,6 +30,7 @@ import com.twitter.common.quantity.Data;
 import org.apache.aurora.Protobufs;
 import org.apache.aurora.codec.ThriftBinaryCodec;
 import org.apache.aurora.scheduler.ResourceSlot;
+import org.apache.aurora.scheduler.TierManager;
 import org.apache.aurora.scheduler.base.CommandUtil;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.SchedulerException;
@@ -79,10 +80,12 @@ public interface MesosTaskFactory {
     static final String EXECUTOR_NAME = "aurora.task";
 
     private final ExecutorSettings executorSettings;
+    private final TierManager tierManager;
 
     @Inject
-    MesosTaskFactoryImpl(ExecutorSettings executorSettings) {
+    MesosTaskFactoryImpl(ExecutorSettings executorSettings, TierManager tierManager) {
       this.executorSettings = requireNonNull(executorSettings);
+      this.tierManager = requireNonNull(tierManager);
     }
 
     @VisibleForTesting
@@ -137,7 +140,8 @@ public interface MesosTaskFactory {
       List<Resource> resources = resourceSlot.toResourceList(
           task.isSetAssignedPorts()
               ? ImmutableSet.copyOf(task.getAssignedPorts().values())
-              : ImmutableSet.of());
+              : ImmutableSet.of(),
+          tierManager.getTier(task.getTask()));
 
       if (LOG.isLoggable(Level.FINE)) {
         LOG.fine("Setting task resources to "
@@ -223,7 +227,7 @@ public interface MesosTaskFactory {
           .setExecutorId(getExecutorId(task.getTaskId()))
           .setName(EXECUTOR_NAME)
           .setSource(getInstanceSourceName(config, task.getInstanceId()))
-          .addAllResources(RESOURCES_EPSILON.toResourceList());
+          .addAllResources(RESOURCES_EPSILON.toResourceList(tierManager.getTier(config)));
     }
 
     private void configureContainerVolumes(ContainerInfo.Builder containerBuilder) {

http://git-wip-us.apache.org/repos/asf/aurora/blob/3fdbc8c1/src/test/java/org/apache/aurora/scheduler/ResourceSlotTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/ResourceSlotTest.java b/src/test/java/org/apache/aurora/scheduler/ResourceSlotTest.java
index 50e7fc9..cab50bc 100644
--- a/src/test/java/org/apache/aurora/scheduler/ResourceSlotTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/ResourceSlotTest.java
@@ -101,16 +101,29 @@ public class ResourceSlotTest {
   }
 
   @Test
-  public void testToResourceList() {
+  public void testToResourceListNoRevocable() {
     ResourceSlot resources = ResourceSlot.from(TASK);
     Set<Integer> ports = ImmutableSet.of(80, 443);
     assertEquals(
         ImmutableSet.of(
-            makeMesosResource(CPUS, TASK.getNumCpus()),
-            makeMesosResource(RAM_MB, TASK.getRamMb()),
-            makeMesosResource(DISK_MB, TASK.getDiskMb()),
+            makeMesosResource(CPUS, TASK.getNumCpus(), false),
+            makeMesosResource(RAM_MB, TASK.getRamMb(), false),
+            makeMesosResource(DISK_MB, TASK.getDiskMb(), false),
             makeMesosRangeResource(PORTS, ports)),
-        ImmutableSet.copyOf(resources.toResourceList(ports)));
+        ImmutableSet.copyOf(resources.toResourceList(ports, new TierInfo(false))));
+  }
+
+  @Test
+  public void testToResourceListRevocable() {
+    ResourceSlot resources = ResourceSlot.from(TASK);
+    Set<Integer> ports = ImmutableSet.of(80, 443);
+    assertEquals(
+        ImmutableSet.of(
+            makeMesosResource(CPUS, TASK.getNumCpus(), true),
+            makeMesosResource(RAM_MB, TASK.getRamMb(), false),
+            makeMesosResource(DISK_MB, TASK.getDiskMb(), false),
+            makeMesosRangeResource(PORTS, ports)),
+        ImmutableSet.copyOf(resources.toResourceList(ports, new TierInfo(true))));
   }
 
   @Test
@@ -118,10 +131,10 @@ public class ResourceSlotTest {
     ResourceSlot resources = ResourceSlot.from(TASK);
     assertEquals(
         ImmutableSet.of(
-            makeMesosResource(CPUS, TASK.getNumCpus()),
-            makeMesosResource(RAM_MB, TASK.getRamMb()),
-            makeMesosResource(DISK_MB, TASK.getDiskMb())),
-        ImmutableSet.copyOf(resources.toResourceList(ImmutableSet.of())));
+            makeMesosResource(CPUS, TASK.getNumCpus(), true),
+            makeMesosResource(RAM_MB, TASK.getRamMb(), false),
+            makeMesosResource(DISK_MB, TASK.getDiskMb(), false)),
+        ImmutableSet.copyOf(resources.toResourceList(new TierInfo(true))));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/aurora/blob/3fdbc8c1/src/test/java/org/apache/aurora/scheduler/ResourcesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/ResourcesTest.java b/src/test/java/org/apache/aurora/scheduler/ResourcesTest.java
index c48d096..38d9abf 100644
--- a/src/test/java/org/apache/aurora/scheduler/ResourcesTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/ResourcesTest.java
@@ -29,12 +29,12 @@ import org.junit.Test;
 
 import static com.twitter.common.quantity.Data.MB;
 
+import static org.apache.aurora.scheduler.ResourceSlot.makeMesosResource;
 import static org.apache.aurora.scheduler.ResourceType.CPUS;
 import static org.apache.aurora.scheduler.ResourceType.DISK_MB;
 import static org.apache.aurora.scheduler.ResourceType.PORTS;
 import static org.apache.aurora.scheduler.ResourceType.RAM_MB;
 import static org.apache.mesos.Protos.Value.Type.RANGES;
-import static org.apache.mesos.Protos.Value.Type.SCALAR;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -93,9 +93,9 @@ public class ResourcesTest {
   @Test
   public void testGetSlot() {
     ImmutableList<Resource> resources = ImmutableList.<Resource>builder()
-        .add(createCpuResource(8.0, false))
-        .add(createMemResource(1024, RAM_MB))
-        .add(createMemResource(2048, DISK_MB))
+        .add(makeMesosResource(CPUS, 8.0, false))
+        .add(makeMesosResource(RAM_MB, 1024, false))
+        .add(makeMesosResource(DISK_MB, 2048, false))
         .add(createPortRange(Pair.of(1, 10)))
         .build();
 
@@ -112,8 +112,8 @@ public class ResourcesTest {
   @Test
   public void testFilter() {
     ImmutableList<Resource> resources = ImmutableList.<Resource>builder()
-        .add(createCpuResource(8.0, true))
-        .add(createMemResource(1024, RAM_MB))
+        .add(makeMesosResource(CPUS, 8.0, true))
+        .add(makeMesosResource(RAM_MB, 1024, false))
         .build();
 
     assertEquals(
@@ -124,9 +124,9 @@ public class ResourcesTest {
   @Test
   public void testFilterByTier() {
     ImmutableList<Resource> resources = ImmutableList.<Resource>builder()
-        .add(createCpuResource(8.0, true))
-        .add(createCpuResource(8.0, false))
-        .add(createMemResource(1024, RAM_MB))
+        .add(makeMesosResource(CPUS, 8.0, true))
+        .add(makeMesosResource(CPUS, 8.0, false))
+        .add(makeMesosResource(RAM_MB, 1024, false))
         .build();
 
     assertEquals(
@@ -160,27 +160,6 @@ public class ResourcesTest {
         .build();
   }
 
-  private static Resource createCpuResource(double cpus, boolean revocable) {
-    Protos.Resource.Builder builder = Resource.newBuilder()
-        .setName(CPUS.getName())
-        .setType(SCALAR)
-        .setScalar(Protos.Value.Scalar.newBuilder().setValue(cpus));
-
-    if (revocable) {
-      builder.setRevocable(Resource.RevocableInfo.newBuilder().build());
-    }
-
-    return builder.build();
-  }
-
-  private static Resource createMemResource(long mem, ResourceType resourceType) {
-    return Resource.newBuilder()
-        .setName(resourceType.getName())
-        .setType(SCALAR)
-        .setScalar(Protos.Value.Scalar.newBuilder().setValue(mem))
-        .build();
-  }
-
   private static Protos.Offer createOffer(Resource resource) {
     return createOffer(ImmutableList.of(resource));
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/3fdbc8c1/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
b/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
index 02fe964..b171177 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosTaskFactoryImplTest.java
@@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.twitter.common.quantity.Data;
+import com.twitter.common.testing.easymock.EasyMockTest;
 
 import org.apache.aurora.gen.AssignedTask;
 import org.apache.aurora.gen.Container;
@@ -30,6 +31,8 @@ import org.apache.aurora.gen.TaskConfig;
 import org.apache.aurora.gen.Volume;
 import org.apache.aurora.scheduler.ResourceSlot;
 import org.apache.aurora.scheduler.Resources;
+import org.apache.aurora.scheduler.TierInfo;
+import org.apache.aurora.scheduler.TierManager;
 import org.apache.aurora.scheduler.mesos.MesosTaskFactory.MesosTaskFactoryImpl;
 import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
 import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
@@ -39,6 +42,7 @@ import org.apache.mesos.Protos.CommandInfo.URI;
 import org.apache.mesos.Protos.ContainerInfo.DockerInfo;
 import org.apache.mesos.Protos.ExecutorInfo;
 import org.apache.mesos.Protos.Parameter;
+import org.apache.mesos.Protos.Resource;
 import org.apache.mesos.Protos.SlaveID;
 import org.apache.mesos.Protos.TaskInfo;
 import org.junit.Before;
@@ -48,26 +52,29 @@ import static org.apache.aurora.scheduler.ResourceSlot.MIN_THERMOS_RESOURCES;
 import static org.apache.aurora.scheduler.mesos.MesosTaskFactory.MesosTaskFactoryImpl.RESOURCES_EPSILON;
 import static org.apache.aurora.scheduler.mesos.TaskExecutors.NO_OVERHEAD_EXECUTOR;
 import static org.apache.aurora.scheduler.mesos.TaskExecutors.SOME_OVERHEAD_EXECUTOR;
+import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-public class MesosTaskFactoryImplTest {
+public class MesosTaskFactoryImplTest extends EasyMockTest {
 
   private static final String EXECUTOR_WRAPPER_PATH = "/fake/executor_wrapper.sh";
+  private static final ITaskConfig TASK_CONFIG = ITaskConfig.build(new TaskConfig()
+      .setJob(new JobKey("role", "environment", "job-name"))
+      .setOwner(new Identity("role", "user"))
+      .setEnvironment("environment")
+      .setJobName("job-name")
+      .setDiskMb(10)
+      .setRamMb(100)
+      .setNumCpus(5)
+      .setContainer(Container.mesos(new MesosContainer()))
+      .setRequestedPorts(ImmutableSet.of("http")));
+  private static final TierInfo DEFAULT_TIER = new TierInfo(false);
   private static final IAssignedTask TASK = IAssignedTask.build(new AssignedTask()
       .setInstanceId(2)
       .setTaskId("task-id")
       .setAssignedPorts(ImmutableMap.of("http", 80))
-      .setTask(new TaskConfig()
-          .setJob(new JobKey("role", "environment", "job-name"))
-          .setOwner(new Identity("role", "user"))
-          .setEnvironment("environment")
-          .setJobName("job-name")
-          .setDiskMb(10)
-          .setRamMb(100)
-          .setNumCpus(5)
-          .setContainer(Container.mesos(new MesosContainer()))
-          .setRequestedPorts(ImmutableSet.of("http"))));
+      .setTask(TASK_CONFIG.newBuilder()));
   private static final IAssignedTask TASK_WITH_DOCKER = IAssignedTask.build(TASK.newBuilder()
       .setTask(
           new TaskConfig(TASK.getTask().newBuilder())
@@ -84,12 +91,13 @@ public class MesosTaskFactoryImplTest {
 
   private MesosTaskFactory taskFactory;
   private ExecutorSettings config;
+  private TierManager tierManager;
 
   private static final ExecutorInfo DEFAULT_EXECUTOR = ExecutorInfo.newBuilder()
       .setExecutorId(MesosTaskFactoryImpl.getExecutorId(TASK.getTaskId()))
       .setName(MesosTaskFactoryImpl.EXECUTOR_NAME)
       .setSource(MesosTaskFactoryImpl.getInstanceSourceName(TASK.getTask(), TASK.getInstanceId()))
-      .addAllResources(RESOURCES_EPSILON.toResourceList())
+      .addAllResources(RESOURCES_EPSILON.toResourceList(DEFAULT_TIER))
       .setCommand(CommandInfo.newBuilder()
           .setValue("./executor.pex")
           .addUris(URI.newBuilder().setValue(NO_OVERHEAD_EXECUTOR.getExecutorPath())
@@ -108,24 +116,47 @@ public class MesosTaskFactoryImplTest {
   @Before
   public void setUp() {
     config = TaskExecutors.SOME_OVERHEAD_EXECUTOR;
+    tierManager = createMock(TierManager.class);
   }
 
   @Test
   public void testExecutorInfoUnchanged() {
-    taskFactory = new MesosTaskFactoryImpl(config);
+    expect(tierManager.getTier(TASK_CONFIG)).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
     TaskInfo task = taskFactory.createFrom(TASK, SLAVE);
     assertEquals(DEFAULT_EXECUTOR, task.getExecutor());
     checkTaskResources(TASK.getTask(), task);
   }
 
   @Test
+  public void testTaskInfoRevocable() {
+    expect(tierManager.getTier(TASK_CONFIG)).andReturn(new TierInfo(true)).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
+    TaskInfo task = taskFactory.createFrom(TASK, SLAVE);
+    checkTaskResources(TASK.getTask(), task);
+    assertTrue(task.getExecutor().getResourcesList().stream().anyMatch(Resource::hasRevocable));
+    assertTrue(task.getResourcesList().stream().anyMatch(Resource::hasRevocable));
+  }
+
+  @Test
   public void testCreateFromPortsUnset() {
-    taskFactory = new MesosTaskFactoryImpl(config);
-    AssignedTask assignedTask = TASK.newBuilder();
-    assignedTask.getTask().unsetRequestedPorts();
-    assignedTask.unsetAssignedPorts();
-    TaskInfo task = taskFactory.createFrom(IAssignedTask.build(assignedTask), SLAVE);
-    checkTaskResources(ITaskConfig.build(assignedTask.getTask()), task);
+    AssignedTask builder = TASK.newBuilder();
+    builder.getTask().unsetRequestedPorts();
+    builder.unsetAssignedPorts();
+    IAssignedTask assignedTask = IAssignedTask.build(builder);
+    expect(tierManager.getTier(assignedTask.getTask())).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
+    TaskInfo task = taskFactory.createFrom(IAssignedTask.build(builder), SLAVE);
+    checkTaskResources(ITaskConfig.build(builder.getTask()), task);
   }
 
   @Test
@@ -133,7 +164,11 @@ public class MesosTaskFactoryImplTest {
     // Here the ram required for the executor is greater than the sum of task resources
     // + executor overhead. We need to ensure we allocate a non-zero amount of ram in this
case.
     config = NO_OVERHEAD_EXECUTOR;
-    taskFactory = new MesosTaskFactoryImpl(config);
+    expect(tierManager.getTier(TASK_CONFIG)).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
     TaskInfo task = taskFactory.createFrom(TASK, SLAVE);
     assertEquals(DEFAULT_EXECUTOR, task.getExecutor());
 
@@ -149,8 +184,6 @@ public class MesosTaskFactoryImplTest {
     // executor.
 
     config = NO_OVERHEAD_EXECUTOR;
-    taskFactory = new MesosTaskFactoryImpl(config);
-
     AssignedTask builder = TASK.newBuilder();
     builder.getTask()
         .setNumCpus(0.001)
@@ -159,6 +192,10 @@ public class MesosTaskFactoryImplTest {
         .setRequestedPorts(ImmutableSet.of());
     IAssignedTask assignedTask =
         IAssignedTask.build(builder.setAssignedPorts(ImmutableMap.of()));
+    expect(tierManager.getTier(assignedTask.getTask())).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
 
     assertEquals(
         MIN_THERMOS_RESOURCES,
@@ -177,7 +214,11 @@ public class MesosTaskFactoryImplTest {
 
   private TaskInfo getDockerTaskInfo(IAssignedTask task) {
     config = TaskExecutors.SOME_OVERHEAD_EXECUTOR;
-    taskFactory = new MesosTaskFactoryImpl(config);
+    expect(tierManager.getTier(task.getTask())).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
     return taskFactory.createFrom(task, SLAVE);
   }
 
@@ -198,6 +239,8 @@ public class MesosTaskFactoryImplTest {
 
   @Test(expected = NullPointerException.class)
   public void testInvalidExecutorSettings() {
+    control.replay();
+
     ExecutorSettings.newBuilder()
         .setExecutorPath(null)
         .setThermosObserverRoot("")
@@ -212,7 +255,11 @@ public class MesosTaskFactoryImplTest {
         .setThermosObserverRoot("/var/run/thermos")
         .setExecutorOverhead(SOME_OVERHEAD_EXECUTOR.getExecutorOverhead())
         .build();
-    taskFactory = new MesosTaskFactoryImpl(config);
+    expect(tierManager.getTier(TASK_CONFIG)).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
     TaskInfo taskInfo = taskFactory.createFrom(TASK, SLAVE);
     assertEquals(EXECUTOR_WITH_WRAPPER, taskInfo.getExecutor());
   }
@@ -226,7 +273,11 @@ public class MesosTaskFactoryImplTest {
         .setExecutorOverhead(SOME_OVERHEAD_EXECUTOR.getExecutorOverhead())
         .setGlobalContainerMounts(ImmutableList.of(new Volume("/container", "/host", Mode.RO)))
         .build();
-    taskFactory = new MesosTaskFactoryImpl(config);
+    expect(tierManager.getTier(TASK_WITH_DOCKER.getTask())).andReturn(DEFAULT_TIER).times(2);
+    taskFactory = new MesosTaskFactoryImpl(config, tierManager);
+
+    control.replay();
+
     TaskInfo taskInfo = taskFactory.createFrom(TASK_WITH_DOCKER, SLAVE);
     Protos.Volume expected = Protos.Volume.newBuilder()
         .setHostPath("/host")
@@ -242,7 +293,7 @@ public class MesosTaskFactoryImplTest {
     return taskResources.slot().add(executorResources.slot());
   }
 
-  private static Resources fromResourceList(Iterable<Protos.Resource> resources) {
+  private static Resources fromResourceList(Iterable<Resource> resources) {
     return Resources.from(Protos.Offer.newBuilder()
         .setId(Protos.OfferID.newBuilder().setValue("ignored"))
         .setFrameworkId(Protos.FrameworkID.newBuilder().setValue("ignored"))

http://git-wip-us.apache.org/repos/asf/aurora/blob/3fdbc8c1/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
index 8a1599a..ca2ee0d 100644
--- a/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/preemptor/PreemptionVictimFilterTest.java
@@ -503,7 +503,8 @@ public class PreemptionVictimFilterTest extends EasyMockTest {
       int numPorts,
       boolean revocable) {
 
-    List<Resource> resources = new ResourceSlot(cpu, ram, disk, numPorts).toResourceList();
+    List<Resource> resources =
+        new ResourceSlot(cpu, ram, disk, numPorts).toResourceList(new TierInfo(false));
     if (revocable) {
       resources = ImmutableList.<Resource>builder()
           .addAll(FluentIterable.from(resources)


Mime
View raw message