Skip to content

Commit 7b36988

Browse files
committed
test
1 parent 995df57 commit 7b36988

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lucene/misc/src/test/org/apache/lucene/misc/store/TestDirectIODirectory.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,31 @@ public void testUseDirectIODefaults() throws Exception {
209209
OptionalLong.of(largeSize)));
210210
}
211211
}
212+
213+
// Ping-pong seeks should be really fast, since the position should be within buffer.
214+
// The test should complete within sub-second times, not minutes.
215+
public void testSeekSmall() throws IOException {
216+
Path tmpDir = createTempDir("testSeekSmall");
217+
int blockSize = Math.toIntExact(Files.getFileStore(tmpDir).getBlockSize());
218+
try (Directory dir = getDirectory(tmpDir)) {
219+
int len = atLeast(100);
220+
try (IndexOutput o = dir.createOutput("out", newIOContext(random()))) {
221+
byte[] b = new byte[len];
222+
for (int i = 0; i < len; i++) {
223+
b[i] = (byte) i;
224+
}
225+
o.writeBytes(b, 0, len);
226+
}
227+
try (IndexInput in = dir.openInput("out", newIOContext(random()))) {
228+
for (int i = 0; i < 100_000; i++) {
229+
in.seek(2);
230+
assertEquals(2, in.readByte());
231+
in.seek(1);
232+
assertEquals(1, in.readByte());
233+
in.seek(0);
234+
assertEquals(0, in.readByte());
235+
}
236+
}
237+
}
238+
}
212239
}

0 commit comments

Comments
 (0)