Skip to content

Commit abd67ac

Browse files
committed
Change the import test to use 2 clusters if available
1 parent 3d0e968 commit abd67ac

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ class KeySpacePathImportDataTest {
5555
@RegisterExtension
5656
final FDBDatabaseExtension dbExtension = new FDBDatabaseExtension();
5757
private FDBDatabase database;
58+
private List<FDBDatabase> databases;
5859

5960
@BeforeEach
6061
void setUp() {
61-
database = dbExtension.getDatabase();
62+
databases = dbExtension.getDatabases(2);
63+
database = databases.get(0);
6264
}
6365

6466
@Test
@@ -395,8 +397,12 @@ private void copyData(final KeySpacePath path) {
395397
// Export the data
396398
final List<DataInKeySpacePath> exportedData = getExportedData(path);
397399

398-
// Clear the data and import it back
399-
clearPath(database, path);
400+
if (databases.size() > 1) {
401+
database = databases.get(1);
402+
} else {
403+
// Clear the data and import it back
404+
clearPath(database, path);
405+
}
400406

401407
// Import the data
402408
importData(database, path, exportedData);

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/test/FDBDatabaseExtension.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@
3636

3737
import javax.annotation.Nonnull;
3838
import javax.annotation.Nullable;
39+
import java.util.ArrayList;
40+
import java.util.Collections;
3941
import java.util.HashMap;
42+
import java.util.List;
4043
import java.util.Map;
4144
import java.util.Objects;
4245
import java.util.concurrent.Executor;
46+
import java.util.stream.Collectors;
4347

4448
import static org.junit.jupiter.api.Assertions.assertEquals;
4549

@@ -161,6 +165,12 @@ public FDBDatabase getDatabase(@Nullable String clusterFile) {
161165
});
162166
}
163167

168+
public List<FDBDatabase> getDatabases(int count) {
169+
List<String> clusterFiles = new ArrayList<>(FDBTestEnvironment.allClusterFiles());
170+
Collections.shuffle(clusterFiles);
171+
return clusterFiles.stream().limit(count).map(this::getDatabase).collect(Collectors.toList());
172+
}
173+
164174
public void checkForOpenContexts() {
165175
for (final Map.Entry<String, FDBDatabase> clusterFileToDatabase : databases.entrySet()) {
166176
assertEquals(0, clusterFileToDatabase.getValue().warnAndCloseOldTrackedOpenContexts(0),

0 commit comments

Comments
 (0)