Skip to content

Commit

Permalink
feat!: allow overrides for fractional seed (#737)
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Bailey <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
4 people authored Apr 11, 2024
1 parent 9ed4e8e commit ab6b888
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:
services:
# flagd-testbed for flagd RPC provider e2e tests
flagd:
image: ghcr.io/open-feature/flagd-testbed:v0.5.2
image: ghcr.io/open-feature/flagd-testbed:v0.5.4
ports:
- 8013:8013
# flagd-testbed for flagd RPC provider reconnect e2e tests
flagd-unstable:
image: ghcr.io/open-feature/flagd-testbed-unstable:v0.5.3
image: ghcr.io/open-feature/flagd-testbed-unstable:v0.5.4
ports:
- 8014:8013
# sync-testbed for flagd in-process provider e2e tests
sync:
image: ghcr.io/open-feature/sync-testbed:v0.5.2
image: ghcr.io/open-feature/sync-testbed:v0.5.4
ports:
- 9090:9090
# sync-testbed for flagd in-process provider reconnect e2e tests
sync-unstable:
image: ghcr.io/open-feature/sync-testbed-unstable:v0.5.3
image: ghcr.io/open-feature/sync-testbed-unstable:v0.5.4
ports:
- 9091:9090

Expand Down
12 changes: 10 additions & 2 deletions providers/flagd/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ In vscode for instance, the following settings are recommended:
The continuous integration runs a set of [gherkin e2e tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) using [`flagd`](https://github.com/open-feature/flagd). These tests do not run with the default maven profile. If you'd like to run them locally, you can start the flagd testbed with

```
docker run -p 8013:8013 ghcr.io/open-feature/flagd-testbed:latest
docker-compose up -d
```
and then run
```
mvn test -P e2e
```
```

Note if your docker compose networking does not resolve to localhost, you can set a custom host
```
FLAGD_HOST=192.168.100.1 mvn test -P e2e
```

If test-harness is being updated, commit the changes before running `mvn`.
Otherwise, uncommitted changes will be overridden by maven test plugins.
25 changes: 25 additions & 0 deletions providers/flagd/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
flagd:
build:
context: test-harness
dockerfile: flagd/Dockerfile
ports:
- 8013:8013
flagd-unstable:
build:
context: test-harness
dockerfile: flagd/Dockerfile.unstable
ports:
- 8014:8013
flagd-sync:
build:
context: test-harness
dockerfile: sync/Dockerfile
ports:
- 9090:9090
flagd-sync-unstable:
build:
context: test-harness
dockerfile: sync/Dockerfile.unstable
ports:
- 9091:9090
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ public Object evaluate(List arguments, Object data) throws JsonLogicEvaluationEx
return null;
}

bucketBy = properties.getTargetingKey();
bucketBy = properties.getFlagKey() + properties.getTargetingKey();
distibutions = arguments.toArray();
}

final String hashKey = properties.getFlagKey() + bucketBy;
final List<FractionProperty> propertyList = new ArrayList<>();

double distribution = 0;
Expand All @@ -70,7 +69,7 @@ public Object evaluate(List arguments, Object data) throws JsonLogicEvaluationEx
}

// find distribution
return distributeValue(hashKey, propertyList);
return distributeValue(bucketBy, propertyList);
}

private static String distributeValue(final String hashKey, final List<FractionProperty> propertyList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public static void setup() throws InterruptedException {
FlagdInProcessSetup.provider = new FlagdProvider(FlagdOptions.builder()
.resolverType(Config.Evaluator.IN_PROCESS)
.deadline(3000)
.host("localhost")
.port(9090)
.build());
StepDefinitions.setProvider(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void setup() throws InterruptedException {
FeatureProvider workingProvider = new FlagdProvider(FlagdOptions.builder()
.resolverType(Config.Evaluator.IN_PROCESS)
.deadline(3000)
.host("localhost")
.port(9091)
.build());
StepDefinitions.setUnstableProvider(workingProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void selfContainedFractionalA() throws JsonLogicEvaluationException {

/* Rule
* [
* "bucketKeyA", // this is resolved value of an expression
* "flagAbucketKeyA", // this is resolved value of an expression
* [
* "red",
* 50
Expand All @@ -37,7 +37,7 @@ void selfContainedFractionalA() throws JsonLogicEvaluationException {
* */

final List<Object> rule = new ArrayList<>();
rule.add("bucketKeyA");
rule.add("flagAbucketKeyA");

final List<Object> bucket1 = new ArrayList<>();
bucket1.add("red");
Expand Down Expand Up @@ -69,7 +69,7 @@ void selfContainedFractionalB() throws JsonLogicEvaluationException {

/* Rule
* [
* "bucketKeyB", // this is resolved value of an expression
* "flagAbucketKeyB", // this is resolved value of an expression
* [
* "red",
* 50
Expand All @@ -82,7 +82,7 @@ void selfContainedFractionalB() throws JsonLogicEvaluationException {
* */

final List<Object> rule = new ArrayList<>();
rule.add("bucketKeyB");
rule.add("flagAbucketKeyB");

final List<Object> bucket1 = new ArrayList<>();
bucket1.add("red");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ void fractionalTestA() throws TargetingRuleException {
final String targetingRule = "" +
"{\n" +
" \"fractional\": [\n" +
" {\"var\": \"email\"},\n" +
" {\"cat\":[\n" +
" {\"var\":\"$flagd.flagKey\"},\n" +
" {\"var\": \"email\"}\n" +
" ]},\n" +
" [\n" +
" \"red\",\n" +
" 25\n" +
Expand Down Expand Up @@ -123,7 +126,10 @@ void fractionalTestB() throws TargetingRuleException {
final String targetingRule = "" +
"{\n" +
" \"fractional\": [\n" +
" {\"var\": \"email\"},\n" +
" {\"cat\":[\n" +
" {\"var\":\"$flagd.flagKey\"},\n" +
" {\"var\": \"email\"}\n" +
" ]},\n" +
" [\n" +
" \"red\",\n" +
" 25\n" +
Expand Down Expand Up @@ -161,7 +167,10 @@ void fractionalTestC() throws TargetingRuleException {
final String targetingRule = "" +
"{\n" +
" \"fractional\": [\n" +
" {\"var\": \"email\"},\n" +
" {\"cat\":[\n" +
" {\"var\":\"$flagd.flagKey\"},\n" +
" {\"var\": \"email\"}\n" +
" ]},\n" +
" [\n" +
" \"red\",\n" +
" 25\n" +
Expand Down
2 changes: 1 addition & 1 deletion providers/flagd/test-harness

0 comments on commit ab6b888

Please sign in to comment.