From 629f22b70e22a7a3923147d348b09326f61fd3bb Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Sun, 26 May 2024 11:42:26 -0700 Subject: [PATCH] better smoke testing --- .../salesforce/apollo/model/DomainTest.java | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/model/src/test/java/com/salesforce/apollo/model/DomainTest.java b/model/src/test/java/com/salesforce/apollo/model/DomainTest.java index 06ec38cb5..15fc29957 100644 --- a/model/src/test/java/com/salesforce/apollo/model/DomainTest.java +++ b/model/src/test/java/com/salesforce/apollo/model/DomainTest.java @@ -37,12 +37,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.IntStream; import static com.salesforce.apollo.choam.Session.retryNesting; -import static java.util.concurrent.CompletableFuture.allOf; import static org.junit.jupiter.api.Assertions.*; /** @@ -88,22 +88,29 @@ public static void smoke(Oracle oracle) throws Exception { // Map direct edges. Transitive edges added as a side effect - allOf(retryNesting(() -> oracle.map(helpDeskMembers, adminMembers), 3), - retryNesting(() -> oracle.map(ali, adminMembers), 3), retryNesting(() -> oracle.map(ali, userMembers), 3), - retryNesting(() -> oracle.map(burcu, userMembers), 3), - retryNesting(() -> oracle.map(can, userMembers), 3), - retryNesting(() -> oracle.map(managerMembers, userMembers), 3), - retryNesting(() -> oracle.map(technicianMembers, userMembers), 3), - retryNesting(() -> oracle.map(demet, helpDeskMembers), 3), - retryNesting(() -> oracle.map(egin, helpDeskMembers), 3), - retryNesting(() -> oracle.map(egin, userMembers), 3), - retryNesting(() -> oracle.map(fuat, managerMembers), 3), - retryNesting(() -> oracle.map(gl, managerMembers), 3), - retryNesting(() -> oracle.map(hakan, technicianMembers), 3), - retryNesting(() -> oracle.map(irmak, technicianMembers), 3), - retryNesting(() -> oracle.map(abcTechMembers, technicianMembers), 3), - retryNesting(() -> oracle.map(flaggedTechnicianMembers, technicianMembers), 3), - retryNesting(() -> oracle.map(jale, abcTechMembers), 3)).get(60, TimeUnit.SECONDS); + var countDown = new CountDownLatch(17); + + retryNesting(() -> oracle.map(helpDeskMembers, adminMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(ali, adminMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(ali, userMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(burcu, userMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(can, userMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(managerMembers, userMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(technicianMembers, userMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(demet, helpDeskMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(egin, helpDeskMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(egin, userMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(fuat, managerMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(gl, managerMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(hakan, technicianMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(irmak, technicianMembers), 3).whenComplete((_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(abcTechMembers, technicianMembers), 3).whenComplete( + (_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(flaggedTechnicianMembers, technicianMembers), 3).whenComplete( + (_, _) -> countDown.countDown()); + retryNesting(() -> oracle.map(jale, abcTechMembers), 3).whenComplete((_, _) -> countDown.countDown()); + + countDown.await(120, TimeUnit.SECONDS); // Protected resource namespace var docNs = Oracle.namespace("Document"); @@ -114,7 +121,7 @@ public static void smoke(Oracle oracle) throws Exception { // Users can View Document 123 Assertion tuple = userMembers.assertion(object123View); - retryNesting(() -> oracle.add(tuple), 3).get(); + retryNesting(() -> oracle.add(tuple), 3).get(120, TimeUnit.SECONDS); // Direct subjects that can View the document var viewers = oracle.read(object123View); @@ -128,7 +135,7 @@ public static void smoke(Oracle oracle) throws Exception { // Assert flagged technicians can directly view the document Assertion grantTechs = flaggedTechnicianMembers.assertion(object123View); - retryNesting(() -> oracle.add(grantTechs), 3).get(); + retryNesting(() -> oracle.add(grantTechs), 3).get(120, TimeUnit.SECONDS); // Now have 2 direct subjects that can view the doc viewers = oracle.read(object123View); @@ -167,22 +174,22 @@ public static void smoke(Oracle oracle) throws Exception { assertFalse(oracle.check(object123View.assertion(helpDeskMembers))); // Remove them - retryNesting(() -> oracle.remove(abcTechMembers, technicianMembers), 3).get(); + retryNesting(() -> oracle.remove(abcTechMembers, technicianMembers), 3).get(120, TimeUnit.SECONDS); assertFalse(oracle.check(object123View.assertion(jale))); assertTrue(oracle.check(object123View.assertion(egin))); assertFalse(oracle.check(object123View.assertion(helpDeskMembers))); // Remove our assertion - retryNesting(() -> oracle.delete(tuple), 3).get(); + retryNesting(() -> oracle.delete(tuple), 3).get(120, TimeUnit.SECONDS); assertFalse(oracle.check(object123View.assertion(jale))); assertFalse(oracle.check(object123View.assertion(egin))); assertFalse(oracle.check(object123View.assertion(helpDeskMembers))); // Some deletes - retryNesting(() -> oracle.delete(abcTechMembers), 3).get(); - retryNesting(() -> oracle.delete(flaggedTechnicianMembers), 3).get(); + retryNesting(() -> oracle.delete(abcTechMembers), 3).get(120, TimeUnit.SECONDS); + retryNesting(() -> oracle.delete(flaggedTechnicianMembers), 3).get(120, TimeUnit.SECONDS); } @AfterEach