use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testServerShouldRetry.
@Test(dataProvider = "retryStatusCodes")
public void testServerShouldRetry(int responseCode) throws Exception {
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", server.url("/").toString(), "http-event-listener.log-completed", "true", "http-event-listener.connect-retry-count", "1"));
server.enqueue(new MockResponse().setResponseCode(responseCode));
server.enqueue(new MockResponse().setResponseCode(200));
eventListener.queryCompleted(queryCompleteEvent);
assertNotNull(server.takeRequest(5, TimeUnit.SECONDS));
checkRequest(server.takeRequest(5, TimeUnit.SECONDS), queryCompleteEventJson);
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testHttpsEnabledShouldUseTLSv13.
@Test
public void testHttpsEnabledShouldUseTLSv13() throws Exception {
setupServerTLSCertificate();
server.enqueue(new MockResponse().setResponseCode(200));
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", server.url("/").toString(), "http-event-listener.log-completed", "true", "http-event-listener.http-client.key-store-path", "src/test/resources/trino-httpquery-test.p12", "http-event-listener.http-client.key-store-password", "testing-ssl"));
eventListener.queryCompleted(queryCompleteEvent);
RecordedRequest recordedRequest = server.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(recordedRequest, "Handshake probably failed");
assertEquals(recordedRequest.getTlsVersion().javaName(), "TLSv1.3");
checkRequest(recordedRequest, queryCompleteEventJson);
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testAllLoggingEnabledShouldSendCorrectEvent.
@Test
public void testAllLoggingEnabledShouldSendCorrectEvent() throws Exception {
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", server.url("/").toString(), "http-event-listener.log-completed", "true", "http-event-listener.log-created", "true", "http-event-listener.log-split", "true"));
server.enqueue(new MockResponse().setResponseCode(200));
server.enqueue(new MockResponse().setResponseCode(200));
server.enqueue(new MockResponse().setResponseCode(200));
eventListener.queryCreated(queryCreatedEvent);
checkRequest(server.takeRequest(5, TimeUnit.SECONDS), queryCreatedEventJson);
eventListener.queryCompleted(queryCompleteEvent);
checkRequest(server.takeRequest(5, TimeUnit.SECONDS), queryCompleteEventJson);
eventListener.splitCompleted(splitCompleteEvent);
checkRequest(server.takeRequest(5, TimeUnit.SECONDS), splitCompleteEventJson);
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testDifferentCertificatesShouldNotSendRequest.
@Test
public void testDifferentCertificatesShouldNotSendRequest() throws Exception {
setupServerTLSCertificate();
server.enqueue(new MockResponse().setResponseCode(200));
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", server.url("/").toString(), "http-event-listener.log-completed", "true", "http-event-listener.http-client.key-store-path", "src/test/resources/trino-httpquery-test2.p12", "http-event-listener.http-client.key-store-password", "testing-ssl"));
eventListener.queryCompleted(queryCompleteEvent);
RecordedRequest recordedRequest = server.takeRequest(5, TimeUnit.SECONDS);
assertNull(recordedRequest, "Handshake should have failed");
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class EventListenerManager method createEventListener.
private EventListener createEventListener(File configFile) {
log.info("-- Loading event listener %s --", configFile);
configFile = configFile.getAbsoluteFile();
Map<String, String> properties = loadEventListenerProperties(configFile);
String name = properties.remove(EVENT_LISTENER_NAME_PROPERTY);
checkArgument(!isNullOrEmpty(name), "EventListener plugin configuration for %s does not contain %s", configFile, EVENT_LISTENER_NAME_PROPERTY);
EventListenerFactory factory = eventListenerFactories.get(name);
checkArgument(factory != null, "Event listener factory '%s' is not registered. Available factories: %s", name, eventListenerFactories.keySet());
EventListener eventListener;
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
eventListener = factory.create(properties);
}
log.info("-- Loaded event listener %s --", configFile);
return eventListener;
}
Aggregations