Search in sources :

Example 1 with ServerConfiguration

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

the class HttpServerTest method testMaxConnections.

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

        {
            setDefaultHandler(new StaticContentHandler(env));
        }
    };
    HttpServer server = new HttpServer(env);
    server.start();
    try {
        Assert.assertNotNull(clientBuilder(true).build().execute(new HttpGet("https://localhost:9000/upload.html")));
        try {
            clientBuilder(true).build().execute(new HttpGet("https://localhost:9000/upload.html"));
            Assert.fail("Expected server to reject connection");
        } catch (Exception ignored) {
        }
    } finally {
        server.halt();
    }
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) StaticContentHandler(com.questdb.net.http.handlers.StaticContentHandler) ServerConfiguration(com.questdb.ServerConfiguration) HttpGet(org.apache.http.client.methods.HttpGet) ResponseContentBufferTooSmallException(com.questdb.ex.ResponseContentBufferTooSmallException) SocketException(java.net.SocketException) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 2 with ServerConfiguration

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

the class HttpServerTest method testUpload.

@Test
public void testUpload() throws Exception {
    final File dir = temp.newFolder();
    BootstrapEnv env = new BootstrapEnv();
    env.configuration = new ServerConfiguration();
    env.matcher = new SimpleUrlMatcher() {

        {
            put("/upload", new UploadHandler(dir));
        }
    };
    HttpServer server = new HttpServer(env);
    server.start();
    File expected = resourceFile("/csv/test-import.csv");
    File actual = new File(dir, "test-import.csv");
    upload(expected);
    TestUtils.assertEquals(expected, actual);
    server.halt();
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) ServerConfiguration(com.questdb.ServerConfiguration) UploadHandler(com.questdb.net.http.handlers.UploadHandler) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 3 with ServerConfiguration

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

the class HttpServerTest method testNativeNotModified.

@Test
public void testNativeNotModified() throws Exception {
    BootstrapEnv env = new BootstrapEnv();
    env.configuration = new ServerConfiguration(new File(resourceFile("/site"), "conf/questdb.conf"));
    env.configuration.getSslConfig().setSecure(false);
    env.matcher = new SimpleUrlMatcher() {

        {
            setDefaultHandler(new StaticContentHandler(env));
        }
    };
    HttpServer server = new HttpServer(env);
    assertNotModified(env.configuration, server);
}
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)

Example 4 with ServerConfiguration

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

the class HttpServerTest method testImportNumericHeader.

@Test
public void testImportNumericHeader() throws Exception {
    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();
    try {
        StringSink sink = new StringSink();
        RecordSourcePrinter printer = new RecordSourcePrinter(sink);
        QueryCompiler qc = new QueryCompiler(env);
        Assert.assertEquals(200, HttpTestUtils.upload("/csv/test-numeric-headers.csv", "http://localhost:9000/imp?name=test-import.csv&overwrite=true&durable=true&forceHeader=true", null, null));
        printer.print(qc.compile(getFactory(), "select count() from 'test-import.csv'"), getFactory());
        // expect first line to be treated as header
        TestUtils.assertEquals("2\n", sink);
    } finally {
        server.halt();
    }
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) ServerConfiguration(com.questdb.ServerConfiguration) RecordSourcePrinter(com.questdb.ql.RecordSourcePrinter) ImportHandler(com.questdb.net.http.handlers.ImportHandler) StringSink(com.questdb.std.str.StringSink) QueryCompiler(com.questdb.parser.sql.QueryCompiler) AbstractJournalTest(com.questdb.net.ha.AbstractJournalTest) Test(org.junit.Test)

Example 5 with ServerConfiguration

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

the class HttpServerTest method testImportUtf8.

@Test
public void testImportUtf8() throws Exception {
    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();
    try {
        StringSink sink = new StringSink();
        RecordSourcePrinter printer = new RecordSourcePrinter(sink);
        QueryCompiler qc = new QueryCompiler(env);
        Assert.assertEquals(200, HttpTestUtils.upload("/csv/test-import-utf8.csv", "http://localhost:9000/imp?overwrite=true&durable=true", null, null));
        printer.print(qc.compile(getFactory(), "'test-import-utf8.csv'"), getFactory());
        // expect first line to be treated as header
        TestUtils.assertEquals("авг\tавг\n", sink);
    } finally {
        server.halt();
    }
}
Also used : BootstrapEnv(com.questdb.BootstrapEnv) ServerConfiguration(com.questdb.ServerConfiguration) RecordSourcePrinter(com.questdb.ql.RecordSourcePrinter) ImportHandler(com.questdb.net.http.handlers.ImportHandler) StringSink(com.questdb.std.str.StringSink) QueryCompiler(com.questdb.parser.sql.QueryCompiler) 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