aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject [1/5] aurora git commit: Remove the internal SQL database
Date Mon, 13 Nov 2017 21:22:20 GMT
Repository: aurora
Updated Branches:
  refs/heads/master e0624b27b -> 942760466


http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java b/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
deleted file mode 100644
index 55b9a8b..0000000
--- a/src/test/java/org/apache/aurora/scheduler/async/GatingDelayExecutorTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * 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.async;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ScheduledExecutorService;
-
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-import org.apache.aurora.common.quantity.Amount;
-import org.apache.aurora.common.quantity.Time;
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.easymock.EasyMock;
-import org.easymock.IExpectationSetters;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.easymock.EasyMock.expectLastCall;
-import static org.junit.Assert.assertEquals;
-
-public class GatingDelayExecutorTest extends EasyMockTest {
-
-  private static final Amount<Long, Time> ONE_SECOND = Amount.of(1L, Time.SECONDS);
-
-  private ScheduledExecutorService gatedExecutor;
-  private Runnable runnable;
-  private GatingDelayExecutor gatingExecutor;
-
-  @Before
-  public void setUp() {
-    gatedExecutor = createMock(ScheduledExecutorService.class);
-    runnable = createMock(Runnable.class);
-    gatingExecutor = new GatingDelayExecutor(gatedExecutor);
-  }
-
-  @Test
-  public void testGateOpen() {
-    gatedExecutor.execute(runnable);
-
-    control.replay();
-
-    // The gate was not closed, so the work is executed immediately.
-    gatingExecutor.execute(runnable);
-  }
-
-  private IExpectationSetters<?> invokeWorkWhenSubmitted() {
-    return expectLastCall().andAnswer(() -> {
-      ((Runnable) EasyMock.getCurrentArguments()[0]).run();
-      return null;
-    });
-  }
-
-  @Test
-  public void testGateIsThreadSpecific() throws InterruptedException {
-    gatedExecutor.execute(runnable);
-
-    control.replay();
-
-    CountDownLatch gateClosed = new CountDownLatch(1);
-    CountDownLatch unblock = new CountDownLatch(1);
-    Runnable closer = () -> gatingExecutor.closeDuring(() -> {
-      gateClosed.countDown();
-      try {
-        unblock.await();
-      } catch (InterruptedException e) {
-        throw Throwables.propagate(e);
-      }
-      return "hi";
-    });
-    new ThreadFactoryBuilder()
-        .setDaemon(true)
-        .setNameFormat("GateTest")
-        .build()
-        .newThread(closer)
-        .start();
-
-    gateClosed.await();
-    gatingExecutor.execute(runnable);
-    assertQueueSize(0);
-    unblock.countDown();
-  }
-
-  private void assertQueueSize(int size) {
-    assertEquals(size, gatingExecutor.getQueueSize());
-  }
-
-  @Test
-  public void testReentrantClose() {
-    gatedExecutor.execute(runnable);
-    expectLastCall().times(3);
-
-    control.replay();
-
-    gatingExecutor.execute(runnable);
-    assertQueueSize(0);
-
-    String result = gatingExecutor.closeDuring(() -> {
-      gatingExecutor.execute(runnable);
-      assertQueueSize(1);
-
-      String result1 = gatingExecutor.closeDuring(() -> {
-        gatingExecutor.execute(runnable);
-        assertQueueSize(2);
-        return "hello";
-      });
-      assertEquals("hello", result1);
-
-      return "hi";
-    });
-    assertEquals("hi", result);
-    assertQueueSize(0);
-  }
-
-  @Test
-  public void testExecute() {
-    gatedExecutor.execute(runnable);
-    invokeWorkWhenSubmitted();
-    runnable.run();
-    expectLastCall();
-
-    control.replay();
-
-    gatingExecutor.execute(runnable);
-  }
-
-  @Test
-  public void testExecuteAfterDelay() {
-    gatedExecutor.schedule(
-        runnable,
-        ONE_SECOND.getValue().longValue(),
-        ONE_SECOND.getUnit().getTimeUnit());
-    invokeWorkWhenSubmitted();
-    runnable.run();
-
-    control.replay();
-
-    gatingExecutor.execute(runnable, ONE_SECOND);
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java b/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java
deleted file mode 100644
index b8a419c..0000000
--- a/src/test/java/org/apache/aurora/scheduler/http/H2ConsoleModuleIT.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.http;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-
-import com.google.inject.Module;
-import com.sun.jersey.api.client.ClientResponse;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class H2ConsoleModuleIT extends AbstractJettyTest {
-  @Override
-  protected Module getChildServletModule() {
-    return new H2ConsoleModule(true);
-  }
-
-  @Test
-  public void testConsoleBinding() {
-    replayAndStart();
-    ClientResponse response = getRequestBuilder(H2ConsoleModule.H2_PATH + "/")
-        .post(ClientResponse.class);
-    assertEquals(ClientResponse.Status.OK.getStatusCode(), response.getStatus());
-    assertEquals(MediaType.TEXT_HTML, response.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java b/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
index be91940..d3c7ac9 100644
--- a/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/http/api/security/HttpSecurityIT.java
@@ -31,7 +31,6 @@ import com.google.inject.Module;
 import com.google.inject.name.Named;
 import com.google.inject.name.Names;
 import com.google.inject.util.Modules;
-import com.sun.jersey.api.client.ClientResponse;
 
 import org.apache.aurora.gen.AuroraAdmin;
 import org.apache.aurora.gen.JobKey;
@@ -39,18 +38,15 @@ import org.apache.aurora.gen.Response;
 import org.apache.aurora.gen.ResponseCode;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.http.AbstractJettyTest;
-import org.apache.aurora.scheduler.http.H2ConsoleModule;
 import org.apache.aurora.scheduler.http.api.ApiModule;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
 import org.apache.aurora.scheduler.thrift.aop.AnnotatedAuroraAdmin;
 import org.apache.aurora.scheduler.thrift.aop.MockDecoratedThrift;
-import org.apache.http.HttpResponse;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.Credentials;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.shiro.authc.credential.CredentialsMatcher;
@@ -66,8 +62,6 @@ import org.easymock.IExpectationSetters;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.apache.aurora.scheduler.http.H2ConsoleModule.H2_PATH;
-import static org.apache.aurora.scheduler.http.H2ConsoleModule.H2_PERM;
 import static org.apache.aurora.scheduler.http.api.ApiModule.API_PATH;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
@@ -89,8 +83,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
       new UsernamePasswordCredentials("backupsvc", "s3cret!!1");
   private static final UsernamePasswordCredentials DEPLOY_SERVICE =
       new UsernamePasswordCredentials("deploysvc", "0_0-x_0");
-  private static final UsernamePasswordCredentials H2_USER =
-      new UsernamePasswordCredentials("dbuser", "pwd");
 
   private static final UsernamePasswordCredentials INCORRECT =
       new UsernamePasswordCredentials("root", "wrong");
@@ -110,7 +102,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
   private static final String ENG_ROLE = "eng";
   private static final String BACKUP_ROLE = "backup";
   private static final String DEPLOY_ROLE = "deploy";
-  private static final String H2_ROLE = "h2access";
   private static final Named SHIRO_AFTER_AUTH_FILTER_ANNOTATION = Names.named("shiro_post_filter");
 
   private Ini ini;
@@ -133,7 +124,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
     users.put(
         DEPLOY_SERVICE.getUserName(),
         COMMA_JOINER.join(DEPLOY_SERVICE.getPassword(), DEPLOY_ROLE));
-    users.put(H2_USER.getUserName(), COMMA_JOINER.join(H2_USER.getPassword(), H2_ROLE));
 
     Ini.Section roles = ini.addSection(IniRealm.ROLES_SECTION_NAME);
     roles.put(ADMIN_ROLE, "*");
@@ -147,7 +137,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
             + ADS_STAGING_JOB.getEnvironment()
             + ":"
             + ADS_STAGING_JOB.getName());
-    roles.put(H2_ROLE, H2_PERM);
 
     auroraAdmin = createMock(AnnotatedAuroraAdmin.class);
     shiroAfterAuthFilter = createMock(Filter.class);
@@ -157,7 +146,6 @@ public class HttpSecurityIT extends AbstractJettyTest {
   protected Module getChildServletModule() {
     return Modules.combine(
         new ApiModule(new ApiModule.Options()),
-        new H2ConsoleModule(true),
         new HttpSecurityModule(
             new IniShiroRealmModule(ini, credentialsMatcher),
             Key.get(Filter.class, SHIRO_AFTER_AUTH_FILTER_ANNOTATION)),
@@ -317,40 +305,4 @@ public class HttpSecurityIT extends AbstractJettyTest {
 
     assertEquals(OK, getAuthenticatedClient(BACKUP_SERVICE).listBackups());
   }
-
-  private HttpResponse callH2Console(Credentials credentials) throws Exception {
-    DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
-
-    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-    credentialsProvider.setCredentials(AuthScope.ANY, credentials);
-    defaultHttpClient.setCredentialsProvider(credentialsProvider);
-    return defaultHttpClient.execute(new HttpPost(formatUrl(H2_PATH + "/")));
-  }
-
-  @Test
-  public void testH2ConsoleUser() throws Exception {
-    replayAndStart();
-
-    assertEquals(
-        ClientResponse.Status.OK.getStatusCode(),
-        callH2Console(H2_USER).getStatusLine().getStatusCode());
-  }
-
-  @Test
-  public void testH2ConsoleAdmin() throws Exception {
-    replayAndStart();
-
-    assertEquals(
-        ClientResponse.Status.OK.getStatusCode(),
-        callH2Console(ROOT).getStatusLine().getStatusCode());
-  }
-
-  @Test
-  public void testH2ConsoleUnauthorized() throws Exception {
-    replayAndStart();
-
-    assertEquals(
-        ClientResponse.Status.UNAUTHORIZED.getStatusCode(),
-        callH2Console(UNPRIVILEGED).getStatusLine().getStatusCode());
-  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java b/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
index 3b6b539..6b18296 100644
--- a/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/offers/OfferManagerImplTest.java
@@ -14,6 +14,7 @@
 package org.apache.aurora.scheduler.offers;
 
 import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
@@ -27,7 +28,6 @@ import org.apache.aurora.common.util.testing.FakeTicker;
 import org.apache.aurora.gen.HostAttributes;
 import org.apache.aurora.gen.MaintenanceMode;
 import org.apache.aurora.scheduler.HostOffer;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.TaskGroupKey;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent.DriverDisconnected;
@@ -538,8 +538,8 @@ public class OfferManagerImplTest extends EasyMockTest {
         RETURN_DELAY,
         Long.MAX_VALUE,
         FAKE_TICKER);
-    DelayExecutor executorMock = createMock(DelayExecutor.class);
-    FakeScheduledExecutor clock = FakeScheduledExecutor.fromDelayExecutor(executorMock);
+    ScheduledExecutorService executorMock = createMock(ScheduledExecutorService.class);
+    FakeScheduledExecutor clock = FakeScheduledExecutor.fromScheduledExecutorService(executorMock);
     addTearDown(clock::assertEmpty);
     offerManager = new OfferManagerImpl(
         driver,

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
index 14e4040..5e5c518 100644
--- a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java
@@ -13,6 +13,9 @@
  */
 package org.apache.aurora.scheduler.pruning;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -28,7 +31,6 @@ import org.apache.aurora.common.util.testing.FakeClock;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.scheduler.SchedulerModule.TaskEventBatchWorker;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.base.Tasks;
@@ -53,6 +55,7 @@ import static org.apache.aurora.gen.ScheduleStatus.STARTING;
 import static org.apache.aurora.scheduler.pruning.TaskHistoryPruner.TASKS_PRUNED;
 import static org.apache.aurora.scheduler.testing.BatchWorkerUtil.expectBatchExecute;
 import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
 import static org.junit.Assert.assertEquals;
 
@@ -64,7 +67,7 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
   private static final Amount<Long, Time> ONE_HOUR = Amount.of(1L, Time.HOURS);
   private static final int PER_JOB_HISTORY = 2;
 
-  private DelayExecutor executor;
+  private ScheduledExecutorService executor;
   private FakeClock clock;
   private StateManager stateManager;
   private StorageTestUtil storageUtil;
@@ -75,7 +78,7 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
 
   @Before
   public void setUp() throws Exception {
-    executor = createMock(DelayExecutor.class);
+    executor = createMock(ScheduledExecutorService.class);
     clock = new FakeClock();
     stateManager = createMock(StateManager.class);
     storageUtil = new StorageTestUtil(this);
@@ -310,9 +313,11 @@ public class TaskHistoryPrunerTest extends EasyMockTest {
 
   private Capture<Runnable> expectDelayedPrune(long timestampMillis) {
     Capture<Runnable> capture = createCapture();
-    executor.execute(
+    expect(executor.schedule(
         EasyMock.capture(capture),
-        eq(Amount.of(pruner.calculateTimeout(timestampMillis), Time.MILLISECONDS)));
+        eq(pruner.calculateTimeout(timestampMillis)),
+        eq(TimeUnit.MILLISECONDS)))
+        .andReturn(null);
     return capture;
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java b/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
index 8fd501b..1bf3320 100644
--- a/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/reconciliation/KillRetryTest.java
@@ -15,6 +15,7 @@ package org.apache.aurora.scheduler.reconciliation;
 
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledExecutorService;
 
 import javax.inject.Singleton;
 
@@ -34,7 +35,6 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.scheduler.app.LifecycleModule;
 import org.apache.aurora.scheduler.async.AsyncModule.AsyncExecutor;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.events.PubsubEventModule;
@@ -68,8 +68,8 @@ public class KillRetryTest extends EasyMockTest {
     storageUtil = new StorageTestUtil(this);
     storageUtil.expectOperations();
     backoffStrategy = createMock(BackoffStrategy.class);
-    final DelayExecutor executorMock = createMock(DelayExecutor.class);
-    clock = FakeScheduledExecutor.fromDelayExecutor(executorMock);
+    final ScheduledExecutorService executorMock = createMock(ScheduledExecutorService.class);
+    clock = FakeScheduledExecutor.fromScheduledExecutorService(executorMock);
     addTearDown(clock::assertEmpty);
     statsProvider = new FakeStatsProvider();
 
@@ -81,7 +81,8 @@ public class KillRetryTest extends EasyMockTest {
           protected void configure() {
             bind(Driver.class).toInstance(driver);
             bind(Storage.class).toInstance(storageUtil.storage);
-            bind(DelayExecutor.class).annotatedWith(AsyncExecutor.class).toInstance(executorMock);
+            bind(ScheduledExecutorService.class).annotatedWith(AsyncExecutor.class)
+                .toInstance(executorMock);
             PubsubEventModule.bindSubscriber(binder(), KillRetry.class);
             bind(KillRetry.class).in(Singleton.class);
             bind(BackoffStrategy.class).toInstance(backoffStrategy);

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java b/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
index 9da99c6..71125bc 100644
--- a/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/reconciliation/TaskTimeoutTest.java
@@ -13,6 +13,8 @@
  */
 package org.apache.aurora.scheduler.reconciliation;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import com.google.common.base.Optional;
@@ -28,7 +30,6 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
 import org.apache.aurora.gen.TaskEvent;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.state.StateChangeResult;
 import org.apache.aurora.scheduler.state.StateManager;
@@ -59,7 +60,7 @@ public class TaskTimeoutTest extends EasyMockTest {
   private static final Amount<Long, Time> TIMEOUT = Amount.of(1L, Time.MINUTES);
 
   private AtomicLong timedOutTaskCounter;
-  private DelayExecutor executor;
+  private ScheduledExecutorService executor;
   private StorageTestUtil storageUtil;
   private StateManager stateManager;
   private FakeClock clock;
@@ -68,7 +69,7 @@ public class TaskTimeoutTest extends EasyMockTest {
 
   @Before
   public void setUp() {
-    executor = createMock(DelayExecutor.class);
+    executor = createMock(ScheduledExecutorService.class);
     storageUtil = new StorageTestUtil(this);
     stateManager = createMock(StateManager.class);
     clock = new FakeClock();
@@ -91,7 +92,11 @@ public class TaskTimeoutTest extends EasyMockTest {
 
   private Capture<Runnable> expectTaskWatch(Amount<Long, Time> expireIn) {
     Capture<Runnable> capture = createCapture();
-    executor.execute(EasyMock.capture(capture), eq(expireIn));
+    expect(executor.schedule(
+        EasyMock.capture(capture),
+        eq(expireIn.as(Time.MILLISECONDS).longValue()),
+        eq(TimeUnit.MILLISECONDS)))
+        .andReturn(null);
     return capture;
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
index b88d5f1..fb85876 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskGroupsTest.java
@@ -14,6 +14,7 @@
 package org.apache.aurora.scheduler.scheduling;
 
 import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.RateLimiter;
@@ -27,7 +28,6 @@ import org.apache.aurora.gen.JobKey;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
@@ -70,8 +70,8 @@ public class TaskGroupsTest extends EasyMockTest {
   public void setUp() throws Exception {
     storageUtil = new StorageTestUtil(this);
     storageUtil.expectOperations();
-    DelayExecutor executor = createMock(DelayExecutor.class);
-    clock = FakeScheduledExecutor.fromDelayExecutor(executor);
+    ScheduledExecutorService executor = createMock(ScheduledExecutorService.class);
+    clock = FakeScheduledExecutor.fromScheduledExecutorService(executor);
     backoffStrategy = createMock(BackoffStrategy.class);
     taskScheduler = createMock(TaskScheduler.class);
     rateLimiter = createMock(RateLimiter.class);

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
index 433f791..2501618 100644
--- a/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/scheduling/TaskThrottlerTest.java
@@ -13,6 +13,9 @@
  */
 package org.apache.aurora.scheduler.scheduling;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 
@@ -25,7 +28,6 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskEvent;
 import org.apache.aurora.scheduler.SchedulerModule.TaskEventBatchWorker;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.events.PubsubEvent.TaskStateChange;
 import org.apache.aurora.scheduler.state.StateChangeResult;
@@ -49,7 +51,7 @@ public class TaskThrottlerTest extends EasyMockTest {
 
   private RescheduleCalculator rescheduleCalculator;
   private FakeClock clock;
-  private DelayExecutor executor;
+  private ScheduledExecutorService executor;
   private StorageTestUtil storageUtil;
   private StateManager stateManager;
   private TaskThrottler throttler;
@@ -58,7 +60,7 @@ public class TaskThrottlerTest extends EasyMockTest {
   public void setUp() throws Exception {
     rescheduleCalculator = createMock(RescheduleCalculator.class);
     clock = new FakeClock();
-    executor = createMock(DelayExecutor.class);
+    executor = createMock(ScheduledExecutorService.class);
     storageUtil = new StorageTestUtil(this);
     storageUtil.expectOperations();
     stateManager = createMock(StateManager.class);
@@ -119,9 +121,11 @@ public class TaskThrottlerTest extends EasyMockTest {
 
   private Capture<Runnable> expectThrottled(long penaltyMs) {
     Capture<Runnable> stateChangeCapture = createCapture();
-    executor.execute(
+    expect(executor.schedule(
         capture(stateChangeCapture),
-        eq(Amount.of(penaltyMs, Time.MILLISECONDS)));
+        eq(penaltyMs),
+        eq(TimeUnit.MILLISECONDS)))
+        .andReturn(null);
     return stateChangeCapture;
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java b/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
index 0857974..bcc7438 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
@@ -117,7 +117,6 @@ public class RecoveryTest extends EasyMockTest {
     recovery.commit();
     transaction.getValue().apply(storeProvider);
 
-    snapshot.getValue().unsetDbScript();
     assertEquals(SNAPSHOT1, snapshot.getValue());
   }
 
@@ -147,7 +146,6 @@ public class RecoveryTest extends EasyMockTest {
     recovery.commit();
     transaction.getValue().apply(storeProvider);
 
-    snapshot.getValue().unsetDbScript();
     assertEquals(modified, snapshot.getValue());
   }
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java
deleted file mode 100644
index 46dc7f5..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/AttributeStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractAttributeStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class AttributeStoreTest extends AbstractAttributeStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java
deleted file mode 100644
index dd9da19..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/CronJobStoreTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.storage.db;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.storage.AbstractCronJobStoreTest;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-
-public class CronJobStoreTest extends AbstractCronJobStoreTest {
-  @Override
-  protected Module getStorageModule() {
-    return Modules.combine(
-        DbModule.testModuleWithWorkQueue(),
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(StatsProvider.class).toInstance(new FakeStatsProvider());
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        });
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
deleted file mode 100644
index 2229e4e..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/DbStorageTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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.storage.db;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.scheduler.async.GatedWorkQueue;
-import org.apache.aurora.scheduler.async.GatedWorkQueue.GatedOperation;
-import org.apache.aurora.scheduler.storage.AttributeStore;
-import org.apache.aurora.scheduler.storage.CronJobStore;
-import org.apache.aurora.scheduler.storage.JobUpdateStore;
-import org.apache.aurora.scheduler.storage.LockStore;
-import org.apache.aurora.scheduler.storage.QuotaStore;
-import org.apache.aurora.scheduler.storage.SchedulerStore;
-import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
-import org.apache.aurora.scheduler.storage.Storage.StorageException;
-import org.apache.aurora.scheduler.storage.Storage.Work;
-import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.ibatis.exceptions.PersistenceException;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.easymock.EasyMock;
-import org.easymock.IExpectationSetters;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-
-public class DbStorageTest extends EasyMockTest {
-  private GatedWorkQueue gatedWorkQueue;
-  private Work.Quiet<String> readWork;
-
-  private DbStorage storage;
-
-  @Before
-  public void setUp() {
-    gatedWorkQueue = createMock(GatedWorkQueue.class);
-    readWork = createMock(new Clazz<Work.Quiet<String>>() { });
-    StatsProvider statsProvider = createMock(StatsProvider.class);
-
-    storage = new DbStorage(
-        createMock(SqlSessionFactory.class),
-        createMock(EnumBackfill.class),
-        gatedWorkQueue,
-        createMock(CronJobStore.Mutable.class),
-        createMock(TaskStore.Mutable.class),
-        createMock(SchedulerStore.Mutable.class),
-        createMock(AttributeStore.Mutable.class),
-        createMock(LockStore.Mutable.class),
-        createMock(QuotaStore.Mutable.class),
-        createMock(JobUpdateStore.Mutable.class),
-        statsProvider);
-  }
-
-  @Test(expected = StorageException.class)
-  public void testReadFails() {
-    expect(readWork.apply(EasyMock.anyObject()))
-        .andThrow(new PersistenceException());
-
-    control.replay();
-
-    storage.read(readWork);
-  }
-
-  @Test
-  public void testRead() {
-    expect(readWork.apply(EasyMock.anyObject())).andReturn("hi");
-
-    control.replay();
-
-    assertEquals("hi", storage.read(readWork));
-  }
-
-  private IExpectationSetters<?> expectGateClosed() throws Exception {
-    return expect(gatedWorkQueue.closeDuring(EasyMock.anyObject()))
-        .andAnswer(() -> {
-          GatedOperation<?, ?> op = (GatedOperation<?, ?>) EasyMock.getCurrentArguments()[0];
-          return op.doWithGateClosed();
-        });
-  }
-
-  @Test
-  public void testGateWithReentrantWrites() throws Exception {
-    expectGateClosed().times(2);
-
-    control.replay();
-
-    storage.write((NoResult.Quiet) storeProvider -> noopWrite());
-  }
-
-  private void noopWrite() {
-    storage.write((NoResult.Quiet) storeProvider -> {
-      // No-op.
-    });
-  }
-
-  @Test
-  public void testFlushWithSeqentialWrites() throws Exception {
-    expectGateClosed().times(2);
-
-    control.replay();
-
-    noopWrite();
-    noopWrite();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java
deleted file mode 100644
index c7d437f..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/InstrumentingInterceptorTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * 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.storage.db;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.aurora.common.stats.SlidingStats;
-import org.apache.aurora.common.stats.Stats;
-import org.apache.aurora.common.testing.easymock.EasyMockTest;
-import org.apache.aurora.common.util.Clock;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.plugin.Invocation;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import static junit.framework.TestCase.assertNotNull;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({MappedStatement.class, Method.class})
-public class InstrumentingInterceptorTest extends EasyMockTest {
-  private InstrumentingInterceptor interceptor;
-  private Invocation invocation;
-  private SlidingStats slidingStats;
-
-  private Clock mockClock;
-
-  @Before
-  public void setUp() throws Exception {
-    invocation = createMock(Invocation.class);
-    mockClock = createMock(Clock.class);
-    slidingStats = createMock(SlidingStats.class);
-    interceptor = new InstrumentingInterceptor(mockClock, name -> slidingStats);
-  }
-
-  private void expectGetArgs(Object[] args, int times) {
-    expect(invocation.getArgs()).andReturn(args).times(times);
-  }
-
-  @Test
-  public void testStatIsCreatedOnce() throws Throwable {
-    final AtomicLong factoryCallCount = new AtomicLong(0);
-    interceptor = new InstrumentingInterceptor(mockClock, name -> {
-      factoryCallCount.incrementAndGet();
-      return slidingStats;
-    });
-
-    String statName = "test";
-    MappedStatement fakeMappedStatement = createMock(MappedStatement.class);
-    Object[] args = new Object[] {fakeMappedStatement};
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 3);
-
-    expect(fakeMappedStatement.getId()).andReturn(statName);
-    expect(invocation.proceed()).andReturn("result");
-
-    slidingStats.accumulate(1000);
-    expectLastCall();
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 3);
-
-    expect(fakeMappedStatement.getId()).andReturn(statName);
-    expect(invocation.proceed()).andReturn("result");
-
-    slidingStats.accumulate(1000);
-    expectLastCall();
-
-    control.replay();
-
-    // Perform the test
-    interceptor.intercept(invocation);
-
-    assertEquals(1L, factoryCallCount.get());
-    interceptor.intercept(invocation);
-    assertEquals(1L, factoryCallCount.get());
-  }
-
-  @Test
-  public void testInterceptMarksMetrics() throws Throwable {
-    MappedStatement fakeMappedStatement = createMock(MappedStatement.class);
-    Object[] args = new Object[] {fakeMappedStatement};
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 3);
-
-    expect(fakeMappedStatement.getId()).andReturn("test");
-    expect(invocation.proceed()).andReturn("result");
-
-    slidingStats.accumulate(1000);
-    expectLastCall();
-
-    control.replay();
-
-    // Perform the test
-    Object res = interceptor.intercept(invocation);
-    assertEquals("result", res);
-  }
-
-  @Test
-  public void testInterceptNotAMappedStatement() throws Throwable {
-    interceptor = new InstrumentingInterceptor(mockClock);
-    Method mockMethod = PowerMock.createMock(Method.class);
-
-    Object notAMappedStatement = new Object();
-    Object[] args = new Object[] {notAMappedStatement};
-
-    expect(mockClock.nowNanos()).andReturn(0L).andReturn(1000L);
-
-    expectGetArgs(args, 2);
-
-    expect(invocation.getMethod()).andReturn(mockMethod);
-    expect(invocation.getTarget()).andReturn("test");
-    expect(invocation.proceed()).andReturn(null);
-
-    control.replay();
-
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total_per_sec"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_events"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_nanos_per_event"));
-    assertNull(Stats.getVariable("mybatis.invalid_invocations_events_per_sec"));
-
-    interceptor.intercept(invocation);
-
-    // upon interception of invocation that does not have a valid MappedStatement use
-    // invalid_invocations as the name
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_nanos_total_per_sec"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_events"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_nanos_per_event"));
-    assertNotNull(Stats.getVariable("mybatis.invalid_invocations_events_per_sec"));
-
-    assertEquals(1000L, Stats.getVariable("mybatis.invalid_invocations_nanos_total").read());
-    assertEquals(1L, Stats.getVariable("mybatis.invalid_invocations_events").read());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java
deleted file mode 100644
index f7e355b..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/JobUpdateStoreTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.storage.db;
-
-import com.google.inject.Injector;
-
-import org.apache.aurora.scheduler.storage.AbstractJobUpdateStoreTest;
-
-public class JobUpdateStoreTest extends AbstractJobUpdateStoreTest {
-  @Override
-  protected Injector createStorageInjector() {
-    return DbUtil.createStorageInjector(DbModule.testModuleWithWorkQueue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java
deleted file mode 100644
index e2965b2..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/LockStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractLockStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class LockStoreTest extends AbstractLockStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java b/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java
deleted file mode 100644
index d594bce..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/MigrationManagerImplIT.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * 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.storage.db;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Optional;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.io.CharStreams;
-import com.google.inject.Injector;
-
-import org.apache.aurora.scheduler.storage.db.views.MigrationChangelogEntry;
-import org.apache.ibatis.migration.Change;
-import org.apache.ibatis.migration.JavaMigrationLoader;
-import org.apache.ibatis.migration.MigrationLoader;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.junit.Test;
-
-import static org.apache.aurora.scheduler.storage.db.DbModule.testModuleWithWorkQueue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class MigrationManagerImplIT {
-  private Injector createMigrationInjector(MigrationLoader migrationLoader) {
-    return DbUtil.createStorageInjector(
-        testModuleWithWorkQueue(),
-        new DbModule.MigrationManagerModule(migrationLoader));
-  }
-
-  /**
-   * Ensure all changes have been applied and their downgrade scripts stored appropriately.
-   *
-   * @param sqlSessionFactory The sql session factory.
-   * @param loader A migration loader.
-   * @throws Exception If the changes were not applied properly.
-   */
-  private void assertMigrationComplete(
-      SqlSessionFactory sqlSessionFactory,
-      MigrationLoader loader) throws Exception {
-
-    try (SqlSession session = sqlSessionFactory.openSession()) {
-      MigrationMapper mapper = session.getMapper(MigrationMapper.class);
-
-      List<MigrationChangelogEntry> appliedChanges = mapper.selectAll();
-
-      for (Change change : loader.getMigrations()) {
-        Optional<MigrationChangelogEntry> appliedChange = appliedChanges
-            .stream()
-            .filter(c -> c.getId().equals(change.getId()))
-            .findFirst();
-
-        assertTrue(appliedChange.isPresent());
-        assertEquals(
-            CharStreams.toString(loader.getScriptReader(change, true /* undo */)),
-            appliedChange.get().getDowngradeScript());
-      }
-
-      // As long as the tables exist, neither of these statements should fail.
-      try (Connection c = session.getConnection()) {
-        try (PreparedStatement select = c.prepareStatement("SELECT * FROM V001_test_table")) {
-          select.execute();
-        }
-        try (PreparedStatement select = c.prepareStatement("SELECT * FROM V002_test_table2")) {
-          select.execute();
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testMigrate() throws Exception {
-    MigrationLoader loader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.testmigration");
-    Injector injector = createMigrationInjector(loader);
-
-    injector.getInstance(MigrationManager.class).migrate();
-    assertMigrationComplete(injector.getInstance(SqlSessionFactory.class), loader);
-  }
-
-  @Test
-  public void testNoMigrationNecessary() throws Exception {
-    MigrationLoader loader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.testmigration");
-    Injector injector = createMigrationInjector(loader);
-
-    MigrationManager migrationManager = injector.getInstance(MigrationManager.class);
-
-    migrationManager.migrate();
-
-    SqlSessionFactory sqlSessionFactory = injector.getInstance(SqlSessionFactory.class);
-    assertMigrationComplete(sqlSessionFactory, loader);
-
-    // Run the migration a second time, no changes should be made.
-    migrationManager.migrate();
-    assertMigrationComplete(sqlSessionFactory, loader);
-  }
-
-  private void assertRollbackComplete(SqlSessionFactory sqlSessionFactory) throws Exception {
-    try (SqlSession session = sqlSessionFactory.openSession()) {
-      MigrationMapper mapper = session.getMapper(MigrationMapper.class);
-
-      assertTrue(mapper.selectAll().isEmpty());
-      try (Connection c = session.getConnection()) {
-        for (String table : ImmutableList.of("V001_test_table", "V002_test_table2")) {
-          try (PreparedStatement select = c.prepareStatement("SELECT * FROM " + table)) {
-            select.execute();
-            fail("Select from " + table + " should have failed, the table should have been "
-                + "dropped.");
-          } catch (SQLException e) {
-            // This exception is expected.
-            assertTrue(
-                e.getMessage().startsWith("Table \"" + table.toUpperCase() + "\" not found"));
-          }
-        }
-      }
-    }
-  }
-
-  @Test
-  public void testRollback() throws Exception {
-    // Run a normal migration which will apply one the change found in the testmigration package.
-    MigrationLoader loader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.testmigration");
-    Injector injector = createMigrationInjector(loader);
-
-    MigrationManager migrationManager = injector.getInstance(MigrationManager.class);
-
-    migrationManager.migrate();
-
-    // Now we intentionally pass a reference to a non-existent package to ensure that no migrations
-    // are found. As such a rollback is expected to be detected and a downgrade be performed.
-    MigrationLoader rollbackLoader = new JavaMigrationLoader(
-        "org.apache.aurora.scheduler.storage.db.nomigrations");
-    Injector rollbackInjector = createMigrationInjector(rollbackLoader);
-    MigrationManager rollbackManager = rollbackInjector.getInstance(MigrationManager.class);
-
-    rollbackManager.migrate();
-
-    assertRollbackComplete(rollbackInjector.getInstance(SqlSessionFactory.class));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java
deleted file mode 100644
index 1ed1a12..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/MyBatisCacheImplTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.storage.db;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-public class MyBatisCacheImplTest {
-  private MyBatisCacheImpl cache;
-
-  @Before
-  public void setUp() {
-    cache = new MyBatisCacheImpl("cache.id");
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testExceptionWithoutSize() {
-    cache.getSize();
-  }
-
-  @Test
-  public void testGetAndSet() {
-    String key = "key";
-    String value = "value";
-
-    cache.setSize(100);
-
-    assertNull(cache.getObject(key));
-
-    cache.putObject(key, value);
-
-    assertEquals(cache.getObject(key), value);
-
-    cache.clear();
-
-    assertNull(cache.getObject(key));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java
deleted file mode 100644
index 048db06..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/QuotaStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractQuotaStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class QuotaStoreTest extends AbstractQuotaStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java
deleted file mode 100644
index 74c9d1d..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/RowGarbageCollectorTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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.storage.db;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.gen.JobKey;
-import org.apache.aurora.scheduler.base.TaskTestUtil;
-import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.entities.IJobKey;
-import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
-import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.apache.aurora.gen.Resource.diskMb;
-import static org.apache.aurora.gen.Resource.numCpus;
-import static org.apache.aurora.gen.Resource.ramMb;
-import static org.junit.Assert.assertEquals;
-
-public class RowGarbageCollectorTest {
-
-  private static final IJobKey JOB_A = IJobKey.build(new JobKey("roleA", "envA", "jobA"));
-  private static final IJobKey JOB_B = IJobKey.build(new JobKey("roleB", "envB", "jobB"));
-  private static final IScheduledTask TASK_A2 = TaskTestUtil.makeTask("task_a2", JOB_A);
-  private static final ITaskConfig CONFIG_A =
-      ITaskConfig.build(TASK_A2.getAssignedTask().getTask().newBuilder()
-              .setResources(ImmutableSet.of(numCpus(1.0), ramMb(124246), diskMb(1024))));
-  private static final ITaskConfig CONFIG_B = TaskTestUtil.makeConfig(JOB_B);
-
-  private JobKeyMapper jobKeyMapper;
-  private TaskMapper taskMapper;
-  private TaskConfigMapper taskConfigMapper;
-  private RowGarbageCollector rowGc;
-
-  @Before
-  public void setUp() {
-    Injector injector = Guice.createInjector(
-        DbModule.testModuleWithWorkQueue(),
-        new DbModule.GarbageCollectorModule(new DbModule.Options()),
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(StatsProvider.class).toInstance(new FakeStatsProvider());
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        }
-    );
-
-    rowGc = injector.getInstance(RowGarbageCollector.class);
-    injector.getInstance(Storage.class).prepare();
-    taskMapper = injector.getInstance(TaskMapper.class);
-    jobKeyMapper = injector.getInstance(JobKeyMapper.class);
-    taskConfigMapper = injector.getInstance(TaskConfigMapper.class);
-  }
-
-  @Test
-  public void testNoop() {
-    rowGc.runOneIteration();
-  }
-
-  @Test
-  public void testGarbageCollection() {
-    rowGc.runOneIteration();
-    assertEquals(ImmutableList.of(), jobKeyMapper.selectAll());
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_A));
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_B));
-
-    jobKeyMapper.merge(JOB_A);
-    rowGc.runOneIteration();
-    assertEquals(ImmutableList.of(), jobKeyMapper.selectAll());
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_A));
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_B));
-
-    jobKeyMapper.merge(JOB_A);
-    taskConfigMapper.insert(CONFIG_A, new InsertResult());
-    InsertResult a2Insert = new InsertResult();
-    taskConfigMapper.insert(TASK_A2.getAssignedTask().getTask(), a2Insert);
-    taskMapper.insertScheduledTask(TASK_A2, a2Insert.getId(), new InsertResult());
-    jobKeyMapper.merge(JOB_B);
-    taskConfigMapper.insert(CONFIG_B, new InsertResult());
-    rowGc.runOneIteration();
-    // Only job A and config A2 are still referenced, other rows are deleted.
-    assertEquals(ImmutableList.of(JOB_A.newBuilder()), jobKeyMapper.selectAll());
-    // Note: Using the ramMb as a sentinel value, since relations in the TaskConfig are not
-    // populated, therefore full object equivalence cannot easily be used.
-    assertEquals(
-        TASK_A2.getAssignedTask().getTask().getRamMb(),
-        Iterables.getOnlyElement(taskConfigMapper.selectConfigsByJob(JOB_A)).toImmutable()
-            .getRamMb());
-    assertEquals(ImmutableList.of(), taskConfigMapper.selectConfigsByJob(JOB_B));
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java
deleted file mode 100644
index 55c4576..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/SchedulerStoreTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.storage.db;
-
-import org.apache.aurora.scheduler.storage.AbstractSchedulerStoreTest;
-import org.apache.aurora.scheduler.storage.Storage;
-
-public class SchedulerStoreTest extends AbstractSchedulerStoreTest {
-  @Override
-  protected Storage createStorage() {
-    return DbUtil.createStorage();
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java
deleted file mode 100644
index 45a2f11..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/TaskStoreTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.storage.db;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
-import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.storage.AbstractTaskStoreTest;
-import org.apache.aurora.scheduler.testing.FakeStatsProvider;
-
-public class TaskStoreTest extends AbstractTaskStoreTest {
-  @Override
-  protected Module getStorageModule() {
-    return Modules.combine(
-        DbModule.testModuleWithWorkQueue(),
-        new AbstractModule() {
-          @Override
-          protected void configure() {
-            bind(StatsProvider.class).toInstance(new FakeStatsProvider());
-            bind(Clock.class).toInstance(new FakeClock());
-          }
-        });
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java b/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java
deleted file mode 100644
index 45a5b5e..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V001_TestMigration.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.storage.db.testmigration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V001_TestMigration implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(1L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "A test migration";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE V001_test_table(id int);";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE V001_test_table;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java b/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java
deleted file mode 100644
index 621ca4c..0000000
--- a/src/test/java/org/apache/aurora/scheduler/storage/db/testmigration/V002_TestMigration2.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.storage.db.testmigration;
-
-import java.math.BigDecimal;
-
-import org.apache.ibatis.migration.MigrationScript;
-
-public class V002_TestMigration2 implements MigrationScript {
-  @Override
-  public BigDecimal getId() {
-    return BigDecimal.valueOf(2L);
-  }
-
-  @Override
-  public String getDescription() {
-    return "A second test migration";
-  }
-
-  @Override
-  public String getUpScript() {
-    return "CREATE TABLE V002_test_table2(id int);";
-  }
-
-  @Override
-  public String getDownScript() {
-    return "DROP TABLE V002_test_table2;";
-  }
-}

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/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 5a28f0b..2d161c8 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
@@ -13,15 +13,8 @@
  */
 package org.apache.aurora.scheduler.storage.log;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.util.Map;
 
-import javax.sql.DataSource;
-
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
@@ -64,9 +57,6 @@ import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.resources.ResourceBag;
 import org.apache.aurora.scheduler.storage.Storage;
-import org.apache.aurora.scheduler.storage.db.DbModule;
-import org.apache.aurora.scheduler.storage.db.DbStorage;
-import org.apache.aurora.scheduler.storage.db.DbUtil;
 import org.apache.aurora.scheduler.storage.entities.IHostAttributes;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
@@ -82,7 +72,6 @@ import org.junit.Test;
 
 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.log.SnapshotStoreImpl.SNAPSHOT_RESTORE;
 import static org.apache.aurora.scheduler.storage.log.SnapshotStoreImpl.SNAPSHOT_SAVE;
 import static org.junit.Assert.assertEquals;
@@ -93,7 +82,6 @@ public class SnapshotStoreImplIT {
   private static final long NOW = 10335463456L;
   private static final IJobKey JOB_KEY = JobKeys.from("role", "env", "job");
 
-  private Storage storage;
   private SnapshotStoreImpl snapshotStore;
 
   private void setUpStore() {
@@ -105,82 +93,24 @@ public class SnapshotStoreImplIT {
             bind(StatsProvider.class).toInstance(new FakeStatsProvider());
           }
         });
-    storage = injector.getInstance(Storage.class);
 
     FakeClock clock = new FakeClock();
     clock.setNowMillis(NOW);
     snapshotStore = new SnapshotStoreImpl(
         generateBuildInfo(),
         clock,
-        storage,
+        injector.getInstance(Storage.class),
         TaskTestUtil.THRIFT_BACKFILL);
     Stats.flush();
   }
 
-  private static Snapshot makeComparable(Snapshot snapshot) {
-    Snapshot copy = snapshot.deepCopy();
-    // Ignore DB snapshot. It will be tested by asserting the DB data.
-    copy.unsetDbScript();
-    return copy;
-  }
-
-  @Test
-  public void testNoDBTaskStore() {
-    setUpStore();
-    populateStore(storage);
-
-    Snapshot snapshot1 = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(snapshot1));
-    assertSnapshotSaveStats(1L);
-
-    snapshotStore.applySnapshot(snapshot1);
-    Snapshot snapshot2 = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(snapshot2));
-    assertEquals(makeComparable(snapshot1), makeComparable(snapshot2));
-    assertSnapshotRestoreStats(1L);
-    assertSnapshotSaveStats(2L);
-  }
-
-  @Test
-  public void testMigrateFromDBStores() {
-    // Produce a snapshot from DbStorage, populating the dbScript field.
-    Injector injector = DbUtil.createStorageInjector(DbModule.testModuleWithWorkQueue());
-    DbStorage dbStorage = injector.getInstance(DbStorage.class);
-    populateStore(dbStorage);
-
-    Snapshot dbScriptSnapshot = new Snapshot();
-    try (Connection c = ((DataSource) dbStorage.getUnsafeStoreAccess()).getConnection()) {
-      try (PreparedStatement ps = c.prepareStatement("SCRIPT")) {
-        try (ResultSet rs = ps.executeQuery()) {
-          ImmutableList.Builder<String> builder = ImmutableList.builder();
-          while (rs.next()) {
-            String columnValue = rs.getString("SCRIPT");
-            builder.add(columnValue + "\n");
-          }
-          dbScriptSnapshot.setDbScript(builder.build());
-        }
-      }
-    } catch (SQLException e) {
-      throw new RuntimeException(e);
-    }
-
-    // Verify that the dbScript snapshot can be loaded into a storage, and the resulting snapshot
-    // fills thrift fields.
-    setUpStore();
-    snapshotStore.applySnapshot(dbScriptSnapshot);
-    Snapshot snapshot2 = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(snapshot2));
-    assertSnapshotRestoreStats(2L);
-    assertSnapshotSaveStats(2L);
-  }
-
   @Test
   public void testBackfill() {
     setUpStore();
     snapshotStore.applySnapshot(makeNonBackfilled());
 
     Snapshot backfilled = snapshotStore.createSnapshot();
-    assertEquals(expected(), makeComparable(backfilled));
+    assertEquals(expected(), backfilled);
     assertSnapshotRestoreStats(1L);
     assertSnapshotSaveStats(1L);
   }
@@ -260,25 +190,6 @@ public class SnapshotStoreImplIT {
     return expected();
   }
 
-  private void populateStore(Storage toPopulate) {
-    toPopulate.write((NoResult.Quiet) store -> {
-      store.getUnsafeTaskStore().saveTasks(ImmutableSet.of(TASK));
-      store.getCronJobStore().saveAcceptedJob(CRON_JOB);
-      store.getQuotaStore().saveQuota(ROLE, QUOTA);
-      store.getAttributeStore().saveHostAttributes(ATTRIBUTES);
-      store.getSchedulerStore().saveFrameworkId(FRAMEWORK_ID);
-      store.getLockStore().saveLock(LOCK);
-      store.getJobUpdateStore().saveJobUpdate(UPDATE.getUpdate(), Optional.of(LOCK.getToken()));
-      store.getJobUpdateStore().saveJobUpdateEvent(
-          UPDATE.getUpdate().getSummary().getKey(),
-          UPDATE.getUpdateEvents().get(0));
-      store.getJobUpdateStore().saveJobInstanceUpdateEvent(
-          UPDATE.getUpdate().getSummary().getKey(),
-          UPDATE.getInstanceEvents().get(0)
-      );
-    });
-  }
-
   private void assertSnapshotSaveStats(long count) {
     for (String stat : snapshotStore.snapshotFieldNames()) {
       assertEquals(count, Stats.getVariable(SNAPSHOT_SAVE + stat + "_events").read());

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
index 66b415c..15e0e30 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemCronJobStoreTest.java
@@ -17,16 +17,12 @@ import com.google.inject.AbstractModule;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
-import org.apache.aurora.common.stats.SlidingStats;
 import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.scheduler.storage.AbstractCronJobStoreTest;
-import org.apache.aurora.scheduler.storage.db.InstrumentingInterceptor;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.junit.Test;
 
 import static org.apache.aurora.scheduler.storage.mem.MemCronJobStore.CRON_JOBS_SIZE;
-import static org.easymock.EasyMock.createMock;
 import static org.junit.Assert.assertEquals;
 
 public class MemCronJobStoreTest extends AbstractCronJobStoreTest {
@@ -42,12 +38,6 @@ public class MemCronJobStoreTest extends AbstractCronJobStoreTest {
           @Override
           protected void configure() {
             bind(StatsProvider.class).toInstance(statsProvider);
-
-            // bindings for mybatis interceptor
-            SlidingStats slidingStats = createMock(SlidingStats.class);
-            bind(InstrumentingInterceptor.class).toInstance(new InstrumentingInterceptor(
-                Clock.SYSTEM_CLOCK, s -> slidingStats
-            ));
           }
         });
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
index 9e75c98..027f2f0 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/mem/MemTaskStoreTest.java
@@ -18,18 +18,14 @@ import com.google.inject.AbstractModule;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
-import org.apache.aurora.common.stats.SlidingStats;
 import org.apache.aurora.common.stats.StatsProvider;
-import org.apache.aurora.common.util.Clock;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.storage.AbstractTaskStoreTest;
 import org.apache.aurora.scheduler.storage.Storage.MutateWork.NoResult;
 import org.apache.aurora.scheduler.storage.TaskStore;
-import org.apache.aurora.scheduler.storage.db.InstrumentingInterceptor;
 import org.apache.aurora.scheduler.testing.FakeStatsProvider;
 import org.junit.Test;
 
-import static org.easymock.EasyMock.createMock;
 import static org.junit.Assert.assertEquals;
 
 public class MemTaskStoreTest extends AbstractTaskStoreTest {
@@ -45,12 +41,6 @@ public class MemTaskStoreTest extends AbstractTaskStoreTest {
           @Override
           protected void configure() {
             bind(StatsProvider.class).toInstance(statsProvider);
-
-            // bindings for mybatis interceptor
-            SlidingStats slidingStats = createMock(SlidingStats.class);
-            bind(InstrumentingInterceptor.class).toInstance(new InstrumentingInterceptor(
-                Clock.SYSTEM_CLOCK, s -> slidingStats
-            ));
           }
         });
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/94276046/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java b/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
index ce6e5a4..0aea369 100644
--- a/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
+++ b/src/test/java/org/apache/aurora/scheduler/testing/FakeScheduledExecutor.java
@@ -27,7 +27,6 @@ import org.apache.aurora.common.collections.Pair;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.util.testing.FakeClock;
-import org.apache.aurora.scheduler.async.DelayExecutor;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 
@@ -64,17 +63,21 @@ public final class FakeScheduledExecutor extends FakeClock {
       Object[] args = EasyMock.getCurrentArguments();
       Runnable work = (Runnable) args[0];
       @SuppressWarnings("unchecked")
-      Amount<Long, Time> delay = (Amount<Long, Time>) args[1];
-      addDelayedWork(executor, delay.as(Time.MILLISECONDS), work);
+      long value = (long) args[1];
+      @SuppressWarnings("unchecked")
+      TimeUnit unit = (TimeUnit) args[2];
+
+      addDelayedWork(executor, TimeUnit.MILLISECONDS.convert(value, unit), work);
       return null;
     };
   }
 
-  public static FakeScheduledExecutor fromDelayExecutor(DelayExecutor mock) {
+  public static FakeScheduledExecutor fromScheduledExecutorService(ScheduledExecutorService mock) {
     FakeScheduledExecutor executor = new FakeScheduledExecutor();
-    mock.execute(
+    mock.schedule(
         EasyMock.<Runnable>anyObject(),
-        EasyMock.<Amount<Long, Time>>anyObject());
+        EasyMock.anyLong(),
+        EasyMock.<TimeUnit>anyObject());
     expectLastCall().andAnswer(answerExecuteWithDelay(executor)).anyTimes();
 
     mock.execute(EasyMock.anyObject());


Mime
View raw message