-
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.
feat!: remove gherkin, add events support
Signed-off-by: Todd Baert <[email protected]>
- Loading branch information
Showing
10 changed files
with
73 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
node_modules | ||
node_modules | ||
flags/changing-flag.json |
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,6 +1,10 @@ | ||
FROM ghcr.io/open-feature/flagd:v0.5.2 | ||
FROM ghcr.io/open-feature/flagd:v0.6.3 as flagd | ||
|
||
COPY testing-flags.json testing-flags.json | ||
FROM busybox:1.36 | ||
|
||
COPY --from=flagd /flagd-build /flagd | ||
COPY flags/* . | ||
COPY wrapper.sh . | ||
LABEL org.opencontainers.image.source = "https://github.com/open-feature/test-harness" | ||
|
||
ENTRYPOINT ["/flagd", "start", "-f", "file:testing-flags.json"] | ||
ENTRYPOINT ["sh", "wrapper.sh"] |
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,18 +1,9 @@ | ||
# OpenFeature Test Harness | ||
|
||
This repository contains the makings of an end-to-end test suite for OpenFeature SDKs. | ||
This repository contains a docker image to support the [gherkin suites](https://github.com/open-feature/spec/blob/main/specification/appendix-b-gherkin-suites.md) in the OpenFeature specification. | ||
|
||
## flagd-testbed container | ||
|
||
The _flagd-testbed_ container is a docker image built on flagd, which essentially just adds a simple set of flags for the purposes of testing OpenFeature SDKs. | ||
|
||
## Gherkin test suite | ||
|
||
The test suite is a set of [_gherkin_](https://cucumber.io/docs/gherkin/) tests that define expected behavior associated with the flags defined in the flagd-testbed. Combined with the _flagd-provider_ for that SDK and the flagd-testbed, these comprise a complete end-to-end tests suite. | ||
|
||
### Lint Gherkin files | ||
|
||
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 | ||
`testing-flags.json` contains a set of flags consistent with the [evaluation feature](https://github.com/open-feature/spec/blob/main/specification/assets/gherkin/evaluation.feature). | ||
`change-flag.sh` runs in the test container generates a file `changing-flag.json`, which contains a flag that changes once every seconds, allowing to easily test change events. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
# this simple script toggles a flag value for a easy way of testing events | ||
cat ./changing-flag-foo.json > ./changing-flag.json | ||
|
||
while true | ||
do | ||
sleep 1 | ||
cat ./changing-flag-foo.json > ./changing-flag.json | ||
echo 'updated flag changing-flag value to "foo"' | ||
|
||
sleep 1 | ||
cat ./changing-flag-bar.json > ./changing-flag.json | ||
echo 'updated flag changing-flag value to "bar"' | ||
done |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"flags": { | ||
"changing-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"foo": "foo", | ||
"bar": "bar" | ||
}, | ||
"defaultVariant": "bar" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"flags": { | ||
"changing-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"foo": "foo", | ||
"bar": "bar" | ||
}, | ||
"defaultVariant": "foo" | ||
} | ||
} | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
# wrapper script to start change-flag.sh and flagd, and forward signals to the child process | ||
|
||
# handle SIGINTs and SIGTERMs so we can kill the container | ||
handle_term() { | ||
kill -TERM "$child" 2>/dev/null | ||
} | ||
|
||
handle_int() { | ||
kill -INT "$child" 2>/dev/null | ||
} | ||
|
||
trap handle_term SIGTERM | ||
trap handle_int SIGINT | ||
|
||
# start change scriptm and flagd | ||
sh ./change-flag.sh & | ||
./flagd start -f 'file:testing-flags.json' -f 'file:changing-flag.json' & | ||
|
||
# wait on flagd | ||
child=$! | ||
wait "$child" |