Search in sources :

Example 1 with TestingNodeModule

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

the class TestProxyServer method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    byte[] sharedSecret = Base64.getMimeEncoder().encode("test secret".getBytes(US_ASCII));
    sharedSecretFile = Files.createTempFile("secret", "txt");
    Files.write(sharedSecretFile, sharedSecret);
    Logging.initialize();
    server = new TestingPrestoServer();
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    server.refreshNodes();
    Bootstrap app = new Bootstrap(new TestingNodeModule("test"), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), new TestingJmxModule(), new ProxyModule());
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperty("proxy.uri", server.getBaseUrl().toString()).setRequiredConfigurationProperty("proxy.shared-secret-file", sharedSecretFile.toString()).quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    httpServerInfo = injector.getInstance(HttpServerInfo.class);
    executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
    setupTestTable();
}
Also used : TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) BlackHolePlugin(com.facebook.presto.plugin.blackhole.BlackHolePlugin) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) HttpServerInfo(com.facebook.airlift.http.server.HttpServerInfo) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with TestingNodeModule

use of com.facebook.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(InternalCommunicationConfig.class);
            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.doNotInitializeLogging().quiet().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(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) ServiceSelector(com.facebook.airlift.discovery.client.ServiceSelector) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) JaxrsBinder.jaxrsBinder(com.facebook.airlift.jaxrs.JaxrsBinder.jaxrsBinder) Binder(com.google.inject.Binder) ConfigBinder.configBinder(com.facebook.airlift.configuration.ConfigBinder.configBinder) DiscoveryBinder.discoveryBinder(com.facebook.airlift.discovery.client.DiscoveryBinder.discoveryBinder) TestingDiscoveryModule(com.facebook.airlift.discovery.client.testing.TestingDiscoveryModule) InternalCommunicationConfig(com.facebook.presto.server.InternalCommunicationConfig) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) Module(com.google.inject.Module) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) JsonModule(com.facebook.airlift.json.JsonModule) TestingDiscoveryModule(com.facebook.airlift.discovery.client.testing.TestingDiscoveryModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) Test(org.testng.annotations.Test)

Example 3 with TestingNodeModule

use of com.facebook.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.setRequiredConfigurationProperties(properties).doNotInitializeLogging().quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    store = injector.getInstance(BackupStore.class);
}
Also used : TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)3 TestingHttpServerModule (com.facebook.airlift.http.server.testing.TestingHttpServerModule)3 JaxrsModule (com.facebook.airlift.jaxrs.JaxrsModule)3 JsonModule (com.facebook.airlift.json.JsonModule)3 TestingNodeModule (com.facebook.airlift.node.testing.TestingNodeModule)3 Injector (com.google.inject.Injector)3 LifeCycleManager (com.facebook.airlift.bootstrap.LifeCycleManager)2 TestingJmxModule (com.facebook.airlift.jmx.testing.TestingJmxModule)2 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)1 DiscoveryBinder.discoveryBinder (com.facebook.airlift.discovery.client.DiscoveryBinder.discoveryBinder)1 ServiceSelector (com.facebook.airlift.discovery.client.ServiceSelector)1 TestingDiscoveryModule (com.facebook.airlift.discovery.client.testing.TestingDiscoveryModule)1 HttpServerInfo (com.facebook.airlift.http.server.HttpServerInfo)1 JaxrsBinder.jaxrsBinder (com.facebook.airlift.jaxrs.JaxrsBinder.jaxrsBinder)1 TraceTokenModule (com.facebook.airlift.tracetoken.TraceTokenModule)1 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)1 BlackHolePlugin (com.facebook.presto.plugin.blackhole.BlackHolePlugin)1 InternalCommunicationConfig (com.facebook.presto.server.InternalCommunicationConfig)1 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)1 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)1