-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Schrottner <[email protected]>
- Loading branch information
Showing
6 changed files
with
211 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
@grace | ||
@rpc @in-process @grace | ||
Feature: Flagd Provider State Changes | ||
|
||
Background: | ||
Given a flagd provider is set | ||
Given a unstable flagd provider | ||
|
||
Scenario Outline: Provider events | ||
When a <event> handler is added | ||
Then the <event> handler must run | ||
Given a <event> event handler | ||
Then the <event> event handler should have been executed | ||
Examples: | ||
| event | | ||
| PROVIDER_ERROR | | ||
| PROVIDER_STALE | | ||
| PROVIDER_READY | | ||
| event | | ||
| error | | ||
| stale | | ||
| ready | | ||
|
||
Scenario: Provider events chain ready -> stale -> error -> ready | ||
When a PROVIDER_READY handler is added | ||
Then the PROVIDER_READY handler must run | ||
When a PROVIDER_STALE handler is added | ||
Then the PROVIDER_STALE handler must run | ||
When a PROVIDER_ERROR handler is added | ||
Then the PROVIDER_ERROR handler must run | ||
When a PROVIDER_READY handler is added | ||
Then the PROVIDER_READY handler must run | ||
Given a ready event handler | ||
Then the ready event handler should have been executed | ||
Given a stale event handler | ||
Then the stale event handler should have been executed | ||
Given a error event handler | ||
Then the error event handler should have been executed | ||
Given a ready event handler | ||
Then the ready event handler should have been executed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,146 @@ | ||
@rpc @in-process @targeting | ||
Feature: flagd json evaluation | ||
|
||
# This test suite contains scenarios to test the json-evaluation of flagd and flag-in-process providers. | ||
# It's associated with the flags configured in flags/changing-flag.json, flags/zero-flags.json, flags/custom-ops.json and evaluator-refs.json. | ||
# It should be used in conjunction with the suites supplied by the OpenFeature specification. | ||
|
||
Background: | ||
Given a flagd provider is set | ||
Given an option "cache" of type "CacheType" with value "disabled" | ||
And a stable flagd provider | ||
|
||
# evaluator refs | ||
Scenario Outline: Evaluator reuse | ||
When a string flag with key <key> is evaluated with default value "fallback" | ||
And a context containing a key "email", with value "[email protected]" | ||
Then the returned value should be <value> | ||
Given a String-flag with key "<key>" and a default value "fallback" | ||
And a context containing a key "email", with type "String" and with value "[email protected]" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| key | value | | ||
| "some-email-targeted-flag" | "hi" | | ||
| "some-other-email-targeted-flag" | "yes" | | ||
| key | value | | ||
| some-email-targeted-flag | hi | | ||
| some-other-email-targeted-flag | yes | | ||
|
||
# custom operators | ||
@fractional | ||
Scenario Outline: Fractional operator | ||
When a string flag with key "fractional-flag" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag" and a default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value "<name>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| name | value | | ||
| "jack" | "spades" | | ||
| "queen" | "clubs" | | ||
| "ten" | "diamonds" | | ||
| "nine" | "hearts" | | ||
| 3 | "diamonds" | | ||
| name | value | | ||
| jack | spades | | ||
| queen | clubs | | ||
| ten | diamonds | | ||
| nine | hearts | | ||
| 3 | diamonds | | ||
|
||
@fractional | ||
Scenario Outline: Fractional operator shorthand | ||
When a string flag with key "fractional-flag-shorthand" is evaluated with default value "fallback" | ||
And a context containing a targeting key with value <targeting key> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag-shorthand" and a default value "fallback" | ||
And a context containing a targeting key with value "<targeting key>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| targeting key | value | | ||
| "jon@company.com" | "heads" | | ||
| "jane@company.com" | "tails" | | ||
| targeting key | value | | ||
| jon@company.com | heads | | ||
| jane@company.com | tails | | ||
|
||
@fractional | ||
Scenario Outline: Fractional operator with shared seed | ||
When a string flag with key "fractional-flag-A-shared-seed" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag-A-shared-seed" and a default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value "<name>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| name | value | | ||
| "jack" | "hearts" | | ||
| "queen" | "spades" | | ||
| "ten" | "hearts" | | ||
| "nine" | "diamonds" | | ||
| name | value | | ||
| jack | hearts | | ||
| queen | spades | | ||
| ten | hearts | | ||
| nine | diamonds | | ||
|
||
@fractional | ||
Scenario Outline: Second fractional operator with shared seed | ||
When a string flag with key "fractional-flag-B-shared-seed" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "fractional-flag-B-shared-seed" and a default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value "<name>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| name | value | | ||
| "jack" | "ace-of-hearts" | | ||
| "queen" | "ace-of-spades" | | ||
| "ten" | "ace-of-hearts" | | ||
| "nine" | "ace-of-diamonds" | | ||
| name | value | | ||
| jack | ace-of-hearts | | ||
| queen | ace-of-spades | | ||
| ten | ace-of-hearts | | ||
| nine | ace-of-diamonds | | ||
|
||
@string | ||
Scenario Outline: Substring operators | ||
When a string flag with key "starts-ends-flag" is evaluated with default value "fallback" | ||
And a context containing a key "id", with value <id> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "starts-ends-flag" and a default value "fallback" | ||
And a context containing a key "id", with type "String" and with value "<id>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| id | value | | ||
| "abcdef" | "prefix" | | ||
| "uvwxyz" | "postfix" | | ||
| "abcxyz" | "prefix" | | ||
| "lmnopq" | "none" | | ||
| 3 | "none" | | ||
| id | value | | ||
| abcdef | prefix | | ||
| uvwxyz | postfix | | ||
| abcxyz | prefix | | ||
| lmnopq | none | | ||
| 3 | none | | ||
|
||
@semver | ||
Scenario Outline: Semantic version operator numeric comparison | ||
When a string flag with key "equal-greater-lesser-version-flag" is evaluated with default value "fallback" | ||
And a context containing a key "version", with value <version> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "equal-greater-lesser-version-flag" and a default value "fallback" | ||
And a context containing a key "version", with type "String" and with value "<version>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| version | value | | ||
| "2.0.0" | "equal" | | ||
| "2.1.0" | "greater" | | ||
| "1.9.0" | "lesser" | | ||
| "2.0.0-alpha" | "lesser" | | ||
| "2.0.0.0" | "none" | | ||
| version | value | | ||
| 2.0.0 | equal | | ||
| 2.1.0 | greater | | ||
| 1.9.0 | lesser | | ||
| 2.0.0-alpha | lesser | | ||
| 2.0.0.0 | none | | ||
|
||
@semver | ||
Scenario Outline: Semantic version operator semantic comparison | ||
When a string flag with key "major-minor-version-flag" is evaluated with default value "fallback" | ||
And a context containing a key "version", with value <version> | ||
Then the returned value should be <value> | ||
Given a String-flag with key "major-minor-version-flag" and a default value "fallback" | ||
And a context containing a key "version", with type "String" and with value "<version>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| version | value | | ||
| "3.0.1" | "minor" | | ||
| "3.1.0" | "major" | | ||
| "4.0.0" | "none" | | ||
| version | value | | ||
| 3.0.1 | minor | | ||
| 3.1.0 | major | | ||
| 4.0.0 | none | | ||
|
||
Scenario Outline: Time-based operations | ||
When an integer flag with key "timestamp-flag" is evaluated with default value 0 | ||
And a context containing a key "time", with value <time> | ||
Then the returned value should be <value> | ||
Given a Integer-flag with key "timestamp-flag" and a default value "0" | ||
And a context containing a key "time", with type "Integer" and with value "<time>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| time | value | | ||
| 1 | -1 | | ||
| 4133980802 | 1 | | ||
|
||
Scenario Outline: Targeting by targeting key | ||
When a string flag with key "targeting-key-flag" is evaluated with default value "fallback" | ||
And a context containing a targeting key with value <targeting key> | ||
Then the returned value should be <value> | ||
Then the returned reason should be <reason> | ||
Given a String-flag with key "targeting-key-flag" and a default value "fallback" | ||
And a context containing a targeting key with value "<targeting key>" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Then the reason should be "<reason>" | ||
Examples: | ||
| targeting key | value | reason | | ||
| "5c3d8535-f81a-4478-a6d3-afaa4d51199e" | "hit" | "TARGETING_MATCH" | | ||
| "f20bd32d-703b-48b6-bc8e-79d53c85134a" | "miss" | "DEFAULT" | | ||
| targeting key | value | reason | | ||
| 5c3d8535-f81a-4478-a6d3-afaa4d51199e | hit | TARGETING_MATCH | | ||
| f20bd32d-703b-48b6-bc8e-79d53c85134a | miss | DEFAULT | | ||
|
||
Scenario Outline: Errors and edge cases | ||
When an integer flag with key <key> is evaluated with default value 3 | ||
Then the returned value should be <value> | ||
Given a Integer-flag with key "<key>" and a default value "3" | ||
When the flag was evaluated with details | ||
Then the resolved details value should be "<value>" | ||
Examples: | ||
| key | value | | ||
| "targeting-null-variant-flag" | 2 | | ||
| "error-targeting-flag" | 3 | | ||
| "missing-variant-targeting-flag" | 3 | | ||
| "non-string-variant-targeting-flag" | 2 | | ||
| "empty-targeting-flag" | 1 | | ||
| key | value | | ||
| targeting-null-variant-flag | 2 | | ||
| error-targeting-flag | 3 | | ||
| missing-variant-targeting-flag | 3 | | ||
| non-string-variant-targeting-flag | 2 | | ||
| empty-targeting-flag | 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
@rpc @in-process @reconnect | ||
Feature: flagd provider disconnect and reconnect functionality | ||
|
||
# This test suite tests the reconnection functionality of flagd providers | ||
|
||
Scenario: Provider reconnection | ||
Given a flagd provider is set | ||
When a PROVIDER_READY handler and a PROVIDER_ERROR handler are added | ||
Then the PROVIDER_READY handler must run when the provider connects | ||
And the PROVIDER_ERROR handler must run when the provider's connection is lost | ||
And when the connection is reestablished the PROVIDER_READY handler must run again | ||
Given a unstable flagd provider | ||
And a ready event handler | ||
And a error event handler | ||
When a ready event was fired | ||
Then the ready event handler should have been executed | ||
When a error event was fired | ||
Then the error event handler should have been executed | ||
|
||
Scenario: Provider unavailable | ||
Given flagd is unavailable | ||
When a flagd provider is set and initialization is awaited | ||
Then an error should be indicated within the configured deadline | ||
Given an option "deadlineMs" of type "Integer" with value "1000" | ||
And a unavailable flagd provider | ||
And a error event handler | ||
Then the error event handler should have been executed within 1000ms |
Oops, something went wrong.