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());
}
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);
}
Aggregations