use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testNoServerCertificateShouldNotSendRequest.
@Test
public void testNoServerCertificateShouldNotSendRequest() throws Exception {
server.enqueue(new MockResponse().setResponseCode(200));
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", new URL("https", server.getHostName(), server.getPort(), "/").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);
assertNull(recordedRequest, "Handshake should have failed");
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testServerDelayDoesNotBlock.
@Test
public void testServerDelayDoesNotBlock() throws Exception {
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", server.url("/").toString(), "http-event-listener.log-completed", "true"));
server.enqueue(new MockResponse().setResponseCode(200).setHeadersDelay(5, TimeUnit.SECONDS));
long startTime = System.nanoTime();
eventListener.queryCompleted(queryCompleteEvent);
long endTime = System.nanoTime();
assertTrue(Duration.of(endTime - startTime, ChronoUnit.NANOS).compareTo(Duration.of(1, ChronoUnit.SECONDS)) < 0, "Server delay is blocking main thread");
checkRequest(server.takeRequest(5, TimeUnit.SECONDS), queryCompleteEventJson);
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testAllLoggingDisabledShouldTimeout.
/**
* Listener created without exceptions but not requests sent
*/
@Test
public void testAllLoggingDisabledShouldTimeout() throws Exception {
server.enqueue(new MockResponse().setResponseCode(200));
EventListener eventListener = factory.create(Map.of("http-event-listener.connect-ingest-uri", server.url("/").toString()));
eventListener.queryCreated(null);
eventListener.queryCompleted(null);
eventListener.splitCompleted(null);
assertNull(server.takeRequest(5, TimeUnit.SECONDS));
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestAccessControlManager method testRegisterSingleEventListener.
@Test
public void testRegisterSingleEventListener() throws IOException {
EventListener expectedListener = new EventListener() {
};
String systemAccessControlName = "event-listening-sac";
TestingEventListenerManager eventListenerManager = emptyEventListenerManager();
AccessControlManager accessControlManager = createAccessControlManager(eventListenerManager, ImmutableList.of("access-control.name=" + systemAccessControlName));
accessControlManager.addSystemAccessControlFactory(eventListeningSystemAccessControlFactory(systemAccessControlName, expectedListener));
accessControlManager.loadSystemAccessControl();
assertThat(eventListenerManager.getConfiguredEventListeners()).contains(expectedListener);
}
use of io.trino.spi.eventlistener.EventListener in project trino by trinodb.
the class TestHttpEventListener method testHttpHeadersShouldBePresent.
@Test
public void testHttpHeadersShouldBePresent() 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-http-headers", "Authorization: Trust Me!, Cache-Control: no-cache"));
server.enqueue(new MockResponse().setResponseCode(200));
eventListener.queryCompleted(queryCompleteEvent);
checkRequest(server.takeRequest(5, TimeUnit.SECONDS), Map.of("Authorization", "Trust Me!", "Cache-Control", "no-cache"), queryCompleteEventJson);
}
Aggregations