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!: improve gherkin files #161

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .gherkin-lintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
{
"steps-length": {
"Background": 3,
"Scenario": 15
"Scenario": 16
}
}
]
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Combined with the _flagd-provider_ for the associated SDK and the flagd-testbed,

Included suites:

[flagd.feature](gherkin/flagd.feature) includes tests relevant to flagd and all flagd providers:
[evaluation.feature](gherkin/evaluation.feature) includes tests relevant to flagd and all flagd providers:
* default value (zero-value) handling (some proto3 implementations handle these inconsistently).
* basic event handling

[flagd-json-evaluator.feature](gherkin/flagd-json-evaluator.feature) includes tests relevant to flagd and in-process providers:
[targeting.feature](gherkin/targeting.feature) includes tests relevant to flagd and in-process providers:
* custom JSONLogic operators (`starts_with`, `ends_with`, `fractional`, `sem_ver`)
* evaluator reuse via `$ref`

Expand Down
36 changes: 18 additions & 18 deletions gherkin/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,23 @@ Feature: Configuration Test
| option | type | value |
| targetUri | String | path |
@customCert
Examples:
Examples: Custom Certificate
| option | type | value |
| certPath | String | path |
@unixsocket
Examples:
Examples: Unixsocket
| option | type | value |
| socketPath | String | path |
@events
Examples:
Examples: events
| option | type | value |
| streamDeadlineMs | Integer | 500000 |
| keepAliveTime | Long | 5 |
| retryBackoffMs | Integer | 5000 |
| retryBackoffMaxMs | Integer | 12000 |
| retryGracePeriod | Integer | 10 |
@sync
Examples:
Examples: sync
| option | type | value |
| streamDeadlineMs | Integer | 500000 |
| keepAliveTime | Long | 5 |
Expand All @@ -135,12 +135,12 @@ Feature: Configuration Test
| retryGracePeriod | Integer | 10 |
| selector | String | selector |
@caching
Examples:
Examples: caching
| option | type | value |
| cache | CacheType | disabled |
| maxCacheSize | Integer | 1236 |
@offline
Examples:
Examples: offline
| option | type | value |
| offlineFlagSourcePath | String | path |
| offlinePollIntervalMs | Integer | 1000 |
Expand All @@ -165,23 +165,23 @@ Feature: Configuration Test
| option | env | type | value |
| targetUri | FLAGD_TARGET_URI | String | path |
@customCert
Examples:
Examples: Custom Certificates
| option | env | type | value |
| certPath | FLAGD_SERVER_CERT_PATH | String | path |
@unixsocket
Examples:
Examples: Unixsocket
| option | env | type | value |
| socketPath | FLAGD_SOCKET_PATH | String | path |
@events
Examples:
Examples: Events
| option | env | type | value |
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | Integer | 500000 |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | Long | 5 |
| retryBackoffMs | FLAGD_RETRY_BACKOFF_MS | Integer | 5000 |
| retryBackoffMaxMs | FLAGD_RETRY_BACKOFF_MAX_MS | Integer | 12000 |
| retryGracePeriod | FLAGD_RETRY_GRACE_PERIOD | Integer | 10 |
@sync
Examples:
Examples: Sync
| option | env | type | value |
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | Integer | 500000 |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | Long | 5 |
Expand All @@ -190,12 +190,12 @@ Feature: Configuration Test
| retryGracePeriod | FLAGD_RETRY_GRACE_PERIOD | Integer | 10 |
| selector | FLAGD_SOURCE_SELECTOR | String | selector |
@caching
Examples:
Examples: Caching
| option | env | type | value |
| cache | FLAGD_CACHE | CacheType | disabled |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | Integer | 1236 |
@offline
Examples:
Examples: Offline
| option | env | type | value |
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | String | path |
| offlinePollIntervalMs | FLAGD_OFFLINE_POLL_MS | Integer | 1000 |
Expand All @@ -218,23 +218,23 @@ Feature: Configuration Test
| option | env | type | value | env-value |
| targetUri | FLAGD_TARGET_URI | String | path | fun |
@customCert
Examples:
Examples: Custom Certificates
| option | env | type | value | env-value |
| certPath | FLAGD_SERVER_CERT_PATH | String | path | rpc |
@unixsocket
Examples:
Examples: Unixsocket
| option | env | type | value | env-value |
| socketPath | FLAGD_SOCKET_PATH | String | path | rpc |
@events
Examples:
Examples: Events
| option | env | type | value | env-value |
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | Integer | 500000 | 400 |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | Long | 5 | 4 |
| retryBackoffMs | FLAGD_RETRY_BACKOFF_MS | Integer | 5000 | 4 |
| retryBackoffMaxMs | FLAGD_RETRY_BACKOFF_MAX_MS | Integer | 12000 | 4 |
| retryGracePeriod | FLAGD_RETRY_GRACE_PERIOD | Integer | 10 | 4 |
@sync
Examples:
Examples: Sync
| option | env | type | value | env-value |
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | Integer | 500000 | 400 |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | Long | 5 | 4 |
Expand All @@ -243,12 +243,12 @@ Feature: Configuration Test
| retryGracePeriod | FLAGD_RETRY_GRACE_PERIOD | Integer | 10 | 4 |
| selector | FLAGD_SOURCE_SELECTOR | String | selector | sele |
@caching
Examples:
Examples: Caching
| option | env | type | value | env-value |
| cache | FLAGD_CACHE | CacheType | disabled | lru |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | Integer | 1236 | 2345 |
@offline
Examples:
Examples: Offline
| option | env | type | value | env-value |
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | String | path | lll |
| offlinePollIntervalMs | FLAGD_OFFLINE_POLL_MS | Integer | 1000 | 4 |
57 changes: 57 additions & 0 deletions gherkin/connection.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@rpc @in-process
Feature: flagd provider disconnect and reconnect functionality

