Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: amend caching scenarios to check that cache is not just being purged #20

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
25 changes: 20 additions & 5 deletions features/caching.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
46 changes: 45 additions & 1 deletion testing-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
},
"defaultVariant": "on"
},
"boolean-flag-copy": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
},
"string-flag": {
"state": "ENABLED",
"variants": {
Expand All @@ -16,6 +24,14 @@
},
"defaultVariant": "greeting"
},
"string-flag-copy": {
"state": "ENABLED",
"variants": {
"greeting": "hi",
"parting": "bye"
},
"defaultVariant": "greeting"
},
"integer-flag": {
"state": "ENABLED",
"variants": {
Expand All @@ -24,6 +40,14 @@
},
"defaultVariant": "ten"
},
"integer-flag-copy": {
"state": "ENABLED",
"variants": {
"one": 1,
"ten": 10
},
"defaultVariant": "ten"
},
"float-flag": {
"state": "ENABLED",
"variants": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -111,4 +155,4 @@
"defaultVariant": "one"
}
}
}
}