From 7fe65ba7ded10f15cb950da895c65e89ee00913e Mon Sep 17 00:00:00 2001 From: Skye Gill Date: Thu, 12 Jan 2023 12:27:49 +0000 Subject: [PATCH 1/2] feat!: amend caching scenarios to check that cache is not just being purged Signed-off-by: Skye Gill --- Dockerfile | 2 +- features/caching.feature | 25 +++++++++++++++++----- testing-flags.json | 46 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71d7a3c..729bcfe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/open-feature/flagd:v0.3.0 +FROM ghcr.io/open-feature/flagd:v0.3.1 COPY testing-flags.json testing-flags.json LABEL org.opencontainers.image.source = "https://github.com/open-feature/test-harness" diff --git a/features/caching.feature b/features/caching.feature index 9ef8cd1..cf4cdd2 100644 --- a/features/caching.feature +++ b/features/caching.feature @@ -34,38 +34,53 @@ Feature: Flag caching # invalidates cached value Scenario: Invalidates cache on boolean flag configuration update Given a boolean flag with key "boolean-flag" is evaluated with details and default value "false" + And a boolean flag with key "boolean-flag-copy" is evaluated with details and default value "false" When the flag's configuration with key "boolean-flag" is updated to defaultVariant "off" And sleep for 50 milliseconds And a boolean flag with key "boolean-flag" is evaluated with details and default value "false" - Then the resolved boolean details reason should be "STATIC" + And a boolean flag with key "boolean-flag-copy" is evaluated with details and default value "false" + Then the resolved boolean details reason of flag with key "boolean-flag" should be "STATIC" + And the resolved boolean details reason of flag with key "boolean-flag-copy" should be "CACHED" Scenario: Invalidates cache on string flag configuration update Given a string flag with key "string-flag" is evaluated with details and default value "bye" + And a string flag with key "string-flag-copy" is evaluated with details and default value "bye" When the flag's configuration with key "string-flag" is updated to defaultVariant "parting" And sleep for 50 milliseconds And a string flag with key "string-flag" is evaluated with details and default value "bye" - Then the resolved string details reason should be "STATIC" + And a string flag with key "string-flag-copy" is evaluated with details and default value "bye" + Then the resolved string details reason of flag with key "string-flag" should be "STATIC" + And the resolved string details reason of flag with key "string-flag-copy" should be "CACHED" Scenario: Invalidates cache on integer flag configuration update Given an integer flag with key "integer-flag" is evaluated with details and default value 1 + And an integer flag with key "integer-flag-copy" is evaluated with details and default value 1 When the flag's configuration with key "integer-flag" is updated to defaultVariant "one" And sleep for 50 milliseconds And an integer flag with key "integer-flag" is evaluated with details and default value 1 - Then the resolved integer details reason should be "STATIC" + And an integer flag with key "integer-flag-copy" is evaluated with details and default value 1 + Then the resolved integer details reason of flag with key "integer-flag" should be "STATIC" + And the resolved integer details reason of flag with key "integer-flag-copy" should be "CACHED" Scenario: Invalidates cache on float flag configuration update Given a float flag with key "float-flag" is evaluated with details and default value 0.1 + And a float flag with key "float-flag-copy" is evaluated with details and default value 0.1 When the flag's configuration with key "float-flag" is updated to defaultVariant "tenth" And sleep for 50 milliseconds And a float flag with key "float-flag" is evaluated with details and default value 0.1 - Then the resolved float details reason should be "STATIC" + And a float flag with key "float-flag-copy" is evaluated with details and default value 0.1 + Then the resolved float details reason of flag with key "float-flag" should be "STATIC" + And the resolved float details reason of flag with key "float-flag-copy" should be "CACHED" Scenario: Invalidates cache on object flag configuration update Given an object flag with key "object-flag" is evaluated with details and a null default value + Given an object flag with key "object-flag-copy" is evaluated with details and a null default value When the flag's configuration with key "object-flag" is updated to defaultVariant "empty" And sleep for 50 milliseconds And an object flag with key "object-flag" is evaluated with details and a null default value - Then the resolved object details reason should be "STATIC" + And an object flag with key "object-flag-copy" is evaluated with details and a null default value + Then the resolved object details reason of flag with key "object-flag" should be "STATIC" + And the resolved object details reason of flag with key "object-flag-copy" should be "CACHED" Scenario: Non-static flag not cached Given a string flag with key "context-aware" is evaluated with details and default value "EXTERNAL" diff --git a/testing-flags.json b/testing-flags.json index 951253e..bcf4517 100644 --- a/testing-flags.json +++ b/testing-flags.json @@ -8,6 +8,14 @@ }, "defaultVariant": "on" }, + "boolean-flag-copy": { + "state": "ENABLED", + "variants": { + "on": true, + "off": false + }, + "defaultVariant": "on" + }, "string-flag": { "state": "ENABLED", "variants": { @@ -16,6 +24,14 @@ }, "defaultVariant": "greeting" }, + "string-flag-copy": { + "state": "ENABLED", + "variants": { + "greeting": "hi", + "parting": "bye" + }, + "defaultVariant": "greeting" + }, "integer-flag": { "state": "ENABLED", "variants": { @@ -24,6 +40,14 @@ }, "defaultVariant": "ten" }, + "integer-flag-copy": { + "state": "ENABLED", + "variants": { + "one": 1, + "ten": 10 + }, + "defaultVariant": "ten" + }, "float-flag": { "state": "ENABLED", "variants": { @@ -32,6 +56,14 @@ }, "defaultVariant": "half" }, + "float-flag-copy": { + "state": "ENABLED", + "variants": { + "tenth": 0.1, + "half": 0.5 + }, + "defaultVariant": "half" + }, "object-flag": { "state": "ENABLED", "variants": { @@ -44,6 +76,18 @@ }, "defaultVariant": "template" }, + "object-flag-copy": { + "state": "ENABLED", + "variants": { + "empty": {}, + "template": { + "showImages": true, + "title": "Check out these pics!", + "imagesPerPage": 100 + } + }, + "defaultVariant": "template" + }, "context-aware": { "state": "ENABLED", "variants": { @@ -111,4 +155,4 @@ "defaultVariant": "one" } } -} \ No newline at end of file +} From f7bd94d1056192d6908dd042ccc3e830d62d7157 Mon Sep 17 00:00:00 2001 From: Skye Gill Date: Thu, 12 Jan 2023 15:56:33 +0000 Subject: [PATCH 2/2] corrected background Signed-off-by: Skye Gill --- features/caching.feature | 2 +- features/evaluation.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/caching.feature b/features/caching.feature index cf4cdd2..e55adf7 100644 --- a/features/caching.feature +++ b/features/caching.feature @@ -3,7 +3,7 @@ Feature: Flag caching # This test suite contains scenarios relating to caching, particularly when an SDK is configured to use a flagd provider. Not all providers may observe these caching semantics. Background: - Given an openfeature client is registered with cache enabled + Given a provider is registered with cache enabled # caches value Scenario: Caches boolean value diff --git a/features/evaluation.feature b/features/evaluation.feature index f2086a2..529d85f 100644 --- a/features/evaluation.feature +++ b/features/evaluation.feature @@ -4,7 +4,7 @@ Feature: Flag evaluation Background: - Given an openfeature client is registered with cache disabled + Given a provider is registered with cache disabled # basic evaluation Scenario: Resolves boolean value