Skip to content

Commit f1e436a

Browse files
committed
Some minor test cleanup
1 parent 5a24630 commit f1e436a

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/DataInKeySpacePathTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class DataInKeySpacePathTest {
5454

5555
@ParameterizedTest
5656
@ValueSource(ints = {0, 1, 2, 3, 4, 5})
57-
void testResolution() {
57+
void resolution() {
5858
// Include some extra children to make sure resolution doesn't get confused
5959
final String companyUuid = UUID.randomUUID().toString();
6060
KeySpace root = new KeySpace(
@@ -113,7 +113,7 @@ void testResolution() {
113113
}
114114

115115
@Test
116-
void testPathWithConstantValues() {
116+
void pathWithConstantValues() {
117117
final String appUuid = UUID.randomUUID().toString();
118118
KeySpace root = new KeySpace(
119119
new KeySpaceDirectory("application", KeyType.STRING, appUuid)
@@ -167,7 +167,7 @@ void testPathWithConstantValues() {
167167
}
168168

169169
@Test
170-
void testPathWithDirectoryLayer() {
170+
void pathWithDirectoryLayer() {
171171
final String tenantUuid = UUID.randomUUID().toString();
172172
KeySpace root = new KeySpace(
173173
new DirectoryLayerDirectory("tenant", tenantUuid)
@@ -207,7 +207,7 @@ void testPathWithDirectoryLayer() {
207207
}
208208

209209
@Test
210-
void testPathWithBinaryData() {
210+
void pathWithBinaryData() {
211211
final String storeUuid = UUID.randomUUID().toString();
212212
KeySpace root = new KeySpace(
213213
new KeySpaceDirectory("binary_store", KeyType.STRING, storeUuid)
@@ -250,7 +250,7 @@ void testPathWithBinaryData() {
250250
}
251251

252252
@Test
253-
void testKeyValueAccessors() {
253+
void keyValueAccessors() {
254254
KeySpace root = new KeySpace(
255255
new KeySpaceDirectory("test", KeyType.STRING, UUID.randomUUID().toString()));
256256

@@ -279,7 +279,7 @@ void testKeyValueAccessors() {
279279
}
280280

281281
@Test
282-
void testWithWrapper() {
282+
void withWrapper() {
283283
final FDBDatabase database = dbExtension.getDatabase();
284284
final EnvironmentKeySpace keySpace = EnvironmentKeySpace.setupSampleData(database);
285285

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathDataExportTest.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class KeySpacePathDataExportTest {
6565
final FDBDatabaseExtension dbExtension = new FDBDatabaseExtension();
6666

6767
@Test
68-
void testExportAllDataFromSimplePath() {
68+
void exportAllDataFromSimplePath() {
6969
KeySpace root = new KeySpace(
7070
new KeySpaceDirectory("root", KeyType.STRING, UUID.randomUUID().toString())
7171
.addSubdirectory(new KeySpaceDirectory("level1", KeyType.LONG)));
@@ -108,7 +108,7 @@ void testExportAllDataFromSimplePath() {
108108
}
109109

110110
@Test
111-
void testExportAllDataFromSpecificSubPath() {
111+
void exportAllDataFromSpecificSubPath() {
112112
KeySpace root = new KeySpace(
113113
new KeySpaceDirectory("app", KeyType.STRING, UUID.randomUUID().toString())
114114
.addSubdirectory(new KeySpaceDirectory("user", KeyType.LONG)
@@ -150,7 +150,7 @@ void testExportAllDataFromSpecificSubPath() {
150150
}
151151

152152
@Test
153-
void testExportAllDataWithDirectoryLayer() {
153+
void exportAllDataWithDirectoryLayer() {
154154
KeySpace root = new KeySpace(
155155
new DirectoryLayerDirectory("env", UUID.randomUUID().toString())
156156
.addSubdirectory(new KeySpaceDirectory("tenant", KeyType.LONG)
@@ -199,7 +199,7 @@ void testExportAllDataWithDirectoryLayer() {
199199
}
200200

201201
@Test
202-
void testExportAllDataWithDifferentKeyTypes() {
202+
void exportAllDataWithDifferentKeyTypes() {
203203
KeySpace root = new KeySpace(
204204
new KeySpaceDirectory("mixed", KeyType.STRING, UUID.randomUUID().toString())
205205
.addSubdirectory(new KeySpaceDirectory("strings", KeyType.STRING))
@@ -250,7 +250,7 @@ void testExportAllDataWithDifferentKeyTypes() {
250250
}
251251

252252
@Test
253-
void testExportAllDataWithConstantValues() {
253+
void exportAllDataWithConstantValues() {
254254
KeySpace root = new KeySpace(
255255
new KeySpaceDirectory("app", KeyType.STRING, UUID.randomUUID().toString())
256256
.addSubdirectory(new KeySpaceDirectory("version", KeyType.LONG, 1L)
@@ -290,7 +290,7 @@ void testExportAllDataWithConstantValues() {
290290
}
291291

292292
@Test
293-
void testExportAllDataEmpty() {
293+
void exportAllDataEmpty() {
294294
KeySpace root = new KeySpace(
295295
new KeySpaceDirectory("empty", KeyType.STRING, UUID.randomUUID().toString())
296296
.addSubdirectory(new KeySpaceDirectory("level1", KeyType.LONG)));
@@ -308,7 +308,7 @@ void testExportAllDataEmpty() {
308308
}
309309

310310
@Test
311-
void testExportAllDataWithDeepNestedStructure() {
311+
void exportAllDataWithDeepNestedStructure() {
312312
KeySpace root = new KeySpace(
313313
new KeySpaceDirectory("org", KeyType.STRING, UUID.randomUUID().toString())
314314
.addSubdirectory(new KeySpaceDirectory("dept", KeyType.STRING)
@@ -372,7 +372,7 @@ void testExportAllDataWithDeepNestedStructure() {
372372
}
373373

374374
@Test
375-
void testExportAllDataWithBinaryData() {
375+
void exportAllDataWithBinaryData() {
376376
KeySpace root = new KeySpace(
377377
new KeySpaceDirectory("binary", KeyType.STRING, UUID.randomUUID().toString())
378378
.addSubdirectory(new KeySpaceDirectory("blob", KeyType.BYTES)));
@@ -416,7 +416,7 @@ void testExportAllDataWithBinaryData() {
416416

417417
@ParameterizedTest
418418
@ValueSource(ints = {1, 2, 3, 30})
419-
void testExportAllDataWithContinuation(int limit) {
419+
void exportAllDataWithContinuation(int limit) {
420420
KeySpace root = new KeySpace(
421421
new KeySpaceDirectory("continuation", KeyType.STRING, UUID.randomUUID().toString())
422422
.addSubdirectory(new KeySpaceDirectory("item", KeyType.LONG)));
@@ -468,7 +468,7 @@ void testExportAllDataWithContinuation(int limit) {
468468
}
469469

470470
@Test
471-
void testExportAllDataThroughKeySpacePathWrapper() {
471+
void exportAllDataThroughKeySpacePathWrapper() {
472472
final FDBDatabase database = dbExtension.getDatabase();
473473
final EnvironmentKeySpace keySpace = EnvironmentKeySpace.setupSampleData(database);
474474

@@ -511,7 +511,7 @@ void testExportAllDataThroughKeySpacePathWrapper() {
511511
}
512512

513513
@Test
514-
void testExportAllDataThroughKeySpacePathWrapperResolvedPaths() {
514+
void exportAllDataThroughKeySpacePathWrapperResolvedPaths() {
515515
final FDBDatabase database = dbExtension.getDatabase();
516516
final EnvironmentKeySpace keySpace = EnvironmentKeySpace.setupSampleData(database);
517517

@@ -547,27 +547,38 @@ private void setData(List<Object> keys, FDBRecordContext context, KeySpacePath b
547547
}
548548
}
549549

550-
private static List<KeyValue> exportAllData(final KeySpacePath rootPath, final FDBRecordContext context) {
551-
final List<KeyValue> asSingleExport = rootPath.exportAllData(context, null, ScanProperties.FORWARD_SCAN)
550+
/**
551+
* Export all the data, and make some assertions that can always be done.
552+
* This combines a lot of assertions, but most of the underlying behavior should be well covered by the objects
553+
* that {@link KeySpacePath#exportAllData} is built on.
554+
* @param pathToExport the path being exported
555+
* @param context the context in which to export
556+
* @return a list of the raw {@code KeyValue}s being exported
557+
*/
558+
private static List<KeyValue> exportAllData(final KeySpacePath pathToExport, final FDBRecordContext context) {
559+
final List<KeyValue> asSingleExport = pathToExport.exportAllData(context, null, ScanProperties.FORWARD_SCAN)
552560
.map(DataInKeySpacePath::getRawKeyValue).asList().join();
553561

554-
final List<ResolvedKeySpacePath> resolvedPaths = rootPath.exportAllData(context, null, ScanProperties.FORWARD_SCAN)
562+
// assert that the resolved paths contain the right prefix
563+
final List<ResolvedKeySpacePath> resolvedPaths = pathToExport.exportAllData(context, null, ScanProperties.FORWARD_SCAN)
555564
.mapPipelined(DataInKeySpacePath::getResolvedPath, 1).asList().join();
556-
final ResolvedKeySpacePath rootResolvedPath = rootPath.toResolvedPath(context);
565+
final ResolvedKeySpacePath rootResolvedPath = pathToExport.toResolvedPath(context);
557566
for (ResolvedKeySpacePath resolvedPath : resolvedPaths) {
558567
assertStartsWith(rootResolvedPath, resolvedPath);
559568
}
560569

561-
final List<KeyValue> reversed = rootPath.exportAllData(context, null, ScanProperties.REVERSE_SCAN)
570+
// assert that the reverse scan is the same as the forward scan, but in reverse
571+
final List<KeyValue> reversed = pathToExport.exportAllData(context, null, ScanProperties.REVERSE_SCAN)
562572
.map(DataInKeySpacePath::getRawKeyValue).asList().join();
563573
Collections.reverse(reversed);
564574
assertEquals(asSingleExport, reversed);
565575

576+
// Assert continuations work correctly
566577
final ScanProperties scanProperties = ScanProperties.FORWARD_SCAN.with(props -> props.setReturnedRowLimit(1));
567578
List<KeyValue> asContinuations = new ArrayList<>();
568579
RecordCursorContinuation continuation = RecordCursorStartContinuation.START;
569580
while (!continuation.isEnd()) {
570-
final RecordCursor<DataInKeySpacePath> cursor = rootPath.exportAllData(context, continuation.toBytes(),
581+
final RecordCursor<DataInKeySpacePath> cursor = pathToExport.exportAllData(context, continuation.toBytes(),
571582
scanProperties);
572583
final AtomicReference<RecordCursorResult<KeyValue>> keyValueResult = new AtomicReference<>();
573584
final List<KeyValue> batch = cursor.map(DataInKeySpacePath::getRawKeyValue).asList(keyValueResult).join();

0 commit comments

Comments
 (0)