-
Notifications
You must be signed in to change notification settings - Fork 7
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!: remove gherkin, add events support #51
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
node_modules | ||
node_modules | ||
flags/changing-flag.json |
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"] |
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.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script just swaps the value of the flag in |
||
|
||
# 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 |
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" | ||
} | ||
} | ||
} |
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" | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need this little wrapper script to start our |
||
# 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 script and flagd | ||
sh ./change-flag.sh & | ||
./flagd start -f 'file:testing-flags.json' -f 'file:changing-flag.json' & | ||
|
||
# wait on flagd | ||
child=$! | ||
wait "$child" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
busybox because we need some basic tools and a shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine. Final image is ~60MB