Search in sources :

Example 26 with ServerConfiguration

use of com.questdb.ServerConfiguration in project questdb by bluestreak01.

the class HttpServerTest method testLargeChunkedSSLGzipDownload.

@Test
public void testLargeChunkedSSLGzipDownload() throws Exception {
    final int count = 3;
    final int sz = 16 * 1026 * 1024 - 4;
    final ServerConfiguration configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
    configuration.getSslConfig().setSecure(true);
    configuration.getSslConfig().setKeyStore(new FileInputStream(resourceFile("/keystore/singlekey.ks")), "changeit");
    configuration.setHttpBufRespContent(sz + 4);
    TestUtils.assertEquals(generateLarge(count, sz), downloadChunked(configuration, count, sz, true, true));
}
Also used : ServerConfiguration(com.questdb.ServerConfiguration) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 27 with ServerConfiguration

use of com.questdb.ServerConfiguration in project questdb by bluestreak01.

the class HttpServerTest method testRangesNative.

@Test
// fix is in server, which would allow limited number of this iterations after which connection is closed.
@Ignore
public void testRangesNative() throws Exception {
    BootstrapEnv env = new BootstrapEnv();
    env.configuration = new ServerConfiguration(new File(HttpServerTest.class.getResource("/site").getPath(), "conf/questdb.conf")) {

        @Override
        public File getHttpPublic() {
            return temp.getRoot();
        }
    };
    env.configuration.setHttpThreads(1);
    env.configuration.setHttpSoRetries(10);
    env.configuration.getSslConfig().setSecure(false);
    env.matcher = new SimpleUrlMatcher() {

        {
            put("/upload", new UploadHandler(env.configuration.getHttpPublic()));
            setDefaultHandler(new StaticContentHandler(env));
        }
    };
    assertRanges(new HttpServer(env));
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) StaticContentHandler(com.questdb.net.http.handlers.StaticContentHandler) ServerConfiguration(com.questdb.ServerConfiguration) UploadHandler(com.questdb.net.http.handlers.UploadHandler) Ignore(org.junit.Ignore) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 28 with ServerConfiguration

use of com.questdb.ServerConfiguration in project questdb by bluestreak01.

the class HttpServerTest method testImportIntoBusyJournal.

@Test
public void testImportIntoBusyJournal() throws Exception {
    try (JournalWriter ignored = getFactory().writer(new JournalStructure("test-import.csv").$int("x").$())) {
        BootstrapEnv env = new BootstrapEnv();
        env.configuration = new ServerConfiguration();
        env.factory = getFactory();
        env.typeProbeCollection = TYPE_PROBE_COLLECTION;
        env.matcher = new SimpleUrlMatcher() {

            {
                put("/imp", new ImportHandler(env));
            }
        };
        HttpServer server = new HttpServer(env);
        server.start();
        StringBuilder response = new StringBuilder();
        try {
            Assert.assertEquals(200, HttpTestUtils.upload("/csv/test-import.csv", "http://localhost:9000/imp?fmt=json", null, response));
            TestUtils.assertEquals("{\"status\":\"Journal exists and column count does not match\"}", response);
        } catch (IOException e) {
            Assert.assertTrue(e.getMessage().contains("Connection reset"));
        } finally {
            server.halt();
        }
    }
}
Also used : JournalWriter(com.questdb.store.JournalWriter) BootstrapEnv(com.questdb.BootstrapEnv) JournalStructure(com.questdb.store.factory.configuration.JournalStructure) ServerConfiguration(com.questdb.ServerConfiguration) ImportHandler(com.questdb.net.http.handlers.ImportHandler) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 29 with ServerConfiguration

use of com.questdb.ServerConfiguration in project questdb by bluestreak01.

the class HttpServerTest method testConnectionCount.

