use of io.questdb.std.FilesFacadeImpl 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());
}
use of io.questdb.std.FilesFacadeImpl 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());
}
use of io.questdb.std.FilesFacadeImpl 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());
}
use of io.questdb.std.FilesFacadeImpl 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());
}
use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.
the class SampleByTest method testSampleFillLinearConstructorFail.
@Test
public void testSampleFillLinearConstructorFail() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x as " + "(" + "select" + " rnd_double(0)*100 a," + " rnd_symbol(5,4,4,1) b," + " timestamp_sequence(172800000000, 3600000000) k" + " from" + " long_sequence(20000000)" + ") timestamp(k) partition by NONE", sqlExecutionContext);
FilesFacade ff = new FilesFacadeImpl() {
int count = 4;
@Override
public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
if (count-- > 0) {
return super.mmap(fd, len, offset, flags, memoryTag);
}
return -1;
}
};
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
try (CairoEngine engine = new CairoEngine(configuration)) {
try (SqlCompiler compiler = new SqlCompiler(engine)) {
try {
compiler.compile("select b, sum(a), k from x sample by 3h fill(linear)", sqlExecutionContext);
Assert.fail();
} catch (SqlException e) {
Assert.assertTrue(Chars.contains(e.getMessage(), "could not mmap"));
}
Assert.assertEquals(0, engine.getBusyReaderCount());
Assert.assertEquals(0, engine.getBusyWriterCount());
}
}
});
}
Aggregations