Skip to content

Commit

Permalink
Merge branch 'main' into feat/improve_gherkin
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Schrottner <[email protected]>
  • Loading branch information
aepfli committed Dec 30, 2024
2 parents 796c0e8 + 706a7e9 commit 53bfd58
Show file tree
Hide file tree
Showing 20 changed files with 317 additions and 72 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ jobs:
with:
context: .
file: flagd/Dockerfile
target: testbed
push: false

- name: Build flagd-testbed-unstable Docker image
uses: docker/build-push-action@v6
with:
context: .
file: flagd/Dockerfile.unstable
file: flagd/Dockerfile
target: unstable
push: false

- name: Build flagd-testbed-ssl Docker image
uses: docker/build-push-action@v6
with:
context: .
file: flagd/Dockerfile
target: ssl
push: false
16 changes: 14 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
with:
context: .
file: flagd/Dockerfile
target: testbed
push: true
tags: |
${{ env.REGISTRY }}/open-feature/${{ env.FLAGD_IMAGE_NAME }}:${{ needs.release-please.outputs.release_tag_name }}
Expand All @@ -68,12 +69,23 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: flagd/Dockerfile.unstable
file: flagd/Dockerfile
target: unstable
push: true
tags: |
${{ env.REGISTRY }}/open-feature/${{ env.FLAGD_IMAGE_NAME }}-unstable:${{ needs.release-please.outputs.release_tag_name }}
${{ env.REGISTRY }}/open-feature/${{ env.FLAGD_IMAGE_NAME }}-unstable:latest
${{ env.REGISTRY }}/open-feature/${{ env.SYNC_IMAGE_NAME }}:${{ needs.release-please.outputs.release_tag_name }}
${{ env.REGISTRY }}/open-feature/${{ env.SYNC_IMAGE_NAME }}:latest
- name: Build and push flagd-testbed-ssl Docker image
uses: docker/build-push-action@v6
with:
context: .
file: flagd/Dockerfile
target: ssl
push: true
tags: |
${{ env.REGISTRY }}/open-feature/${{ env.FLAGD_IMAGE_NAME }}-ssl:${{ needs.release-please.outputs.release_tag_name }}
${{ env.REGISTRY }}/open-feature/${{ env.FLAGD_IMAGE_NAME }}-ssl:latest
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.5.17"
".": "0.5.20"
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [0.5.20](https://github.com/open-feature/flagd-testbed/compare/v0.5.19...v0.5.20) (2024-12-25)


### Features

* move to grace period from grace attempts ([#172](https://github.com/open-feature/flagd-testbed/issues/172)) ([56a600f](https://github.com/open-feature/flagd-testbed/commit/56a600fd0f9bcdcc435ac41ed02edcf832a01b3c))

## [0.5.19](https://github.com/open-feature/flagd-testbed/compare/v0.5.18...v0.5.19) (2024-12-17)


### Features

* add certificates for ssl test and an ssl test image ([#168](https://github.com/open-feature/flagd-testbed/issues/168)) ([8177dc0](https://github.com/open-feature/flagd-testbed/commit/8177dc0c4bde7ddadb5a939f55ee70663ca485b9))

## [0.5.18](https://github.com/open-feature/flagd-testbed/compare/v0.5.17...v0.5.18) (2024-12-16)


### Features

* add yaml file with current version, to easier fetch images corr… ([#169](https://github.com/open-feature/flagd-testbed/issues/169)) ([ac1263a](https://github.com/open-feature/flagd-testbed/commit/ac1263af53f3d9380bfe4732034f4282f9a93228))

## [0.5.17](https://github.com/open-feature/flagd-testbed/compare/v0.5.16...v0.5.17) (2024-12-06)


Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ The _flagd-testbed_ container is a docker image built on flagd, which essentiall

See the [flagd docs](https://flagd.dev/) for more information on flagd.

### SSL

The _flagd-testbed-ssl_ container is based on _flagd-testbed_ but replaces all the certificates for SSL testing with a custom root CA.
Within the SSL folder you will find all the necessary OpenSSL files, and the commands used for generation.
Please do not use this CA in any kind of production environment.

## Gherkin test suite

The [gherkin/](gherkin/) dir includes a set of [_gherkin_](https://cucumber.io/docs/gherkin/) tests that define expected behavior associated with the configurations defined in the flagd-testbed (see [flags/](flags/)).
Combined with the _flagd-provider_ for the associated SDK and the flagd-testbed, these comprise a complete integration test suite.

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 All @@ -31,4 +37,5 @@ Included suites:
The Gherkin files structure can be linted using [gherkin-lint](https://github.com/vsiakka/gherkin-lint). The following commands require Node.js 10 or later.

1. npm install
1. npm run gherkin-lint
1. npm run gherkin-lint

32 changes: 30 additions & 2 deletions flagd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# we NEED flagd v0.6.4 as a minimum
FROM ghcr.io/open-feature/flagd:v0.11.4 AS flagd
FROM ghcr.io/open-feature/flagd:v0.11.5 AS flagd

FROM busybox:1.37
FROM busybox:1.37 AS testbed

COPY --from=flagd /flagd-build /flagd
COPY flags/* .
Expand All @@ -15,3 +15,31 @@ ENTRYPOINT ["sh", "change-flag-wrapper.sh", "./flagd", "start", \
"-f", "file:evaluator-refs.json", \
"-f", "file:edge-case-flags.json", \
"-f", "file:zero-flags.json"]

FROM testbed AS unstable

ENTRYPOINT ["sh", "restart-wrapper.sh", "./flagd", "start", \
"-f", "file:testing-flags.json"]

FROM alpine/openssl AS certs

# Copy the server and CA certificates
COPY ssl/* ./

RUN openssl genpkey -algorithm RSA -out server-key.pem -pkeyopt rsa_keygen_bits:2048
RUN openssl req -new -key server-key.pem -out server.csr -subj "/CN=localhost" \
&& openssl x509 -req -in server.csr -CA custom-root-cert.crt -CAkey custom-ca.key -CAcreateserial -out server-cert.pem -days 365 -sha256

FROM testbed AS ssl

# Copy the custom root CA certificate into the image

COPY --from=certs server-cert.pem /etc/ssl/certs/
COPY --from=certs server-key.pem /etc/ssl/private/
COPY --from=certs custom-root-cert.crt /etc/ssl/certs/


ENTRYPOINT ["./flagd", "start",\
"-f", "file:testing-flags.json", \
"-c", "/etc/ssl/certs/server-cert.pem", \
"-k", "/etc/ssl/private/server-key.pem"]
12 changes: 0 additions & 12 deletions flagd/Dockerfile.unstable

This file was deleted.

38 changes: 19 additions & 19 deletions gherkin/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Configuration Test
| streamDeadlineMs | FLAGD_STREAM_DEADLINE_MS | deadline for streaming calls, useful as an application-layer keepalive | int | 600000 | rpc & in-process |
| retryBackoffMs | FLAGD_RETRY_BACKOFF_MS | initial backoff for stream retry | int | 1000 | rpc & in-process |
| retryBackoffMaxMs | FLAGD_RETRY_BACKOFF_MAX_MS | maximum backoff for stream retry | int | 120000 | rpc & in-process |
| retryGracePeriod | FLAGD_RETRY_GRACE_PERIOD | amount of stream retry attempts before provider moves from STALE to ERROR state | int | 5 | rpc & in-process |
| retryGracePeriod | FLAGD_RETRY_GRACE_PERIOD | time before provider moves from STALE to ERROR state | int | 5 | rpc & in-process |
| keepAliveTime | FLAGD_KEEP_ALIVE_TIME_MS | http 2 keepalive | long | 0 | rpc & in-process |
| cache | FLAGD_CACHE | enable cache of static flags | String - `lru`, `disabled` | lru | rpc |
| maxCacheSize | FLAGD_MAX_CACHE_SIZE | max size of static flag cache | int | 1000 | rpc |
Expand Down 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
Loading

0 comments on commit 53bfd58

Please sign in to comment.