Skip to content

Commit c255044

Browse files
committed
Cleanup some of the export tests
1 parent 714faf3 commit c255044

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import java.util.Map;
5050
import java.util.Set;
5151
import java.util.UUID;
52-
import java.util.concurrent.ExecutionException;
5352
import java.util.concurrent.atomic.AtomicReference;
5453
import java.util.stream.Collectors;
5554
import java.util.stream.IntStream;
@@ -69,7 +68,7 @@ class KeySpacePathDataExportTest {
6968
final FDBDatabaseExtension dbExtension = new FDBDatabaseExtension();
7069

7170
@Test
72-
void exportAllDataFromSimplePath() throws ExecutionException, InterruptedException {
71+
void exportAllDataFromSimplePath() {
7372
KeySpace root = new KeySpace(
7473
new KeySpaceDirectory("root", KeyType.STRING, UUID.randomUUID().toString())
7574
.addSubdirectory(new KeySpaceDirectory("level1", KeyType.LONG)));
@@ -83,13 +82,14 @@ void exportAllDataFromSimplePath() throws ExecutionException, InterruptedExcepti
8382

8483
// Add data at different levels
8584
for (int i = 0; i < 5; i++) {
86-
Tuple key = basePath.add("level1", (long) i).toTuple(context);
85+
final KeySpacePath path = basePath.add("level1", (long)i);
86+
Tuple key = path.toTuple(context);
8787
tr.set(key.pack(), Tuple.from("value" + i).pack());
8888

8989
// Add some sub-data under each key
9090
for (int j = 0; j < 3; j++) {
91-
Tuple subKey = key.add("sub" + j);
92-
tr.set(subKey.pack(), Tuple.from("subvalue" + i + "_" + j).pack());
91+
tr.set(path.toSubspace(context).pack(Tuple.from("sub" + j)),
92+
Tuple.from("subvalue" + i + "_" + j).pack());
9393
}
9494
}
9595
context.commit();
@@ -103,16 +103,19 @@ void exportAllDataFromSimplePath() throws ExecutionException, InterruptedExcepti
103103
// Should have 5 main entries + 15 sub-entries = 20 total
104104
assertEquals(20, allData.size());
105105

106+
assertThat(allData)
107+
.allSatisfy(data ->
108+
assertThat(data.getPath().getDirectoryName()).isEqualTo("level1"));
109+
106110
// Verify the data is sorted by key
107-
for (int i = 1; i < allData.size(); i++) {
108-
assertTrue(getKey(allData.get(i - 1), context).compareTo(getKey(allData.get(i), context)) < 0);
109-
}
111+
assertThat(allData.stream().map(data -> getKey(data, context)).collect(Collectors.toList()))
112+
.isSorted();
110113
}
111114
}
112115

113116
// `toTuple` does not include the remainder, I'm not sure if that is intentional, or an oversight.
114-
private Tuple getKey(final DataInKeySpacePath dataInKeySpacePath, final FDBRecordContext context) throws ExecutionException, InterruptedException {
115-
final ResolvedKeySpacePath resolvedKeySpacePath = dataInKeySpacePath.getPath().toResolvedPathAsync(context).get();
117+
private Tuple getKey(final DataInKeySpacePath dataInKeySpacePath, final FDBRecordContext context) {
118+
final ResolvedKeySpacePath resolvedKeySpacePath = dataInKeySpacePath.getPath().toResolvedPathAsync(context).join();
116119
if (dataInKeySpacePath.getRemainder() != null) {
117120
return resolvedKeySpacePath.toTuple().addAll(dataInKeySpacePath.getRemainder());
118121
} else {
@@ -524,9 +527,7 @@ private static void exportWithContinuations(final KeySpacePath pathToExport,
524527
final RecordCursor<DataInKeySpacePath> cursor = pathToExport.exportAllData(context, continuation.toBytes(),
525528
scanProperties);
526529
final AtomicReference<RecordCursorResult<Tuple>> tupleResult = new AtomicReference<>();
527-
final List<Tuple> batch = cursor.map(dataInPath -> {
528-
return Tuple.fromBytes(dataInPath.getValue());
529-
}).asList(tupleResult).join();
530+
final List<Tuple> batch = cursor.map(dataInPath -> Tuple.fromBytes(dataInPath.getValue())).asList(tupleResult).join();
530531
actual.add(batch);
531532
continuation = tupleResult.get().getContinuation();
532533
}
@@ -578,7 +579,7 @@ void exportAllDataThroughKeySpacePathWrapper() {
578579
}
579580

580581
@Test
581-
void exportAllDataThroughKeySpacePathWrapperResolvedPaths() {
582+
void exportAllDataThroughKeySpacePathWrapperRemainders() {
582583
final FDBDatabase database = dbExtension.getDatabase();
583584
final EnvironmentKeySpace keySpace = EnvironmentKeySpace.setupSampleData(database);
584585

0 commit comments

Comments
 (0)