|
28 | 28 | import org.junit.jupiter.api.BeforeEach;
|
29 | 29 | import org.junit.jupiter.api.Test;
|
30 | 30 | import org.mockito.Mockito;
|
31 |
| -import org.junit.runner.RunWith; |
32 |
| -import org.junit.runners.Parameterized; |
33 | 31 |
|
34 | 32 | import java.io.File;
|
35 | 33 | import java.io.IOException;
|
|
41 | 39 | import java.util.List;
|
42 | 40 | import java.util.Optional;
|
43 | 41 | import java.util.Random;
|
44 |
| -import java.util.Collection; |
45 |
| -import java.util.Arrays; |
46 | 42 | import java.util.concurrent.ExecutorService;
|
47 | 43 | import java.util.concurrent.Executors;
|
48 | 44 | import java.util.concurrent.Future;
|
|
67 | 63 | import static org.mockito.Mockito.verify;
|
68 | 64 | import static org.mockito.Mockito.when;
|
69 | 65 |
|
70 |
| -@RunWith(Parameterized.class) |
71 | 66 | public class FileRecordsTest {
|
72 | 67 |
|
73 | 68 | private byte[][] values = new byte[][] {
|
74 | 69 | "abcd".getBytes(),
|
75 | 70 | "efgh".getBytes(),
|
76 | 71 | "ijkl".getBytes()
|
77 | 72 | };
|
78 |
| - private FileRecords fileRecords; |
| 73 | + protected FileRecords fileRecords; |
79 | 74 | private Time time;
|
80 |
| - private int initSize; |
81 |
| - private boolean usePMem; |
82 |
| - |
83 |
| - @Parameterized.Parameters |
84 |
| - public static Collection<Boolean> testCases() { |
85 |
| - return Arrays.asList(true, false); |
86 |
| - } |
87 |
| - |
88 |
| - public FileRecordsTest(boolean usePMem) { |
89 |
| - this.usePMem = usePMem; |
90 |
| - } |
91 | 75 |
|
92 | 76 | @BeforeEach
|
93 | 77 | public void setup() throws IOException {
|
94 |
| - if (usePMem) { |
95 |
| - String pmemDir = "/tmp/pmem"; |
96 |
| - File directory = new File(pmemDir); |
97 |
| - if (directory.exists()) { |
98 |
| - String[] entries = directory.list(); |
99 |
| - for (String s : entries) { |
100 |
| - File currentFile = new File(directory.getPath(), s); |
101 |
| - currentFile.delete(); |
102 |
| - } |
103 |
| - directory.delete(); |
104 |
| - } |
105 |
| - directory.mkdirs(); |
106 |
| - |
107 |
| - String path = pmemDir + "/heap"; |
108 |
| - long size = 1024L * 1024 * 1024 * 10; |
109 |
| - this.initSize = 10 * 1024 * 1024; |
110 |
| - PMemChannel.initHeap(path, size, initSize, 0.9); |
111 |
| - } |
112 |
| - |
113 | 78 | this.fileRecords = createFileRecords(values);
|
| 79 | + append(fileRecords, values); |
114 | 80 | this.time = new MockTime();
|
115 | 81 | }
|
116 | 82 |
|
@@ -149,18 +115,10 @@ public void testOutOfRangeSlice() {
|
149 | 115 | */
|
150 | 116 | @Test
|
151 | 117 | public void testFileSize() throws IOException {
|
152 |
| - if (usePMem) { |
153 |
| - assertEquals(fileRecords.channel().position(), fileRecords.sizeInBytes()); |
154 |
| - } else { |
155 |
| - assertEquals(fileRecords.channel().size(), fileRecords.sizeInBytes()); |
156 |
| - } |
| 118 | + assertEquals(fileRecords.channel().size(), fileRecords.sizeInBytes()); |
157 | 119 | for (int i = 0; i < 20; i++) {
|
158 | 120 | fileRecords.append(MemoryRecords.withRecords(CompressionType.NONE, new SimpleRecord("abcd".getBytes())));
|
159 |
| - if (usePMem) { |
160 |
| - assertEquals(fileRecords.channel().position(), fileRecords.sizeInBytes()); |
161 |
| - } else { |
162 |
| - assertEquals(fileRecords.channel().size(), fileRecords.sizeInBytes()); |
163 |
| - } |
| 121 | + assertEquals(fileRecords.channel().size(), fileRecords.sizeInBytes()); |
164 | 122 | }
|
165 | 123 | }
|
166 | 124 |
|
@@ -732,14 +690,8 @@ private static List<RecordBatch> batches(Records buffer) {
|
732 | 690 | return TestUtils.toList(buffer.batches());
|
733 | 691 | }
|
734 | 692 |
|
735 |
| - private FileRecords createFileRecords(byte[][] values) throws IOException { |
736 |
| - FileRecords fileRecords = null; |
737 |
| - if (usePMem) { |
738 |
| - fileRecords = FileRecords.open(tempFile(), true, false, initSize, true, FileRecords.FileChannelType.PMEM); |
739 |
| - } else { |
740 |
| - fileRecords = FileRecords.open(tempFile()); |
741 |
| - } |
742 |
| - append(fileRecords, values); |
| 693 | + protected FileRecords createFileRecords(byte[][] values) throws IOException { |
| 694 | + FileRecords fileRecords = FileRecords.open(tempFile()); |
743 | 695 | return fileRecords;
|
744 | 696 | }
|
745 | 697 |
|
|
0 commit comments