use of com.hubspot.singularity.SingularityAbort in project Singularity by HubSpot.
the class SingularityTestModule method configure.
@Override
public void configure(Binder mainBinder) {
mainBinder.install(new GuiceBundle.GuiceEnforcerModule());
TestingMesosClient tmc = new TestingMesosClient();
mainBinder.bind(MesosClient.class).toInstance(tmc);
mainBinder.bind(TestingMesosClient.class).toInstance(tmc);
mainBinder.bind(TestingServer.class).toInstance(ts);
final SingularityConfiguration configuration = getSingularityConfigurationForTestingServer(ts);
configuration.getMesosConfiguration().setMaster("");
if (useDBTests) {
configuration.setDatabaseConfiguration(getDataSourceFactory());
}
if (customConfigSetup != null) {
customConfigSetup.apply(configuration);
}
mainBinder.bind(SingularityConfiguration.class).toInstance(configuration);
mainBinder.install(Modules.override(new SingularityMainModule(configuration)).with(new Module() {
@Override
public void configure(Binder binder) {
binder.bind(SingularityExceptionNotifier.class).toInstance(mock(SingularityExceptionNotifier.class));
SingularityAbort abort = mock(SingularityAbort.class);
SingularityMailer mailer = mock(SingularityMailer.class);
binder.bind(SingularityMailer.class).toInstance(mailer);
binder.bind(SingularityAbort.class).toInstance(abort);
TestingLoadBalancerClient tlbc = new TestingLoadBalancerClient();
binder.bind(LoadBalancerClient.class).toInstance(tlbc);
binder.bind(TestingLoadBalancerClient.class).toInstance(tlbc);
if (configuration.isCacheOffers()) {
binder.bind(OfferCache.class).to(SingularityOfferCache.class);
} else {
binder.bind(OfferCache.class).to(SingularityNoOfferCache.class);
}
binder.bind(ObjectMapper.class).toInstance(om);
binder.bind(Environment.class).toInstance(environment);
binder.bind(HostAndPort.class).annotatedWith(named(HTTP_HOST_AND_PORT)).toInstance(HostAndPort.fromString("localhost:8080"));
binder.bind(new TypeLiteral<Optional<Raven>>() {
}).toInstance(Optional.<Raven>absent());
binder.bind(new TypeLiteral<Optional<SentryConfiguration>>() {
}).toInstance(Optional.<SentryConfiguration>absent());
binder.bind(HttpServletRequest.class).toProvider(new Provider<HttpServletRequest>() {
@Override
public HttpServletRequest get() {
throw new OutOfScopeException("testing");
}
});
}
}));
mainBinder.install(Modules.override(new SingularityMesosModule()).with(new Module() {
@Override
public void configure(Binder binder) {
SingularityMesosExecutorInfoSupport logSupport = mock(SingularityMesosExecutorInfoSupport.class);
binder.bind(SingularityMesosExecutorInfoSupport.class).toInstance(logSupport);
SingularityMesosSchedulerClient mockClient = mock(SingularityMesosSchedulerClient.class);
when(mockClient.isRunning()).thenReturn(true);
binder.bind(SingularityMesosSchedulerClient.class).toInstance(mockClient);
}
}));
mainBinder.install(new SingularityDataModule());
mainBinder.install(new SingularitySchedulerModule());
mainBinder.install(new SingularityTranscoderModule());
mainBinder.install(new SingularityHistoryModule(configuration));
mainBinder.install(new SingularityZkMigrationsModule());
mainBinder.install(new SingularityEventModule(configuration));
// Auth module bits
mainBinder.bind(SingularityAuthenticator.class).to(SingularityTestAuthenticator.class);
mainBinder.bind(SingularityAuthDatastore.class).to(SingularityDisabledAuthDatastore.class);
mainBinder.bind(SingularityAuthorizationHelper.class).in(Scopes.SINGLETON);
mainBinder.bind(SingularityTestAuthenticator.class).in(Scopes.SINGLETON);
mainBinder.bind(DeployResource.class);
mainBinder.bind(RequestResource.class);
mainBinder.bind(TaskResource.class);
mainBinder.bind(SlaveResource.class);
mainBinder.bind(RackResource.class);
mainBinder.bind(PriorityResource.class);
}
Aggregations