Search in sources :

Example 21 with LPSZ

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

the class MimeTypesCacheTest method testCannotRead2.

@Test()
public void testCannotRead2() 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 128;
        }
    }, "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 22 with LPSZ

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

the class AlterTableAttachPartitionTest method testCannotRenameDetachedFolderOnAttach.

@Test
public void testCannotRenameDetachedFolderOnAttach() throws Exception {
    AtomicInteger counter = new AtomicInteger(1);
    FilesFacadeImpl ff = new FilesFacadeImpl() {

        @Override
        public boolean rename(LPSZ from, LPSZ to) {
            if (Chars.endsWith(to, "2020-01-01") && counter.decrementAndGet() == 0) {
                return false;
            }
            return super.rename(from, to);
        }
    };
    testSqlFailedOnFsOperation(ff, "table 'dst' could not be altered: [", "]: File system error on trying to rename [from=");
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) Test(org.junit.Test)

Example 23 with LPSZ

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

the class AlterTableAttachPartitionTest method testCannotReadTimestampColumnFileDoesNotExist.

@Test
public void testCannotReadTimestampColumnFileDoesNotExist() throws Exception {
    AtomicInteger counter = new AtomicInteger(1);
    FilesFacadeImpl ff = new FilesFacadeImpl() {

        @Override
        public boolean exists(LPSZ name) {
            if (Chars.endsWith(name, "ts.d") && counter.decrementAndGet() == 0) {
                return false;
            }
            return super.exists(name);
        }
    };
    testSqlFailedOnFsOperation(ff, "table 'dst' could not be altered: [0]: Doesn't exist:");
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LPSZ(io.questdb.std.str.LPSZ) Test(org.junit.Test)

Example 24 with LPSZ

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

the class LineUdpParserImplTest method testCannotCreateTable.

@Test
public void testCannotCreateTable() throws Exception {
    TestFilesFacade ff = new TestFilesFacade() {

        boolean called = false;

        @Override
        public int mkdirs(LPSZ path, int mode) {
            if (Chars.endsWith(path, "x" + Files.SEPARATOR)) {
                called = true;
                return -1;
            }
            return super.mkdirs(path, mode);
        }

        @Override
        public boolean wasCalled() {
            return called;
        }
    };
    final String expected = "sym\tdouble\tint\tbool\tstr\ttimestamp\n" + "zzz\t1.3\t11\tfalse\tnice\t2017-10-03T10:00:00.000000Z\n";
    String lines = "x,sym2=xyz double=1.6,int=15i,bool=true,str=\"string1\"\n" + "x,sym1=abc double=1.3,int=11i,bool=false,str=\"string2\"\n" + "y,sym=zzz double=1.3,int=11i,bool=false,str=\"nice\"\n";
    CairoConfiguration configuration = new DefaultCairoConfiguration(root) {

        @Override
        public FilesFacade getFilesFacade() {
            return ff;
        }

        @Override
        public MicrosecondClock getMicrosecondClock() {
            try {
                return new TestMicroClock(TimestampFormatUtils.parseTimestamp("2017-10-03T10:00:00.000Z"), 10);
            } catch (NumericException e) {
                throw new RuntimeException(e);
            }
        }
    };
    assertThat(expected, lines, "y", configuration);
    Assert.assertTrue(ff.wasCalled());
    try (Path path = new Path()) {
        Assert.assertEquals(TableUtils.TABLE_DOES_NOT_EXIST, TableUtils.exists(ff, path, root, "all"));
    }
}
Also used : Path(io.questdb.std.str.Path) LPSZ(io.questdb.std.str.LPSZ) TestMicroClock(io.questdb.test.tools.TestMicroClock) Test(org.junit.Test)

Example 25 with LPSZ

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

the class MimeTypesCacheTest method testWrongFileSize2.

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

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

        @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