21
21
package com .apple .foundationdb .async .rtree ;
22
22
23
23
import com .apple .foundationdb .Database ;
24
- import com .apple .foundationdb .FDB ;
25
- import com .apple .foundationdb .FDBTestBase ;
26
24
import com .apple .foundationdb .KeyValue ;
27
- import com .apple .foundationdb .NetworkOptions ;
28
25
import com .apple .foundationdb .Range ;
29
26
import com .apple .foundationdb .async .AsyncUtil ;
30
- import com .apple .foundationdb .directory .DirectoryLayer ;
31
- import com .apple .foundationdb .directory .DirectorySubspace ;
32
- import com .apple .foundationdb .directory .PathUtil ;
33
27
import com .apple .foundationdb .subspace .Subspace ;
28
+ import com .apple .foundationdb .test .TestDatabaseExtension ;
29
+ import com .apple .foundationdb .test .TestExecutors ;
30
+ import com .apple .foundationdb .test .TestSubspaceExtension ;
34
31
import com .apple .foundationdb .tuple .Tuple ;
35
32
import com .apple .test .Tags ;
36
33
import com .google .common .collect .ImmutableList ;
37
- import org .junit .jupiter .api .AfterEach ;
38
34
import org .junit .jupiter .api .Assertions ;
39
35
import org .junit .jupiter .api .BeforeEach ;
40
36
import org .junit .jupiter .api .Tag ;
41
37
import org .junit .jupiter .api .Test ;
38
+ import org .junit .jupiter .api .extension .RegisterExtension ;
39
+ import org .junit .jupiter .api .parallel .Execution ;
40
+ import org .junit .jupiter .api .parallel .ExecutionMode ;
42
41
import org .junit .jupiter .params .ParameterizedTest ;
43
42
import org .junit .jupiter .params .provider .Arguments ;
44
43
import org .junit .jupiter .params .provider .MethodSource ;
49
48
import java .util .List ;
50
49
import java .util .Random ;
51
50
import java .util .concurrent .CompletableFuture ;
52
- import java .util .concurrent .ForkJoinPool ;
53
51
import java .util .concurrent .atomic .AtomicLong ;
54
52
import java .util .stream .Stream ;
55
53
58
56
*/
59
57
@ Tag (Tags .RequiresFDB )
60
58
@ Tag (Tags .Slow )
61
- public class RTreeModificationTest extends FDBTestBase {
59
+ @ Execution (ExecutionMode .CONCURRENT )
60
+ public class RTreeModificationTest {
62
61
private static final Logger logger = LoggerFactory .getLogger (RTreeModificationTest .class );
63
-
64
62
private static final int NUM_TEST_RUNS = 5 ;
65
63
private static final int NUM_SAMPLES = 10_000 ;
66
64
67
- private Database db ;
68
- private DirectorySubspace rtSubspace ;
69
- private DirectorySubspace rtSecondarySubspace ;
65
+ @ RegisterExtension
66
+ static final TestDatabaseExtension dbExtension = new TestDatabaseExtension ();
67
+ @ RegisterExtension
68
+ TestSubspaceExtension rtSubspace = new TestSubspaceExtension (dbExtension );
69
+ @ RegisterExtension
70
+ TestSubspaceExtension rtSecondarySubspace = new TestSubspaceExtension (dbExtension );
70
71
71
- private static final boolean TRACE = false ;
72
+ private Database db ;
72
73
73
74
@ BeforeEach
74
- public void setUpDb () throws Exception {
75
- FDB fdb = FDB .instance ();
76
- if (TRACE ) {
77
- NetworkOptions options = fdb .options ();
78
- options .setTraceEnable ("/tmp" );
79
- options .setTraceLogGroup ("RTreeTest" );
80
- }
81
- db = fdb .open ();
82
- rtSubspace = DirectoryLayer .getDefault ().createOrOpen (db , PathUtil .from (RTree .class .getSimpleName ())).get ();
83
- db .run (tr -> {
84
- tr .clear (Range .startsWith (rtSubspace .getKey ()));
85
- return null ;
86
- });
87
- rtSecondarySubspace = DirectoryLayer .getDefault ().createOrOpen (db , PathUtil .from (RTree .class .getSimpleName (), "secondary" )).get ();
88
- db .run (tr -> {
89
- tr .clear (Range .startsWith (rtSecondarySubspace .getKey ()));
90
- return null ;
91
- });
92
- }
93
-
94
- @ AfterEach
95
- public void closeDb () {
96
- db .close ();
75
+ public void setUpDb () {
76
+ db = dbExtension .getDatabase ();
97
77
}
98
78
99
79
@ ParameterizedTest
@@ -102,7 +82,7 @@ public void testAllDeleted(final RTree.Config config, final long seed, final int
102
82
final RTreeScanTest .OnWriteCounters onWriteCounters = new RTreeScanTest .OnWriteCounters ();
103
83
final RTreeScanTest .OnReadCounters onReadCounters = new RTreeScanTest .OnReadCounters ();
104
84
105
- final RTree rTree = new RTree (rtSubspace , rtSecondarySubspace , ForkJoinPool . commonPool (), config ,
85
+ final RTree rTree = new RTree (rtSubspace . getSubspace () , rtSecondarySubspace . getSubspace (), TestExecutors . defaultThreadPool (), config ,
106
86
RTreeHilbertCurveHelpers ::hilbertValue , NodeHelpers ::newSequentialNodeId , onWriteCounters ,
107
87
onReadCounters );
108
88
final long startTs = System .nanoTime ();
@@ -160,7 +140,7 @@ public void testAllDeleted(final RTree.Config config, final long seed, final int
160
140
@ MethodSource ("numSamplesAndNumDeletes" )
161
141
public void testRandomDeletes (@ Nonnull final RTree .Config config , final long seed , final int numSamples , final int numDeletes ) {
162
142
final RTreeScanTest .OnReadCounters onReadCounters = new RTreeScanTest .OnReadCounters ();
163
- final RTree rTree = new RTree (rtSubspace , rtSecondarySubspace , ForkJoinPool . commonPool (), config ,
143
+ final RTree rTree = new RTree (rtSubspace . getSubspace () , rtSecondarySubspace . getSubspace (), TestExecutors . defaultThreadPool (), config ,
164
144
RTreeHilbertCurveHelpers ::hilbertValue , NodeHelpers ::newSequentialNodeId , OnWriteListener .NOOP ,
165
145
onReadCounters );
166
146
final Item [] items = randomInserts (db , rTree , seed , numSamples );
@@ -222,7 +202,7 @@ public <T extends Node> CompletableFuture<T> onAsyncRead(@Nonnull final Completa
222
202
}
223
203
};
224
204
225
- final RTree rTree = new RTree (rtSubspace , rtSecondarySubspace , ForkJoinPool . commonPool (),
205
+ final RTree rTree = new RTree (rtSubspace . getSubspace () , rtSecondarySubspace . getSubspace (), TestExecutors . defaultThreadPool (),
226
206
new RTree .ConfigBuilder ().build (),
227
207
RTreeHilbertCurveHelpers ::hilbertValue , NodeHelpers ::newSequentialNodeId , OnWriteListener .NOOP ,
228
208
onReadListener );
0 commit comments