Search in sources :

Example 1 with Raven

use of net.kencochrane.raven.Raven 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);
}
Also used : Raven(net.kencochrane.raven.Raven) MesosClient(com.hubspot.mesos.client.MesosClient) SingularityDataModule(com.hubspot.singularity.data.SingularityDataModule) SingularityNoOfferCache(com.hubspot.singularity.mesos.SingularityNoOfferCache) OfferCache(com.hubspot.singularity.mesos.OfferCache) SingularityOfferCache(com.hubspot.singularity.mesos.SingularityOfferCache) SentryConfiguration(com.hubspot.singularity.config.SentryConfiguration) HttpServletRequest(javax.servlet.http.HttpServletRequest) SingularityMesosExecutorInfoSupport(com.hubspot.singularity.mesos.SingularityMesosExecutorInfoSupport) Binder(com.google.inject.Binder) TypeLiteral(com.google.inject.TypeLiteral) SingularityZkMigrationsModule(com.hubspot.singularity.data.zkmigrations.SingularityZkMigrationsModule) SingularityTestAuthenticator(com.hubspot.singularity.SingularityTestAuthenticator) SingularityAuthDatastore(com.hubspot.singularity.auth.datastore.SingularityAuthDatastore) SingularityConfiguration(com.hubspot.singularity.config.SingularityConfiguration) SingularityAuthenticator(com.hubspot.singularity.auth.authenticator.SingularityAuthenticator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LoadBalancerClient(com.hubspot.singularity.hooks.LoadBalancerClient) SingularityEventModule(com.hubspot.singularity.event.SingularityEventModule) TestingServer(org.apache.curator.test.TestingServer) GuiceBundle(com.hubspot.dropwizard.guicier.GuiceBundle) SingularityAbort(com.hubspot.singularity.SingularityAbort) SingularityMailer(com.hubspot.singularity.smtp.SingularityMailer) SingularityHistoryModule(com.hubspot.singularity.data.history.SingularityHistoryModule) OutOfScopeException(com.google.inject.OutOfScopeException) SingularityAuthorizationHelper(com.hubspot.singularity.auth.SingularityAuthorizationHelper) SingularityTranscoderModule(com.hubspot.singularity.data.transcoders.SingularityTranscoderModule) SingularityExceptionNotifier(com.hubspot.singularity.sentry.SingularityExceptionNotifier) Environment(io.dropwizard.setup.Environment) SingularityMesosModule(com.hubspot.singularity.mesos.SingularityMesosModule) SingularityMainModule(com.hubspot.singularity.SingularityMainModule) Module(com.google.inject.Module) SingularityTranscoderModule(com.hubspot.singularity.data.transcoders.SingularityTranscoderModule) ProtobufModule(com.hubspot.jackson.datatype.protobuf.ProtobufModule) SingularityDataModule(com.hubspot.singularity.data.SingularityDataModule) SingularityHistoryModule(com.hubspot.singularity.data.history.SingularityHistoryModule) SingularityEventModule(com.hubspot.singularity.event.SingularityEventModule) SingularityZkMigrationsModule(com.hubspot.singularity.data.zkmigrations.SingularityZkMigrationsModule) SingularityMesosModule(com.hubspot.singularity.mesos.SingularityMesosModule) DropwizardModule(com.hubspot.dropwizard.guicier.DropwizardModule) SingularityMainModule(com.hubspot.singularity.SingularityMainModule) SingularityMesosSchedulerClient(com.hubspot.singularity.mesos.SingularityMesosSchedulerClient)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 OutOfScopeException (com.google.inject.OutOfScopeException)1 TypeLiteral (com.google.inject.TypeLiteral)1 DropwizardModule (com.hubspot.dropwizard.guicier.DropwizardModule)1 GuiceBundle (com.hubspot.dropwizard.guicier.GuiceBundle)1 ProtobufModule (com.hubspot.jackson.datatype.protobuf.ProtobufModule)1 MesosClient (com.hubspot.mesos.client.MesosClient)1 SingularityAbort (com.hubspot.singularity.SingularityAbort)1 SingularityMainModule (com.hubspot.singularity.SingularityMainModule)1 SingularityTestAuthenticator (com.hubspot.singularity.SingularityTestAuthenticator)1 SingularityAuthorizationHelper (com.hubspot.singularity.auth.SingularityAuthorizationHelper)1 SingularityAuthenticator (com.hubspot.singularity.auth.authenticator.SingularityAuthenticator)1 SingularityAuthDatastore (com.hubspot.singularity.auth.datastore.SingularityAuthDatastore)1 SentryConfiguration (com.hubspot.singularity.config.SentryConfiguration)1 SingularityConfiguration (com.hubspot.singularity.config.SingularityConfiguration)1 SingularityDataModule (com.hubspot.singularity.data.SingularityDataModule)1 SingularityHistoryModule (com.hubspot.singularity.data.history.SingularityHistoryModule)1 SingularityTranscoderModule (com.hubspot.singularity.data.transcoders.SingularityTranscoderModule)1