@Test
public void testConnectionCount() throws Exception {
    final BootstrapEnv env = new BootstrapEnv();
    env.configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
    env.configuration.setHttpMaxConnections(10);
    env.matcher = new SimpleUrlMatcher() {

        {
            setDefaultHandler(new StaticContentHandler(env));
        }
    };
    HttpServer server = new HttpServer(env);
    server.start();
    try {
        CloseableHttpClient c1 = clientBuilder(true).build();
        CloseableHttpClient c2 = clientBuilder(true).build();
        CloseableHttpClient c3 = clientBuilder(true).build();
        CloseableHttpClient c4 = clientBuilder(true).build();
        Assert.assertNotNull(c1.execute(new HttpGet("https://localhost:9000/upload.html")));
        Assert.assertEquals(1, server.getConnectionCount());
        Assert.assertNotNull(c2.execute(new HttpGet("https://localhost:9000/upload.html")));
        Assert.assertEquals(2, server.getConnectionCount());
        Assert.assertNotNull(c3.execute(new HttpGet("https://localhost:9000/upload.html")));
        Assert.assertEquals(3, server.getConnectionCount());
        Assert.assertNotNull(c4.execute(new HttpGet("https://localhost:9000/upload.html")));
        Assert.assertEquals(4, server.getConnectionCount());
        c1.close();
        c2.close();
        Thread.sleep(300);
        Assert.assertEquals(2, server.getConnectionCount());
        c3.close();
        c4.close();
        Thread.sleep(300);
        Assert.assertEquals(0, server.getConnectionCount());
    } finally {
        server.halt();
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) BootstrapEnv(com.questdb.BootstrapEnv) StaticContentHandler(com.questdb.net.http.handlers.StaticContentHandler) ServerConfiguration(com.questdb.ServerConfiguration) HttpGet(org.apache.http.client.methods.HttpGet) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 30 with ServerConfiguration

use of com.questdb.ServerConfiguration in project questdb by bluestreak01.

the class HttpServerTest method testSslConcurrentDownload.

@Test
public void testSslConcurrentDownload() throws Exception {
    BootstrapEnv env = new BootstrapEnv();
    env.configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
    env.configuration.getSslConfig().setSecure(true);
    env.configuration.getSslConfig().setKeyStore(new FileInputStream(resourceFile("/keystore/singlekey.ks")), "changeit");
    env.matcher = new SimpleUrlMatcher() {

        {
            setDefaultHandler(new StaticContentHandler(env));
        }
    };
    final MimeTypes mimeTypes = new MimeTypes(env.configuration.getMimeTypes());
    HttpServer server = new HttpServer(env);
    server.start();
    assertConcurrentDownload(mimeTypes, server, "https");
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) StaticContentHandler(com.questdb.net.http.handlers.StaticContentHandler) ServerConfiguration(com.questdb.ServerConfiguration) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Aggregations

ServerConfiguration (com.questdb.ServerConfiguration)38 Test (org.junit.Test)34 BootstrapEnv (com.questdb.BootstrapEnv)33 AbstractJournalTest (com.questdb.net.ha.AbstractJournalTest)29 ImportHandler (com.questdb.net.http.handlers.ImportHandler)13 StringSink (com.questdb.std.str.StringSink)11 StaticContentHandler (com.questdb.net.http.handlers.StaticContentHandler)9 QueryCompiler (com.questdb.parser.sql.QueryCompiler)9 RecordSourcePrinter (com.questdb.ql.RecordSourcePrinter)9 JournalWriter (com.questdb.store.JournalWriter)4 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)4 AbstractOptimiserTest (com.questdb.parser.sql.AbstractOptimiserTest)3 RecordSource (com.questdb.ql.RecordSource)3 JournalEntryWriter (com.questdb.store.JournalEntryWriter)3 SocketException (java.net.SocketException)3 ResponseContentBufferTooSmallException (com.questdb.ex.ResponseContentBufferTooSmallException)2 HttpServer (com.questdb.net.http.HttpServer)2 IOContext (com.questdb.net.http.IOContext)2 SimpleUrlMatcher (com.questdb.net.http.SimpleUrlMatcher)2 UploadHandler (com.questdb.net.http.handlers.UploadHandler)2