aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject incubator-aurora git commit: Add test coverage for MesosSchedulerImpl.
Date Fri, 27 Feb 2015 20:50:27 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 443f66867 -> e8a0a9fa4


Add test coverage for MesosSchedulerImpl.

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


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

Branch: refs/heads/master
Commit: e8a0a9fa432903fb73c34010d7faaa05e826b3c1
Parents: 443f668
Author: Bill Farner <wfarner@apache.org>
Authored: Fri Feb 27 12:49:27 2015 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Fri Feb 27 12:49:27 2015 -0800

----------------------------------------------------------------------
 .../scheduler/mesos/MesosSchedulerImpl.java     |  61 +++---
 .../scheduler/mesos/MesosSchedulerImplTest.java | 193 +++++++++++++------
 2 files changed, 163 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e8a0a9fa/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
index aa8aaad..f40746b 100644
--- a/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImpl.java
@@ -17,7 +17,6 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 import java.util.List;
 import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -29,7 +28,6 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.twitter.common.application.Lifecycle;
 import com.twitter.common.inject.TimedInterceptor.Timed;
-import com.twitter.common.stats.Stats;
 
 import org.apache.aurora.GuiceUtils.AllowUnchecked;
 import org.apache.aurora.scheduler.HostOffer;
@@ -39,6 +37,7 @@ import org.apache.aurora.scheduler.events.EventSink;
 import org.apache.aurora.scheduler.events.PubsubEvent.DriverDisconnected;
 import org.apache.aurora.scheduler.events.PubsubEvent.DriverRegistered;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStatusReceived;
+import org.apache.aurora.scheduler.stats.CachedCounters;
 import org.apache.aurora.scheduler.storage.AttributeStore;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.Storage.MutableStoreProvider;
