From 30f7c8b2c8e507feb06bba183d118414774d4562 Mon Sep 17 00:00:00 2001 From: Simon Schrottner Date: Wed, 19 Feb 2025 08:51:31 +0100 Subject: [PATCH 1/2] feat: improve contextEnrichment to handle special cases. relates: https://github.com/open-feature/java-sdk-contrib/pull/1230 Signed-off-by: Simon Schrottner --- gherkin/contextEnrichment.feature | 49 +++++++++++++++++++++++++++++++ gherkin/targeting.feature | 17 ----------- 2 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 gherkin/contextEnrichment.feature diff --git a/gherkin/contextEnrichment.feature b/gherkin/contextEnrichment.feature new file mode 100644 index 0000000..95ec8f5 --- /dev/null +++ b/gherkin/contextEnrichment.feature @@ -0,0 +1,49 @@ +@contextEnrichment +Feature: Context Enrichment + + Background: + And a stable flagd provider + + @in-process @rpc + Scenario: Use enriched context + Given a String-flag with key "flagd-context-aware" and a default value "not" + When the flag was evaluated with details + Then the resolved details value should be "INTERNAL" + + @grace @in-process + Scenario: Use enriched context on connection error for IN-PROCESS + Given a String-flag with key "flagd-context-aware" and a default value "not" + And a stale event handler + And a ready event handler + When the flag was evaluated with details + Then the resolved details value should be "INTERNAL" + When the connection is lost for 6s + And a stale event was fired + When the flag was evaluated with details + Then the resolved details value should be "INTERNAL" + When a ready event was fired + + @grace @rpc + Scenario: Use enriched context on connection error for RPC + Given a String-flag with key "flagd-context-aware" and a default value "not" + And a stale event handler + And a ready event handler + When the flag was evaluated with details + Then the resolved details value should be "INTERNAL" + When the connection is lost for 6s + And a stale event was fired + When the flag was evaluated with details + Then the resolved details value should be "not" + When a ready event was fired + + @rpc @caching + Scenario: Use enriched context on RPC connection will not cache the value + Given a String-flag with key "flagd-context-aware" and a default value "not" + And a change event handler + And a ready event handler + When the flag was modified + And a change event was fired + And the flag was evaluated with details + Then the reason should be "TARGETING_MATCH" + When the flag was evaluated with details + Then the reason should be "TARGETING_MATCH" diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index 0499558..17411ed 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -144,20 +144,3 @@ Feature: Targeting rules | missing-variant-targeting-flag | 3 | | non-string-variant-targeting-flag | 2 | | empty-targeting-flag | 1 | - - @contextEnrichment - Scenario: Use enriched context - Given a String-flag with key "flagd-context-aware" and a default value "not" - When the flag was evaluated with details - Then the resolved details value should be "INTERNAL" - - @contextEnrichment @grace - Scenario: Use enriched context on connection error - Given a String-flag with key "flagd-context-aware" and a default value "not" - And a stale event handler - When the flag was evaluated with details - Then the resolved details value should be "INTERNAL" - When the connection is lost for 6s - And a stale event was fired - When the flag was evaluated with details - Then the resolved details value should be "INTERNAL" From f27ac96a2e85421402e0d1bce0443699b4e33f39 Mon Sep 17 00:00:00 2001 From: Simon Schrottner Date: Wed, 19 Feb 2025 08:51:31 +0100 Subject: [PATCH 2/2] feat: improve contextEnrichment to handle special cases. relates: https://github.com/open-feature/java-sdk-contrib/pull/1230 Signed-off-by: Simon Schrottner --- gherkin/contextEnrichment.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gherkin/contextEnrichment.feature b/gherkin/contextEnrichment.feature index 95ec8f5..fc6d5ba 100644 --- a/gherkin/contextEnrichment.feature +++ b/gherkin/contextEnrichment.feature @@ -2,7 +2,7 @@ Feature: Context Enrichment Background: - And a stable flagd provider + Given a stable flagd provider @in-process @rpc Scenario: Use enriched context @@ -45,5 +45,6 @@ Feature: Context Enrichment And a change event was fired And the flag was evaluated with details Then the reason should be "TARGETING_MATCH" + # ensure that we do not cache a "TARGETING_MATCH", we should only cache evaluation with a "STATIC" reason When the flag was evaluated with details Then the reason should be "TARGETING_MATCH"