|
12 | 12 | import com.linkedin.testing.RelationshipV2Bar; |
13 | 13 | import com.linkedin.testing.localrelationship.AspectFooBar; |
14 | 14 | import com.linkedin.testing.localrelationship.PairsWith; |
15 | | -import com.linkedin.testing.localrelationship.VersionOf; |
16 | 15 | import com.linkedin.testing.urn.BarUrn; |
17 | 16 | import com.linkedin.testing.urn.FooUrn; |
18 | 17 | import io.ebean.Ebean; |
|
26 | 25 | import java.util.ArrayList; |
27 | 26 | import java.util.Collections; |
28 | 27 | import java.util.List; |
29 | | -import java.util.Set; |
30 | | -import java.util.concurrent.CountDownLatch; |
31 | | -import java.util.concurrent.ExecutorService; |
32 | | -import java.util.concurrent.Executors; |
33 | | -import java.util.stream.Collectors; |
34 | 28 | import org.testng.annotations.BeforeClass; |
35 | 29 | import org.testng.annotations.DataProvider; |
36 | 30 | import org.testng.annotations.Factory; |
@@ -365,66 +359,6 @@ public void testAddRelationships() throws URISyntaxException, ReflectiveOperatio |
365 | 359 | _server.execute(Ebean.createSqlUpdate("truncate metadata_relationship_pairswith")); |
366 | 360 | } |
367 | 361 |
|
368 | | - @Test |
369 | | - public void testConcurrentAddRelationships() throws Exception { |
370 | | - if (!_useAspectColumnForRelationshipRemoval) { |
371 | | - return; |
372 | | - } |
373 | | - _localRelationshipWriterDAO.setUseAspectColumnForRelationshipRemoval(_useAspectColumnForRelationshipRemoval); |
374 | | - |
375 | | - BarUrn barUrn = BarUrn.createFromString("urn:li:bar:123"); |
376 | | - final int numThreads = 10; |
377 | | - final int relationshipsPerThread = 4; |
378 | | - final ExecutorService executor = Executors.newFixedThreadPool(numThreads); |
379 | | - final CountDownLatch latch = new CountDownLatch(numThreads); |
380 | | - |
381 | | - // set INSERT_BATCH_SIZE from 1000 to 2 for testing purposes |
382 | | - Field field = _localRelationshipWriterDAO.getClass().getDeclaredField("INSERT_BATCH_SIZE"); |
383 | | - field.setAccessible(true); // ignore private keyword |
384 | | - Field modifiersField = Field.class.getDeclaredField("modifiers"); |
385 | | - modifiersField.setAccessible(true); |
386 | | - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); // remove the 'final' modifier |
387 | | - field.set(null, 2); // use null bc of static context |
388 | | - |
389 | | - for (int i = 0; i < numThreads; i++) { |
390 | | - final int threadId = i; |
391 | | - executor.submit(() -> { |
392 | | - try { |
393 | | - List<VersionOf> relationships = new ArrayList<>(); |
394 | | - for (int j = 0; j < relationshipsPerThread; j++) { |
395 | | - FooUrn destination = FooUrn.createFromString("urn:li:foo:" + threadId + "00000" + j); |
396 | | - relationships.add(new VersionOf().setSource(barUrn).setDestination(destination)); |
397 | | - } |
398 | | - |
399 | | - _localRelationshipWriterDAO.addRelationships(barUrn, AspectFooBar.class, relationships, false); |
400 | | - Thread.sleep(1000); |
401 | | - } catch (Exception e) { |
402 | | - e.printStackTrace(); // helpful for debugging failures |
403 | | - } finally { |
404 | | - latch.countDown(); |
405 | | - } |
406 | | - }); |
407 | | - } |
408 | | - |
409 | | - latch.await(); // wait for all threads to finish |
410 | | - executor.shutdown(); |
411 | | - |
412 | | - // Verify all relationships were inserted |
413 | | - List<SqlRow> all = _server.createSqlQuery("select * from metadata_relationship_versionof where deleted_ts is null").findList(); |
414 | | - int expected = numThreads * relationshipsPerThread; |
415 | | - assertEquals(all.size(), expected); |
416 | | - |
417 | | - // Verify uniqueness of destination URNs |
418 | | - Set<String> uniqueDestinations = all.stream() |
419 | | - .map(row -> row.getString("destination")) |
420 | | - .collect(Collectors.toSet()); |
421 | | - |
422 | | - assertEquals(uniqueDestinations.size(), expected); |
423 | | - |
424 | | - // Clean up |
425 | | - _server.execute(Ebean.createSqlUpdate("truncate metadata_relationship_versionof")); |
426 | | - } |
427 | | - |
428 | 362 | @Test |
429 | 363 | public void testRemoveRelationshipsSameAspectDifferentNamespace() throws URISyntaxException { |
430 | 364 | if (!_useAspectColumnForRelationshipRemoval) { |
|
0 commit comments