@@ -65,22 +64,14 @@ import static org.apache.mesos.Protos.Offer;
  * Location for communication with mesos.
  */
 class MesosSchedulerImpl implements Scheduler {
-  private static final Logger LOG = Logger.getLogger(MesosSchedulerImpl.class.getName());
-
-  private final AtomicLong totalResourceOffers = Stats.exportLong("scheduler_resource_offers");
-  private final AtomicLong totalFailedStatusUpdates = Stats.exportLong("scheduler_status_updates");
-  private final AtomicLong totalFrameworkDisconnects =
-      Stats.exportLong("scheduler_framework_disconnects");
-  private final AtomicLong totalFrameworkReregisters =
-      Stats.exportLong("scheduler_framework_reregisters");
-  private final AtomicLong totalLostExecutors = Stats.exportLong("scheduler_lost_executors");
-
   private final List<TaskLauncher> taskLaunchers;
 
   private final Storage storage;
   private final Lifecycle lifecycle;
   private final EventSink eventSink;
   private final Executor executor;
+  private final Logger log;
+  private final CachedCounters counters;
   private volatile boolean isRegistered = false;
 
   /**
@@ -109,18 +100,22 @@ class MesosSchedulerImpl implements Scheduler {
       final Lifecycle lifecycle,
       List<TaskLauncher> taskLaunchers,
       EventSink eventSink,
-      @SchedulerExecutor Executor executor) {
+      @SchedulerExecutor Executor executor,
+      Logger log,
+      CachedCounters counters) {
 
     this.storage = requireNonNull(storage);
     this.lifecycle = requireNonNull(lifecycle);
     this.taskLaunchers = requireNonNull(taskLaunchers);
     this.eventSink = requireNonNull(eventSink);
     this.executor = requireNonNull(executor);
+    this.log = requireNonNull(log);
+    this.counters = requireNonNull(counters);
   }
 
   @Override
   public void slaveLost(SchedulerDriver schedulerDriver, SlaveID slaveId) {
-    LOG.info("Received notification of lost slave: " + slaveId);
+    log.info("Received notification of lost slave: " + slaveId);
   }
 
   @Override
@@ -129,7 +124,7 @@ class MesosSchedulerImpl implements Scheduler {
       final FrameworkID frameworkId,
       MasterInfo masterInfo) {
 
-    LOG.info("Registered with ID " + frameworkId + ", master: " + masterInfo);
+    log.info("Registered with ID " + frameworkId + ", master: " + masterInfo);
 
     storage.write(new MutateWork.NoResult.Quiet() {
       @Override
@@ -143,15 +138,15 @@ class MesosSchedulerImpl implements Scheduler {
 
   @Override
   public void disconnected(SchedulerDriver schedulerDriver) {
-    LOG.warning("Framework disconnected.");
-    totalFrameworkDisconnects.incrementAndGet();
+    log.warning("Framework disconnected.");
+    counters.get("scheduler_framework_disconnects").get();
     eventSink.post(new DriverDisconnected());
   }
 
   @Override
   public void reregistered(SchedulerDriver schedulerDriver, MasterInfo masterInfo) {
-    LOG.info("Framework re-registered with master " + masterInfo);
-    totalFrameworkReregisters.incrementAndGet();
+    log.info("Framework re-registered with master " + masterInfo);
+    counters.get("scheduler_framework_reregisters").incrementAndGet();
   }
 
   @Timed("scheduler_resource_offers")
@@ -171,10 +166,10 @@ class MesosSchedulerImpl implements Scheduler {
               IHostAttributes attributes =
                   AttributeStore.Util.mergeOffer(storeProvider.getAttributeStore(), offer);
               storeProvider.getAttributeStore().saveHostAttributes(attributes);
-              if (LOG.isLoggable(Level.FINE)) {
-                LOG.log(Level.FINE, String.format("Received offer: %s", offer));
+              if (log.isLoggable(Level.FINE)) {
+                log.log(Level.FINE, String.format("Received offer: %s", offer));
               }
-              totalResourceOffers.incrementAndGet();
+              counters.get("scheduler_resource_offers").incrementAndGet();
               for (TaskLauncher launcher : taskLaunchers) {
                 if (launcher.willUse(new HostOffer(offer, attributes))) {
                   break;
@@ -189,13 +184,13 @@ class MesosSchedulerImpl implements Scheduler {
 
   @Override
   public void offerRescinded(SchedulerDriver schedulerDriver, OfferID offerId) {
-    LOG.info("Offer rescinded: " + offerId);
+    log.info("Offer rescinded: " + offerId);
     for (TaskLauncher launcher : taskLaunchers) {
       launcher.cancelOffer(offerId);
     }
   }
 
-  private static void logStatusUpdate(TaskStatus status) {
+  private static void logStatusUpdate(Logger log, TaskStatus status) {
     StringBuilder message = new StringBuilder("Received status update for task ")
         .append(status.getTaskId().getValue())
         .append(" in state ")
@@ -209,7 +204,7 @@ class MesosSchedulerImpl implements Scheduler {
     if (status.hasMessage()) {
       message.append(": ").append(status.getMessage());
     }
-    LOG.info(message.toString());
+    log.info(message.toString());
   }
 
   private static final Function<Double, Long> SECONDS_TO_MICROS = new Function<Double,
Long>() {
@@ -223,7 +218,7 @@ class MesosSchedulerImpl implements Scheduler {
   @Timed("scheduler_status_update")
   @Override
   public void statusUpdate(SchedulerDriver driver, TaskStatus status) {
-    logStatusUpdate(status);
+    logStatusUpdate(log, status);
     eventSink.post(new TaskStatusReceived(
         status.getState(),
         Optional.fromNullable(status.getSource()),
@@ -237,7 +232,7 @@ class MesosSchedulerImpl implements Scheduler {
         }
       }
     } catch (SchedulerException e) {
-      LOG.log(Level.SEVERE, "Status update failed due to scheduler exception: " + e, e);
+      log.log(Level.SEVERE, "Status update failed due to scheduler exception: " + e, e);
       // We re-throw the exception here in an effort to NACK the status update and trigger
an
       // abort of the driver.  Previously we directly issued driver.abort(), but the re-entrancy
       // guarantees of that are uncertain (and we believe it was not working).  However,
this
@@ -246,13 +241,13 @@ class MesosSchedulerImpl implements Scheduler {
       throw e;
     }
 
-    LOG.warning("Unhandled status update " + status);
-    totalFailedStatusUpdates.incrementAndGet();
+    log.warning("Unhandled status update " + status);
+    counters.get("scheduler_status_updates").incrementAndGet();
   }
 
   @Override
   public void error(SchedulerDriver driver, String message) {
-    LOG.severe("Received error message: " + message);
+    log.severe("Received error message: " + message);
     lifecycle.shutdown();
   }
 
@@ -260,8 +255,8 @@ class MesosSchedulerImpl implements Scheduler {
   public void executorLost(SchedulerDriver schedulerDriver, ExecutorID executorID, SlaveID
slaveID,
       int status) {
 
-    LOG.info("Lost executor " + executorID);
-    totalLostExecutors.incrementAndGet();
+    log.info("Lost executor " + executorID);
+    counters.get("scheduler_lost_executors").incrementAndGet();
   }
 
   @Timed("scheduler_framework_message")
@@ -272,6 +267,6 @@ class MesosSchedulerImpl implements Scheduler {
       SlaveID slave,
       byte[] data) {
 
-    LOG.warning("Ignoring framework message.");
+    log.warning("Ignoring framework message.");
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/e8a0a9fa/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
index d621586..4ef23ea 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/MesosSchedulerImplTest.java
@@ -15,20 +15,15 @@ package org.apache.aurora.scheduler.mesos;
 
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.testing.TearDown;
 import com.google.common.util.concurrent.MoreExecutors;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.TypeLiteral;
 import com.twitter.common.application.Lifecycle;
 import com.twitter.common.base.Command;
 import com.twitter.common.testing.easymock.EasyMockTest;
@@ -44,10 +39,11 @@ import org.apache.aurora.scheduler.events.EventSink;
 import org.apache.aurora.scheduler.events.PubsubEvent.DriverDisconnected;
 import org.apache.aurora.scheduler.events.PubsubEvent.DriverRegistered;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStatusReceived;
-import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.stats.CachedCounters;
 import org.apache.aurora.scheduler.storage.Storage.StorageException;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
+import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.apache.mesos.Protos.ExecutorID;
 import org.apache.mesos.Protos.FrameworkID;
 import org.apache.mesos.Protos.MasterInfo;
@@ -114,6 +110,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       .setSource(Source.SOURCE_SLAVE)
       // Only testing data plumbing, this field with TASK_RUNNING would not normally happen,
       .setReason(Reason.REASON_COMMAND_EXECUTOR_FAILED)
+      .setMessage("message")
       .setTimestamp(1D)
       .setTaskId(TaskID.newBuilder().setValue("task-id").build())
       .build();
@@ -125,7 +122,9 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       Optional.of(1000000L)
   );
 
+  private Logger log;
   private StorageTestUtil storageUtil;
+  private Command shutdownCommand;
   private TaskLauncher systemLauncher;
   private TaskLauncher userLauncher;
   private SchedulerDriver driver;
@@ -135,26 +134,24 @@ public class MesosSchedulerImplTest extends EasyMockTest {
 
   @Before
   public void setUp() {
+    log = Logger.getAnonymousLogger();
+    log.setLevel(Level.INFO);
     storageUtil = new StorageTestUtil(this);
+    shutdownCommand = createMock(Command.class);
     final Lifecycle lifecycle =
-        new Lifecycle(createMock(Command.class), createMock(UncaughtExceptionHandler.class));
+        new Lifecycle(shutdownCommand, createMock(UncaughtExceptionHandler.class));
     systemLauncher = createMock(TaskLauncher.class);
     userLauncher = createMock(TaskLauncher.class);
     eventSink = createMock(EventSink.class);
 
-    Injector injector = Guice.createInjector(new AbstractModule() {
-      @Override
-      protected void configure() {
-        bind(Storage.class).toInstance(storageUtil.storage);
-        bind(Lifecycle.class).toInstance(lifecycle);
-        bind(new TypeLiteral<List<TaskLauncher>>() { })
-            .toInstance(Arrays.asList(systemLauncher, userLauncher));
-        bind(EventSink.class).toInstance(eventSink);
-        bind(Executor.class).annotatedWith(MesosSchedulerImpl.SchedulerExecutor.class)
-            .toInstance(MoreExecutors.sameThreadExecutor());
-      }
-    });
-    scheduler = injector.getInstance(MesosSchedulerImpl.class);
+    scheduler = new MesosSchedulerImpl(
+        storageUtil.storage,
+        lifecycle,
+        ImmutableList.of(systemLauncher, userLauncher),
+        eventSink,
+        MoreExecutors.sameThreadExecutor(),
+        log,
+        new CachedCounters(new FakeStatsProvider()));
     driver = createMock(SchedulerDriver.class);
   }
 
@@ -167,7 +164,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testNoOffers() throws Exception {
+  public void testNoOffers() {
     new RegisteredFixture() {
       @Override
       void test() {
@@ -177,10 +174,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testNoAccepts() throws Exception {
+  public void testNoAccepts() {
     new OfferFixture() {
       @Override
-      void respondToOffer() throws Exception {
+      void respondToOffer() {
         expectOfferAttributesSaved(OFFER);
         expect(systemLauncher.willUse(OFFER)).andReturn(false);
         expect(userLauncher.willUse(OFFER)).andReturn(false);
@@ -189,10 +186,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testOfferFirstAccepts() throws Exception {
+  public void testOfferFirstAccepts() {
     new OfferFixture() {
       @Override
-      void respondToOffer() throws Exception {
+      void respondToOffer() {
         expectOfferAttributesSaved(OFFER);
         expect(systemLauncher.willUse(OFFER)).andReturn(true);
       }
@@ -200,10 +197,22 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testOfferSchedulerAccepts() throws Exception {
+  public void testOfferFirstAcceptsFineLogging() {
+    log.setLevel(Level.FINE);
     new OfferFixture() {
       @Override
-      void respondToOffer() throws Exception {
+      void respondToOffer() {
+        expectOfferAttributesSaved(OFFER);
+        expect(systemLauncher.willUse(OFFER)).andReturn(true);
+      }
+    }.run();
+  }
+
+  @Test
+  public void testOfferSchedulerAccepts() {
+    new OfferFixture() {
+      @Override
+      void respondToOffer() {
         expectOfferAttributesSaved(OFFER);
         expect(systemLauncher.willUse(OFFER)).andReturn(false);
         expect(userLauncher.willUse(OFFER)).andReturn(true);
@@ -212,10 +221,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testAttributesModePreserved() throws Exception {
+  public void testAttributesModePreserved() {
     new OfferFixture() {
       @Override
-      void respondToOffer() throws Exception {
+      void respondToOffer() {
         IHostAttributes draining =
             IHostAttributes.build(OFFER.getAttributes().newBuilder().setMode(DRAINING));
         expect(storageUtil.attributeStore.getHostAttributes(OFFER.getOffer().getHostname()))
@@ -232,10 +241,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testStatusUpdateNoAccepts() throws Exception {
+  public void testStatusUpdateNoAccepts() {
     new StatusFixture() {
       @Override
-      void expectations() throws Exception {
+      void expectations() {
         eventSink.post(PUBSUB_EVENT);
         expect(systemLauncher.statusUpdate(STATUS)).andReturn(false);
         expect(userLauncher.statusUpdate(STATUS)).andReturn(false);
@@ -243,22 +252,43 @@ public class MesosSchedulerImplTest extends EasyMockTest {
     }.run();
   }
 
+  private class FirstLauncherAccepts extends StatusFixture {
+    FirstLauncherAccepts(TaskStatus status) {
+      super(status);
+    }
+
+    @Override
+    void expectations() {
+      eventSink.post(new TaskStatusReceived(
+          STATUS.getState(),
+          Optional.fromNullable(status.getSource()),
+          Optional.fromNullable(status.getReason()),
+          Optional.of(1000000L)
+      ));
+      expect(systemLauncher.statusUpdate(status)).andReturn(true);
+    }
+  }
+
   @Test
-  public void testStatusUpdateFirstAccepts() throws Exception {
-    new StatusFixture() {
-      @Override
-      void expectations() throws Exception {
-        eventSink.post(PUBSUB_EVENT);
-        expect(systemLauncher.statusUpdate(STATUS)).andReturn(true);
-      }
-    }.run();
+  public void testStatusUpdateFirstAccepts() {
+    // Test multiple variations of fields in TaskStatus to cover all branches.
+    new FirstLauncherAccepts(STATUS).run();
+    control.verify();
+    control.reset();
+    new FirstLauncherAccepts(STATUS.toBuilder().clearSource().build()).run();
+    control.verify();
+    control.reset();
+    new FirstLauncherAccepts(STATUS.toBuilder().clearReason().build()).run();
+    control.verify();
+    control.reset();
+    new FirstLauncherAccepts(STATUS.toBuilder().clearMessage().build()).run();
   }
 
   @Test
-  public void testStatusUpdateSecondAccepts() throws Exception {
+  public void testStatusUpdateSecondAccepts() {
     new StatusFixture() {
       @Override
-      void expectations() throws Exception {
+      void expectations() {
         eventSink.post(PUBSUB_EVENT);
         expect(systemLauncher.statusUpdate(STATUS)).andReturn(false);
         expect(userLauncher.statusUpdate(STATUS)).andReturn(true);
@@ -267,10 +297,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test(expected = SchedulerException.class)
-  public void testStatusUpdateFails() throws Exception {
+  public void testStatusUpdateFails() {
     new StatusFixture() {
       @Override
-      void expectations() throws Exception {
+      void expectations() {
         eventSink.post(PUBSUB_EVENT);
         expect(systemLauncher.statusUpdate(STATUS)).andReturn(false);
         expect(userLauncher.statusUpdate(STATUS)).andThrow(new StorageException("Injected."));
@@ -279,10 +309,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testMultipleOffers() throws Exception {
+  public void testMultipleOffers() {
     new RegisteredFixture() {
       @Override
-      void expectations() throws Exception {
+      void expectations() {
         expectOfferAttributesSaved(OFFER);
         expectOfferAttributesSaved(OFFER_2);
         expect(systemLauncher.willUse(OFFER)).andReturn(false);
@@ -299,10 +329,10 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testDisconnected() throws Exception {
+  public void testDisconnected() {
     new RegisteredFixture() {
       @Override
-      void expectations() throws Exception {
+      void expectations() {
         eventSink.post(new DriverDisconnected());
       }
 
@@ -314,7 +344,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   @Test
-  public void testFrameworkMessageIgnored() throws Exception {
+  public void testFrameworkMessageIgnored() {
     control.replay();
 
     scheduler.frameworkMessage(
@@ -324,6 +354,46 @@ public class MesosSchedulerImplTest extends EasyMockTest {
         "hello".getBytes(StandardCharsets.UTF_8));
   }
 
+  @Test
+  public void testSlaveLost() {
+    control.replay();
+
+    scheduler.slaveLost(driver, SLAVE_ID);
+  }
+
+  @Test
+  public void testReregistered() {
+    control.replay();
+
+    scheduler.reregistered(driver, MasterInfo.getDefaultInstance());
+  }
+
+  @Test
+  public void testOfferRescinded() {
+    systemLauncher.cancelOffer(OFFER_ID);
+    userLauncher.cancelOffer(OFFER_ID);
+
+    control.replay();
+
+    scheduler.offerRescinded(driver, OFFER_ID);
+  }
+
+  @Test
+  public void testError() {
+    shutdownCommand.execute();
+
+    control.replay();
+
+    scheduler.error(driver, "error");
+  }
+
+  @Test
+  public void testExecutorLost() {
+    control.replay();
+
+    scheduler.executorLost(driver, EXECUTOR_ID, SLAVE_ID, 1);
+  }
+
   private void expectOfferAttributesSaved(HostOffer offer) {
     expect(storageUtil.attributeStore.getHostAttributes(offer.getOffer().getHostname()))
         .andReturn(Optional.<IHostAttributes>absent());
@@ -335,7 +405,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   private abstract class RegisteredFixture {
     private final AtomicBoolean runCalled = new AtomicBoolean(false);
 
-    RegisteredFixture() throws Exception {
+    RegisteredFixture() {
       // Prevent otherwise silent noop tests that forget to call run().
       addTearDown(new TearDown() {
         @Override
@@ -345,7 +415,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       });
     }
 
-    void run() throws Exception {
+    void run() {
       runCalled.set(true);
       eventSink.post(new DriverRegistered());
       storageUtil.expectOperations();
@@ -358,7 +428,7 @@ public class MesosSchedulerImplTest extends EasyMockTest {
       test();
     }
 
-    void expectations() throws Exception {
+    void expectations() {
       // Default no-op, subclasses may override.
     }
 
@@ -366,14 +436,14 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   private abstract class OfferFixture extends RegisteredFixture {
-    OfferFixture() throws Exception {
+    OfferFixture() {
       super();
     }
 
-    abstract void respondToOffer() throws Exception;
+    abstract void respondToOffer();
 
     @Override
-    void expectations() throws Exception {
+    void expectations() {
       respondToOffer();
     }
 
@@ -384,13 +454,20 @@ public class MesosSchedulerImplTest extends EasyMockTest {
   }
 
   private abstract class StatusFixture extends RegisteredFixture {
-    StatusFixture() throws Exception {
+    protected final TaskStatus status;
+
+    StatusFixture() {
+      this(STATUS);
+    }
+
+    StatusFixture(TaskStatus status) {
       super();
+      this.status = status;
     }
 
     @Override
     void test() {
-      scheduler.statusUpdate(driver, STATUS);
+      scheduler.statusUpdate(driver, status);
     }
   }
 }


Mime
View raw message