From e593d30718ce35a19ead5ae406793887a639a649 Mon Sep 17 00:00:00 2001 From: "christian.lutnik" Date: Thu, 20 Nov 2025 13:40:22 +0100 Subject: [PATCH 1/3] Improve tests Signed-off-by: christian.lutnik --- .../flagd/FlagdProviderSyncResourcesTest.java | 10 +++++++--- .../openfeature/contrib/providers/flagd/e2e/State.java | 5 ++--- .../contrib/providers/flagd/e2e/steps/EventSteps.java | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java index 6258dad37..07bb63da2 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java @@ -79,14 +79,14 @@ void interruptingWaitingThread_isIgnored() throws InterruptedException { @Test void callingInitialize_wakesUpWaitingThread() throws InterruptedException { final AtomicBoolean isWaiting = new AtomicBoolean(); - final AtomicBoolean successfulTest = new AtomicBoolean(); + final AtomicLong waitTime = new AtomicLong(Long.MAX_VALUE); Thread waitingThread = new Thread(() -> { long start = System.currentTimeMillis(); isWaiting.set(true); flagdProviderSyncResources.waitForInitialization(10000); long end = System.currentTimeMillis(); long duration = end - start; - successfulTest.set(duration < MAX_TIME_TOLERANCE * 2); + waitTime.set(duration); }); waitingThread.start(); @@ -100,7 +100,11 @@ void callingInitialize_wakesUpWaitingThread() throws InterruptedException { waitingThread.join(); - Assertions.assertTrue(successfulTest.get()); + Assertions.assertTrue( + waitTime.get() < MAX_TIME_TOLERANCE * 2, + "Wakeup should be almost instant, but took " + waitTime.get() + + " ms, which is more than the max of" + + (MAX_TIME_TOLERANCE * 2) + " ms"); } @Timeout(2) diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/State.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/State.java index 765e741ef..2d3a227a4 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/State.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/State.java @@ -9,15 +9,14 @@ import dev.openfeature.sdk.FeatureProvider; import dev.openfeature.sdk.FlagEvaluationDetails; import dev.openfeature.sdk.MutableContext; -import java.util.LinkedList; -import java.util.List; import java.util.Optional; +import java.util.concurrent.ConcurrentLinkedQueue; public class State { public ProviderType providerType; public Client client; public FeatureProvider provider; - public List events = new LinkedList<>(); + public ConcurrentLinkedQueue events = new ConcurrentLinkedQueue<>(); public Optional lastEvent; public FlagSteps.Flag flag; public MutableContext context = new MutableContext(); diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java index c31517320..6dfc46c4e 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java @@ -8,7 +8,7 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.LinkedList; +import java.util.concurrent.ConcurrentLinkedQueue; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class EventSteps extends AbstractSteps { public EventSteps(State state) { super(state); - state.events = new LinkedList<>(); + state.events = new ConcurrentLinkedQueue<>(); } @Given("a {} event handler") From 6a11bd67e1cf650c1d7000c766f54c82ebe661e5 Mon Sep 17 00:00:00 2001 From: "christian.lutnik" Date: Thu, 20 Nov 2025 14:05:10 +0100 Subject: [PATCH 2/3] Improve tests Signed-off-by: christian.lutnik --- .../contrib/providers/flagd/FlagdProviderSyncResourcesTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java index 07bb63da2..c7d9672ef 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResourcesTest.java @@ -102,7 +102,7 @@ void callingInitialize_wakesUpWaitingThread() throws InterruptedException { Assertions.assertTrue( waitTime.get() < MAX_TIME_TOLERANCE * 2, - "Wakeup should be almost instant, but took " + waitTime.get() + () -> "Wakeup should be almost instant, but took " + waitTime.get() + " ms, which is more than the max of" + (MAX_TIME_TOLERANCE * 2) + " ms"); } From a77b932ea24371c6eaa26d7b349aa38698c7d269 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Thu, 18 Dec 2025 08:43:03 -0500 Subject: [PATCH 3/3] fixup: pr feedback Signed-off-by: Todd Baert --- .../contrib/providers/flagd/e2e/steps/EventSteps.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java index 6dfc46c4e..dc11bbb6a 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/EventSteps.java @@ -8,7 +8,6 @@ import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.concurrent.ConcurrentLinkedQueue; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -19,7 +18,6 @@ public class EventSteps extends AbstractSteps { public EventSteps(State state) { super(state); - state.events = new ConcurrentLinkedQueue<>(); } @Given("a {} event handler")