|
@@ -17,26 +17,16 @@
|
|
|
*/
|
|
|
package org.apache.ambari.server.scheduler;
|
|
|
|
|
|
-import static org.easymock.EasyMock.anyObject;
|
|
|
-import static org.easymock.EasyMock.capture;
|
|
|
-import static org.easymock.EasyMock.createMock;
|
|
|
-import static org.easymock.EasyMock.createMockBuilder;
|
|
|
-import static org.easymock.EasyMock.createNiceMock;
|
|
|
-import static org.easymock.EasyMock.eq;
|
|
|
-import static org.easymock.EasyMock.expect;
|
|
|
-import static org.easymock.EasyMock.expectLastCall;
|
|
|
-import static org.easymock.EasyMock.replay;
|
|
|
-import static org.easymock.EasyMock.verify;
|
|
|
-import static org.hamcrest.CoreMatchers.instanceOf;
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertThat;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.inject.Binder;
|
|
|
+import com.google.inject.Guice;
|
|
|
+import com.google.inject.Inject;
|
|
|
+import com.google.inject.Injector;
|
|
|
+import com.google.inject.Module;
|
|
|
+import com.google.inject.persist.PersistService;
|
|
|
+import com.google.inject.persist.Transactional;
|
|
|
+import com.google.inject.util.Modules;
|
|
|
+import junit.framework.Assert;
|
|
|
import org.apache.ambari.server.AmbariException;
|
|
|
import org.apache.ambari.server.actionmanager.ActionDBAccessor;
|
|
|
import org.apache.ambari.server.actionmanager.HostRoleStatus;
|
|
@@ -58,8 +48,8 @@ import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
|
|
|
import org.apache.ambari.server.state.scheduler.Schedule;
|
|
|
import org.easymock.Capture;
|
|
|
import org.easymock.EasyMock;
|
|
|
-import org.junit.After;
|
|
|
-import org.junit.Before;
|
|
|
+import org.junit.AfterClass;
|
|
|
+import org.junit.BeforeClass;
|
|
|
import org.junit.Test;
|
|
|
import org.quartz.CronTrigger;
|
|
|
import org.quartz.JobDataMap;
|
|
@@ -76,34 +66,42 @@ import org.quartz.impl.matchers.GroupMatcher;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.inject.Binder;
|
|
|
-import com.google.inject.Guice;
|
|
|
-import com.google.inject.Inject;
|
|
|
-import com.google.inject.Injector;
|
|
|
-import com.google.inject.Module;
|
|
|
-import com.google.inject.persist.PersistService;
|
|
|
-import com.google.inject.persist.Transactional;
|
|
|
-import com.google.inject.util.Modules;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
-import junit.framework.Assert;
|
|
|
+import static org.easymock.EasyMock.anyObject;
|
|
|
+import static org.easymock.EasyMock.capture;
|
|
|
+import static org.easymock.EasyMock.createMock;
|
|
|
+import static org.easymock.EasyMock.createMockBuilder;
|
|
|
+import static org.easymock.EasyMock.createNiceMock;
|
|
|
+import static org.easymock.EasyMock.eq;
|
|
|
+import static org.easymock.EasyMock.expect;
|
|
|
+import static org.easymock.EasyMock.expectLastCall;
|
|
|
+import static org.easymock.EasyMock.replay;
|
|
|
+import static org.easymock.EasyMock.verify;
|
|
|
+import static org.hamcrest.CoreMatchers.instanceOf;
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertThat;
|
|
|
|
|
|
public class ExecutionScheduleManagerTest {
|
|
|
- private Clusters clusters;
|
|
|
- private Cluster cluster;
|
|
|
- private String clusterName;
|
|
|
- private Injector injector;
|
|
|
- private AmbariMetaInfo metaInfo;
|
|
|
- private ExecutionScheduleManager executionScheduleManager;
|
|
|
- private RequestExecutionFactory requestExecutionFactory;
|
|
|
- private ExecutionScheduler executionScheduler;
|
|
|
- private Scheduler scheduler;
|
|
|
+ private static Clusters clusters;
|
|
|
+ private static Cluster cluster;
|
|
|
+ private static String clusterName;
|
|
|
+ private static Injector injector;
|
|
|
+ private static AmbariMetaInfo metaInfo;
|
|
|
+ private static ExecutionScheduleManager executionScheduleManager;
|
|
|
+ private static RequestExecutionFactory requestExecutionFactory;
|
|
|
+ private static ExecutionScheduler executionScheduler;
|
|
|
+ private static Scheduler scheduler;
|
|
|
|
|
|
private static final Logger LOG =
|
|
|
LoggerFactory.getLogger(ExecutionScheduleManagerTest.class);
|
|
|
|
|
|
- @Before
|
|
|
- public void setup() throws Exception {
|
|
|
+ @BeforeClass
|
|
|
+ public static void setup() throws Exception {
|
|
|
InMemoryDefaultTestModule defaultTestModule = new InMemoryDefaultTestModule();
|
|
|
injector = Guice.createInjector(Modules.override(defaultTestModule)
|
|
|
.with(new ExecutionSchedulerTestModule()));
|
|
@@ -128,8 +126,8 @@ public class ExecutionScheduleManagerTest {
|
|
|
executionScheduleManager.start();
|
|
|
}
|
|
|
|
|
|
- @After
|
|
|
- public void teardown() throws Exception {
|
|
|
+ @AfterClass
|
|
|
+ public static void teardown() throws Exception {
|
|
|
executionScheduleManager.stop();
|
|
|
injector.getInstance(PersistService.class).stop();
|
|
|
}
|
|
@@ -154,7 +152,7 @@ public class ExecutionScheduleManagerTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public class ExecutionSchedulerTestModule implements Module {
|
|
|
+ public static class ExecutionSchedulerTestModule implements Module {
|
|
|
@Override
|
|
|
public void configure(Binder binder) {
|
|
|
binder.bind(ExecutionScheduler.class).to(TestExecutionScheduler.class);
|