Skip to content

Commit

Permalink
feat!: offline file an own resolver (#195)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
  • Loading branch information
aepfli authored Feb 4, 2025
1 parent 6c095cf commit ef03ed0
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 115 deletions.
210 changes: 128 additions & 82 deletions gherkin/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,51 @@ Feature: Configuration Test
| contextEnricher | - | sync-metadata to evaluation context mapping function | function | identity function | in-process |
"""

@rpc @in-process
Scenario Outline: Default Config
When a config was initialized
Then the option "<option>" of type "<type>" should have the value "<default>"

@rpc @in-process @file
Scenarios: Basic
| option | type | default |
| resolver | ResolverType | rpc |
| host | String | localhost |
| port | Integer | 8013 |
| tls | Boolean | false |
| deadlineMs | Integer | 500 |
@targetURI
| option | type | default |
| resolver | ResolverType | rpc |
| deadlineMs | Integer | 500 |
@rpc @in-process
Scenarios: Basic Connection
| option | type | default |
| host | String | localhost |
| port | Integer | 8013 |
| tls | Boolean | false |
@rpc @in-process @targetURI
Scenarios: Target URI
| option | type | default |
| targetUri | String | null |
@customCert
@rpc @in-process @customCert
Scenarios: Certificates
| option | type | default |
| certPath | String | null |
@unixsocket
@rpc @in-process @unixsocket
Scenarios: Unixsocket
| option | type | default |
| socketPath | String | null |
@events
@rpc @in-process @stream
Scenarios: Events
| option | type | default |
| streamDeadlineMs | Integer | 600000 |
| keepAliveTime | Long | 0 |
| retryBackoffMs | Integer | 1000 |
| retryBackoffMaxMs | Integer | 120000 |
| retryGracePeriod | Integer | 5 |
@sync
@in-process @sync
Scenarios: Sync
| option | type | default |
| streamDeadlineMs | Integer | 600000 |
| keepAliveTime | Long | 0 |
| retryBackoffMs | Integer | 1000 |
| retryBackoffMaxMs | Integer | 120000 |
| retryGracePeriod | Integer | 5 |
| selector | String | null |
@caching
| option | type | default |
| selector | String | null |
@rpc @caching
Scenarios: caching
| option | type | default |
| cache | CacheType | lru |
| maxCacheSize | Integer | 1000 |
@offline
@file
Scenarios: offline
| option | type | default |
| offlineFlagSourcePath | String | null |
Expand All @@ -93,161 +92,208 @@ Feature: Configuration Test
| option | type | default |
| port | Integer | 8015 |

@rpc @in-process
@file
Scenario Outline: File Backwards compatibility
Given an option "resolver" of type "ResolverType" with value "<resolverSet>"
And an option "offlineFlagSourcePath" of type "String" with value "some-path"
When a config was initialized
Then the option "resolver" of type "ResolverType" should have the value "<resolverExpected>"
Scenarios:
| resolverSet | resolverExpected |
| in-process | file |
| rpc | rpc |
| file | file |

@file
Scenario: Default Config File
Given an option "resolver" of type "ResolverType" with value "file"
When a config was initialized
Then we should have an error

Scenario Outline: Dedicated Config
Given an option "<option>" of type "<type>" with value "<value>"
When a config was initialized
Then the option "<option>" of type "<type>" should have the value "<value>"
Scenarios:

@rpc @in-process @file
Scenarios: Basic
| option | type | value |
| resolver | ResolverType | in-process |
| host | String | local |
| tls | Boolean | True |
| port | Integer | 1234 |
| deadlineMs | Integer | 123 |
@targetURI
@rpc @in-process
Scenarios: Basic Connection
| option | type | value |
| host | String | local |
| tls | Boolean | True |
| port | Integer | 1234 |

@rpc @in-process @targetURI
Scenarios: Target URI
| option | type | value |
| targetUri | String | path |
@customCert

@rpc @in-process @customCert
Scenarios: Custom Certificate
| option | type | value |
| certPath | String | path |
@unixsocket

@rpc @in-process @unixsocket
Scenarios: Unixsocket
| option | type | value |
| socketPath | String | path |
@events
Scenarios: events

@rpc @in-process @stream
Scenarios: Stream
| option | type | value |
| streamDeadlineMs | Integer | 500000 |
| keepAliveTime | Long | 5 |
| retryBackoffMs | Integer | 5000 |
| retryBackoffMaxMs | Integer | 12000 |
| retryGracePeriod | Integer | 10 |
@sync
Scenarios: sync
| option | type | value |
| streamDeadlineMs | Integer | 500000 |
| keepAliveTime | Long | 5 |
| retryBackoffMs | Integer | 5000 |
| retryBackoffMaxMs | Integer | 12000 |
| retryGracePeriod | Integer | 10 |
| selector | String | selector |
@caching

@in-process @sync
Scenarios: Selector
| option | type | value |
| selector | String | selector |
@rpc @caching
Scenarios: caching
| option | type | value |
| cache | CacheType | disabled |
| maxCacheSize | Integer | 1236 |
@offline
@file
Scenarios: offline
| option | type | value |
| offlineFlagSourcePath | String | path |
| offlinePollIntervalMs | Integer | 1000 |

@rpc @in-process
Scenario Outline: Dedicated Config via Env_var
Given an environment variable "<env>" with value "<value>"
When a config was initialized
Then the option "<option>" of type "<type>" should have the value "<value>"
Scenarios:

@rpc @in-process @file
Scenarios: Basic
| option | env | type | value |
| resolver | FLAGD_RESOLVER | ResolverType | in-process |
| resolver | FLAGD_RESOLVER | ResolverType | IN-PROCESS |
| resolver | FLAGD_RESOLVER | ResolverType | rpc |
| resolver | FLAGD_RESOLVER | ResolverType | RPC |
| host | FLAGD_HOST | String | local |
| tls | FLAGD_TLS | Boolean | True |
| port | FLAGD_PORT | Integer | 1234 |
| deadlineMs | FLAGD_DEADLINE_MS | Integer | 123 |
@targetURI

@rpc @in-process
Scenarios: Basic Connection
| option | env | type | value |
| host | FLAGD_HOST | String | local |
| tls | FLAGD_TLS | Boolean | True |
| port | FLAGD_PORT | Integer | 1234 |

@rpc @in-process @targetURI
Scenarios: Target URI
| option | env | type | value |
| targetUri | FLAGD_TARGET_URI | String | path |
@customCert

@rpc @in-process @customCert
Scenarios: Custom Certificates
| option | env | type | value |
| certPath | FLAGD_SERVER_CERT_PATH | String | path |
@unixsocket

@rpc @in-process @unixsocket
Scenarios: Unixsocket
| option | env | type | value |
| socketPath | FLAGD_SOCKET_PATH | String | path |
@events
Scenarios: Events

@rpc @in-process @stream
Scenarios: Stream
| 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

@in-process @sync
Scenarios: Sync
| 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 |
| selector | FLAGD_SOURCE_SELECTOR | String | selector |
@caching
| option | env | type | value |
| selector | FLAGD_SOURCE_SELECTOR | String | selector |

@rpc @caching
Scenarios: Caching
| option | env | type | value |
| cache | FLAGD_CACHE | CacheType | disabled |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | Integer | 1236 |
@offline
@file
Scenarios: Offline
| option | env | type | value |
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | String | path |
| offlinePollIntervalMs | FLAGD_OFFLINE_POLL_MS | Integer | 1000 |

@rpc @in-process
@file
Scenario Outline: Dedicated Config via Env_var special file case
Given an environment variable "<env>" with value "<value>"
And an option "offlineFlagSourcePath" of type "String" with value "some-path"
When a config was initialized
Then the option "<option>" of type "<type>" should have the value "<value>"

Scenarios: Basic
| option | env | type | value |
| resolver | FLAGD_RESOLVER | ResolverType | file |
| resolver | FLAGD_RESOLVER | ResolverType | FILE |

Scenario Outline: Dedicated Config via Env_var and set
Given an environment variable "<env>" with value "<env-value>"
And an option "<option>" of type "<type>" with value "<value>"
When a config was initialized
Then the option "<option>" of type "<type>" should have the value "<value>"
Scenarios:

@rpc @in-process @file
Scenarios: Basic
| option | env | type | value | env-value |
| resolver | FLAGD_RESOLVER | ResolverType | in-process | rpc |
| host | FLAGD_HOST | String | local | l |
| tls | FLAGD_TLS | Boolean | True | False |
| port | FLAGD_PORT | Integer | 1234 | 3456 |
| deadlineMs | FLAGD_DEADLINE_MS | Integer | 123 | 345 |
@targetURI

@rpc @in-process
Scenarios: Basic Connection
| option | env | type | value | env-value |
| host | FLAGD_HOST | String | local | l |
| tls | FLAGD_TLS | Boolean | True | False |
| port | FLAGD_PORT | Integer | 1234 | 3456 |

@rpc @in-process @targetURI
Scenarios: Target URI
| option | env | type | value | env-value |
| targetUri | FLAGD_TARGET_URI | String | path | fun |
@customCert

@rpc @in-process @customCert
Scenarios: Custom Certificates
| option | env | type | value | env-value |
| certPath | FLAGD_SERVER_CERT_PATH | String | path | rpc |
@unixsocket

@rpc @in-process @unixsocket
Scenarios: Unixsocket
| option | env | type | value | env-value |
| socketPath | FLAGD_SOCKET_PATH | String | path | rpc |
@events
Scenarios: Events

@rpc @in-process @stream
Scenarios: Stream
| 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

@rpc @in-process @sync
Scenarios: Sync
| 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 |
| selector | FLAGD_SOURCE_SELECTOR | String | selector | sele |
@caching
| option | env | type | value | env-value |
| selector | FLAGD_SOURCE_SELECTOR | String | selector | sele |

@rpc @caching
Scenarios: Caching
| option | env | type | value | env-value |
| cache | FLAGD_CACHE | CacheType | disabled | lru |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | Integer | 1236 | 2345 |
@offline

@file
Scenarios: Offline
| option | env | type | value | env-value |
| offlineFlagSourcePath | FLAGD_OFFLINE_FLAG_SOURCE_PATH | String | path | lll |
Expand Down
3 changes: 2 additions & 1 deletion gherkin/connection.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@rpc @in-process
@rpc @in-process @file
Feature: flagd provider disconnect and reconnect functionality

Scenario Outline: Connection
Expand Down Expand Up @@ -51,6 +51,7 @@ Feature: flagd provider disconnect and reconnect functionality
# | name |
# | socket |

@unavailable
Scenario: Provider unavailable
Given an option "deadlineMs" of type "Integer" with value "1000"
And a unavailable flagd provider
Expand Down
2 changes: 1 addition & 1 deletion gherkin/evaluation.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@rpc @in-process
@rpc @in-process @file
Feature: flagd evaluations

# This test suite contains scenarios to test flagd providers.
Expand Down
2 changes: 1 addition & 1 deletion gherkin/events.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@rpc @in-process
@rpc @in-process @file @events
Feature: Flagd Provider State Changes

Background:
Expand Down
28 changes: 0 additions & 28 deletions gherkin/offline.feature

This file was deleted.

Loading

0 comments on commit ef03ed0

Please sign in to comment.