Search in sources :

Example 16 with LPSZ

use of io.questdb.std.str.LPSZ in project questdb by bluestreak01.

the class O3FailureTest method testPartitionedDataAppendOOData.

@Test
public void testPartitionedDataAppendOOData() throws Exception {
    counter.set(4);
    executeWithoutPool(O3FailureTest::testPartitionedDataAppendOODataFailRetry0, new FilesFacadeImpl() {

        private final AtomicInteger mapCounter = new AtomicInteger(2);

        private long theFd = 0;

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (theFd == fd && mapCounter.decrementAndGet() == 0) {
                theFd = 0;
                return -1;
            }
            return super.mmap(fd, len, offset, flags, memoryTag);
        }

        @Override
        public long openRW(LPSZ name) {
            long fd = super.openRW(name);
            if (Chars.endsWith(name, "ts.d") && counter.decrementAndGet() == 0) {
                theFd = fd;
            }
            return fd;
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 17 with LPSZ

use of io.questdb.std.str.LPSZ in project questdb by bluestreak01.

the class LineTcpConnectionContextTest method testCairoExceptionOnAddColumn.

@Test
public void testCairoExceptionOnAddColumn() throws Exception {
    String table = "columnEx";
    runInContext(new FilesFacadeImpl() {

        @Override
        public long openRW(LPSZ name) {
            if (Chars.endsWith(name, "broken.d")) {
                return -1;
            }
            return super.openRW(name);
        }
    }, () -> {
        recvBuffer = table + ",location=us-midwest temperature=82 1465839830100400200\n" + table + ",location=us-midwest temperature=83 1465839830100500200\n" + table + ",location=us-eastcoast temperature=81,broken=23 1465839830101400200\n" + table + ",location=us-midwest temperature=85 1465839830102300200\n" + table + ",location=us-eastcoast temperature=89 1465839830102400200\n" + table + ",location=us-eastcoast temperature=80 1465839830102400200\n" + table + ",location=us-westcost temperature=82 1465839830102500200\n";
        do {
            handleContextIO();
            Assert.assertFalse(disconnected);
        } while (recvBuffer.length() > 0);
        closeContext();
        String expected = "location\ttemperature\ttimestamp\n" + "us-midwest\t82.0\t2016-06-13T17:43:50.100400Z\n" + "us-midwest\t83.0\t2016-06-13T17:43:50.100500Z\n" + "us-midwest\t85.0\t2016-06-13T17:43:50.102300Z\n" + "us-eastcoast\t89.0\t2016-06-13T17:43:50.102400Z\n" + "us-eastcoast\t80.0\t2016-06-13T17:43:50.102400Z\n" + "us-westcost\t82.0\t2016-06-13T17:43:50.102500Z\n";
        assertTable(expected, table);
    }, null, null);
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 18 with LPSZ

use of io.questdb.std.str.LPSZ in project questdb by bluestreak01.

the class MimeTypesCacheTest method testCannotRead1.

@Test()
public void testCannotRead1() throws Exception {
    AtomicInteger closeCount = new AtomicInteger(0);
    testFailure(new FilesFacadeImpl() {

        @Override
        public boolean close(long fd) {
            closeCount.incrementAndGet();
            return true;
        }

        @Override
        public long length(long fd) {
            return 1024;
        }

        @Override
        public long openRO(LPSZ name) {
            return 123L;
        }

        @Override
        public long read(long fd, long buf, long len, long offset) {
            return -1;
        }
    }, "could not read");
    Assert.assertEquals(1, closeCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 19 with LPSZ

use of io.questdb.std.str.LPSZ in project questdb by bluestreak01.

the class MimeTypesCacheTest method testWrongFileSize4.

@Test()
public void testWrongFileSize4() throws Exception {
    AtomicInteger closeCount = new AtomicInteger();
    testFailure(new FilesFacadeImpl() {

        @Override
        public long length(long fd) {
            return 1024 * 1024 * 2;
        }

        @Override
        public long openRO(LPSZ name) {
            return 123L;
        }

        @Override
        public boolean close(long fd) {
            closeCount.incrementAndGet();
            return true;
        }
    }, "wrong file size");
    Assert.assertEquals(1, closeCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 20 with LPSZ

use of io.questdb.std.str.LPSZ in project questdb by bluestreak01.

the class MimeTypesCacheTest method testWrongFileSize.

@Test()
public void testWrongFileSize() throws Exception {
    AtomicInteger closeCount = new AtomicInteger();
    testFailure(new FilesFacadeImpl() {

        @Override
        public long length(long fd) {
            return 0;
        }

        @Override
        public long openRO(LPSZ name) {
            return 123L;
        }

        @Override
        public boolean close(long fd) {
            closeCount.incrementAndGet();
            return true;
        }
    }, "wrong file size");
    Assert.assertEquals(1, closeCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Aggregations

LPSZ (io.questdb.std.str.LPSZ)50 Test (org.junit.Test)49 FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)35 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 RecordCursor (io.questdb.cairo.sql.RecordCursor)8 Record (io.questdb.cairo.sql.Record)7 Path (io.questdb.std.str.Path)5 FilesFacade (io.questdb.std.FilesFacade)3 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)1 MemoryCMARW (io.questdb.cairo.vm.api.MemoryCMARW)1 MemoryMA (io.questdb.cairo.vm.api.MemoryMA)1 TestMicroClock (io.questdb.test.tools.TestMicroClock)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1