Search in sources :

Example 1 with TestingNodeModule

use of io.airlift.node.testing.TestingNodeModule in project presto by prestodb.

the class TestHeartbeatFailureDetector method testExcludesCurrentNode.

@Test
public void testExcludesCurrentNode() throws Exception {
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingJmxModule(), new TestingDiscoveryModule(), new TestingHttpServerModule(), new TraceTokenModule(), new JsonModule(), new JaxrsModule(true), new FailureDetectorModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            configBinder(binder).bindConfig(QueryManagerConfig.class);
            discoveryBinder(binder).bindSelector("presto");
            discoveryBinder(binder).bindHttpAnnouncement("presto");
            // Jersey with jetty 9 requires at least one resource
            // todo add a dummy resource to airlift jaxrs in this case
            jaxrsBinder(binder).bind(FooResource.class);
        }
    });
    Injector injector = app.strictConfig().doNotInitializeLogging().initialize();
    ServiceSelector selector = injector.getInstance(Key.get(ServiceSelector.class, serviceType("presto")));
    assertEquals(selector.selectAllServices().size(), 1);
    HeartbeatFailureDetector detector = injector.getInstance(HeartbeatFailureDetector.class);
    detector.updateMonitoredServices();
    assertEquals(detector.getTotalCount(), 0);
    assertEquals(detector.getActiveCount(), 0);
    assertEquals(detector.getFailedCount(), 0);
    assertTrue(detector.getFailed().isEmpty());
}
Also used : TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) ServiceSelector(io.airlift.discovery.client.ServiceSelector) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JsonModule(io.airlift.json.JsonModule) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) TestingJmxModule(io.airlift.jmx.testing.TestingJmxModule) Binder(com.google.inject.Binder) DiscoveryBinder.discoveryBinder(io.airlift.discovery.client.DiscoveryBinder.discoveryBinder) JaxrsBinder.jaxrsBinder(io.airlift.jaxrs.JaxrsBinder.jaxrsBinder) ConfigBinder.configBinder(io.airlift.configuration.ConfigBinder.configBinder) TestingDiscoveryModule(io.airlift.discovery.client.testing.TestingDiscoveryModule) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) Module(com.google.inject.Module) TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) TestingJmxModule(io.airlift.jmx.testing.TestingJmxModule) TestingDiscoveryModule(io.airlift.discovery.client.testing.TestingDiscoveryModule) JsonModule(io.airlift.json.JsonModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) Test(org.testng.annotations.Test)

Example 2 with TestingNodeModule

use of io.airlift.node.testing.TestingNodeModule in project presto by prestodb.

the class TestHttpBackupStore method setup.

@BeforeMethod
public void setup() throws Exception {
    temporary = createTempDir();
    Map<String, String> properties = ImmutableMap.<String, String>builder().put("backup.http.uri", "http://localhost:8080").build();
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), binder -> jaxrsBinder(binder).bind(TestingHttpBackupResource.class), override(new HttpBackupModule()).with(new TestingModule()));
    Injector injector = app.strictConfig().setRequiredConfigurationProperties(properties).doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    store = injector.getInstance(BackupStore.class);
}
Also used : TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JsonModule(io.airlift.json.JsonModule) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Injector (com.google.inject.Injector)2 Bootstrap (io.airlift.bootstrap.Bootstrap)2 TestingHttpServerModule (io.airlift.http.server.testing.TestingHttpServerModule)2 JaxrsModule (io.airlift.jaxrs.JaxrsModule)2 JsonModule (io.airlift.json.JsonModule)2 TestingNodeModule (io.airlift.node.testing.TestingNodeModule)2 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)1 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)1 ConfigBinder.configBinder (io.airlift.configuration.ConfigBinder.configBinder)1 DiscoveryBinder.discoveryBinder (io.airlift.discovery.client.DiscoveryBinder.discoveryBinder)1 ServiceSelector (io.airlift.discovery.client.ServiceSelector)1 TestingDiscoveryModule (io.airlift.discovery.client.testing.TestingDiscoveryModule)1 JaxrsBinder.jaxrsBinder (io.airlift.jaxrs.JaxrsBinder.jaxrsBinder)1 TestingJmxModule (io.airlift.jmx.testing.TestingJmxModule)1 TraceTokenModule (io.airlift.tracetoken.TraceTokenModule)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1