Skip to content

Commit ec07b3e

Browse files
committed
some cleanup
1 parent 5df2180 commit ec07b3e

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

fdb-record-layer-lucene/src/test/java/com/apple/foundationdb/record/lucene/LuceneIndexScrubbingTest.java

+20-17
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252

5353
class LuceneIndexScrubbingTest extends FDBLuceneTestBase {
5454

55-
TestingIndexMaintainerRegistry registry;
55+
private TestingIndexMaintainerRegistry registry;
56+
private boolean flipBoolean = false;
5657

5758
@BeforeEach
5859
public void beforeEach() {
@@ -65,13 +66,18 @@ private void rebuildIndexMetaData(final FDBRecordContext context, final String d
6566
this.planner = pair.getRight();
6667
}
6768

68-
public static Stream<Arguments> threeBooleanArgs() {
69+
private static Stream<Arguments> threeBooleanArgs() {
6970
return Stream.of(false, true)
7071
.flatMap(isSynthetic -> Stream.of(false, true)
7172
.flatMap(isPartitioned -> Stream.of(false, true)
7273
.map(isGrouped -> Arguments.of(isSynthetic, isGrouped, isPartitioned))));
7374
}
7475

76+
private boolean yinYang() {
77+
flipBoolean = !flipBoolean;
78+
return flipBoolean;
79+
}
80+
7581
@Nonnull
7682
protected FDBRecordStore.Builder getStoreBuilderWithRegistry(@Nonnull FDBRecordContext context,
7783
@Nonnull RecordMetaDataProvider metaData,
@@ -91,10 +97,8 @@ void luceneIndexScrubMissingDataModelNoIssues(boolean isSynthetic, boolean isGro
9197
.setPartitionHighWatermark(isPartitioned ? 5 : 0)
9298
.build();
9399

94-
boolean flipFlop = false;
95100
for (int i = 0; i < 14; i++) {
96-
dataModel.setReverseSaveOrder(flipFlop);
97-
flipFlop = !flipFlop;
101+
dataModel.setReverseSaveOrder(yinYang());
98102
try (final FDBRecordContext context = openContext()) {
99103
dataModel.saveRecords(7, context, i / 6);
100104
context.commit();
@@ -108,6 +112,7 @@ void luceneIndexScrubMissingDataModelNoIssues(boolean isSynthetic, boolean isGro
108112

109113
try (final FDBRecordContext context = openContext()) {
110114
dataModel.explicitMergeIndex(context, timer);
115+
context.commit();
111116
}
112117
try (final FDBRecordContext context = openContext()) {
113118
FDBRecordStore store = dataModel.createOrOpenRecordStore(context);
@@ -176,39 +181,36 @@ void luceneIndexScrubMissingDataModel(boolean isSynthetic, boolean isGrouped, bo
176181
.setPartitionHighWatermark(isPartitioned ? 5 : 0)
177182
.build();
178183

179-
try (final FDBRecordContext context = openContext()) {
180-
context.commit();
181-
}
182-
183184
final InjectedFailureRepository injectedFailures = new InjectedFailureRepository();
184185
registry.overrideFactory(new MockedLuceneIndexMaintainerFactory(injectedFailures));
185186

186-
boolean flipFlop = false;
187187
for (int i = 0; i < 14; i++) {
188-
dataModel.setReverseSaveOrder(flipFlop);
189-
flipFlop = !flipFlop;
188+
dataModel.setReverseSaveOrder(yinYang());
190189
try (final FDBRecordContext context = openContext()) {
191190
dataModel.saveRecords(7, context, i / 6);
192191
context.commit();
193192
}
194193
}
195-
try (FDBRecordContext context = openContext()) {
196-
final FDBRecordStore recordStore = dataModel.createOrOpenRecordStore(context);
197-
dataModel.sampleRecordsUnderTest().forEach(sampleRecord -> sampleRecord.deleteRecord(recordStore).join());
198-
context.commit();
199-
}
200194

201195
try (final FDBRecordContext context = openContext()) {
202196
dataModel.explicitMergeIndex(context, timer);
197+
context.commit();
203198
}
204199

205200
try (final FDBRecordContext context = openContext()) {
206201
// Write some documents
207202
dataModel.saveRecordsToAllGroups(7, context);
203+
context.commit();
208204
}
209205

206+
try (FDBRecordContext context = openContext()) {
207+
final FDBRecordStore recordStore = dataModel.createOrOpenRecordStore(context);
208+
dataModel.sampleRecordsUnderTest().forEach(sampleRecord -> sampleRecord.deleteRecord(recordStore).join());
209+
context.commit();
210+
}
210211
try (final FDBRecordContext context = openContext()) {
211212
dataModel.explicitMergeIndex(context, timer);
213+
context.commit();
212214
}
213215

214216
try (final FDBRecordContext context = openContext()) {
@@ -229,6 +231,7 @@ void luceneIndexScrubMissingDataModel(boolean isSynthetic, boolean isGrouped, bo
229231

230232
try (final FDBRecordContext context = openContext()) {
231233
dataModel.explicitMergeIndex(context, timer);
234+
context.commit();
232235
}
233236

234237
try (final FDBRecordContext context = openContext()) {

0 commit comments

Comments
 (0)