Scenario Outline: Connection
Given a <name> flagd provider
And a Boolean-flag with key "boolean-flag" and a default value "true"
When the flag was evaluated with details
Then the resolved details value should be "true"

Examples: Stable
| name |
| stable |
@targetURI
Examples: Target URI
| name |
| target |
@customCert
Examples: Certificates
| name |
| ssl |
@unixsocket @os.linux
Examples: Unixsocket
| name |
| socket |

@reconnect
# This test suite tests the reconnection functionality of flagd providers
Scenario Outline: Provider reconnection
Given a <name> flagd provider
And a ready event handler
And a error event handler
When a ready event was fired
When the connection is lost for 4s
Then the error event handler should have been executed
Then the ready event handler should have been executed

Examples: Stable
| name |
| stable |
@targetURI
Examples: Target URI
| name |
| socket |
@customCert
Examples: Certificates
| name |
| ssl |
@unixsocket @os.linux
Examples: Unixsocket
| name |
| socket |

Scenario: Provider unavailable
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
34 changes: 34 additions & 0 deletions gherkin/evaluation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@rpc @in-process
Feature: flagd providers

# This test suite contains scenarios to test flagd providers.
# It's associated with the flags configured in flags/changing-flag.json and flags/zero-flags.json.
# It should be used in conjunction with the suites supplied by the OpenFeature specification.

Background:
Given an option "cache" of type "CacheType" with value "disabled"
And a stable flagd provider

Scenario Outline: Resolve values
Given a <type>-flag with key "<key>" and a default value "<default>"
When the flag was evaluated with details
Then the resolved details value should be "<resolved_value>"

Examples:
| key | type | default | resolved_value |
| boolean-flag | Boolean | false | true |
| string-flag | String | bye | hi |
| integer-flag | Integer | 1 | 10 |
| float-flag | Float | 0.1 | 0.5 |

Scenario Outline: Resolves zero value
Given a <type>-flag with key "<key>" and a default value "<default>"
When the flag was evaluated with details
Then the resolved details value should be "<resolved_value>"

Examples:
| key | type | default | resolved_value |
| boolean-zero-flag | Boolean | true | false |
| string-zero-flag | String | hi | |
| integer-zero-flag | Integer | 1 | 0 |
| float-zero-flag | Float | 0.1 | 0.0 |
52 changes: 36 additions & 16 deletions gherkin/events.feature
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
@grace
@rpc @in-process
Feature: Flagd Provider State Changes

Background:
Given a flagd provider is set
Given a stable flagd provider

Scenario Outline: Provider events
When a <event> handler is added
Then the <event> handler must run
Given a <event> event handler
When the connection is lost for 6s
Then the <event> event handler should have been executed
Examples:
| event |
| PROVIDER_ERROR |
| PROVIDER_STALE |
| PROVIDER_READY |
| event |
| error |
| ready |
@grace
Examples:
| event |
| stale |

@grace
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
And a error event handler
And a stale event handler
Then the ready event handler should have been executed
When the connection is lost for 6s
Then the stale event handler should have been executed
Then the error event handler should have been executed
Then the ready event handler should have been executed

Scenario: Provider events chain ready -> error -> ready
Given a ready event handler
And a error event handler
Then the ready event handler should have been executed
When the connection is lost for 6s
Then the error event handler should have been executed
Then the ready event handler should have been executed

Scenario: Flag change event
Given a String-flag with key "changing-flag" and a default value "false"
And a change event handler
When a change event was fired
And the flag was modified
Then the flag should be part of the event payload
Loading
Loading