Skip to content

Commit ab6b888

Browse files
colebaileygitrenovate[bot]Kavindu-Dodan
authored
feat!: allow overrides for fractional seed (#737)
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]>
1 parent 9ed4e8e commit ab6b888

File tree

9 files changed

+58
-19
lines changed

9 files changed

+58
-19
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ jobs:
1414
services:
1515
# flagd-testbed for flagd RPC provider e2e tests
1616
flagd:
17-
image: ghcr.io/open-feature/flagd-testbed:v0.5.2
17+
image: ghcr.io/open-feature/flagd-testbed:v0.5.4
1818
ports:
1919
- 8013:8013
2020
# flagd-testbed for flagd RPC provider reconnect e2e tests
2121
flagd-unstable:
22-
image: ghcr.io/open-feature/flagd-testbed-unstable:v0.5.3
22+
image: ghcr.io/open-feature/flagd-testbed-unstable:v0.5.4
2323
ports:
2424
- 8014:8013
2525
# sync-testbed for flagd in-process provider e2e tests
2626
sync:
27-
image: ghcr.io/open-feature/sync-testbed:v0.5.2
27+
image: ghcr.io/open-feature/sync-testbed:v0.5.4
2828
ports:
2929
- 9090:9090
3030
# sync-testbed for flagd in-process provider reconnect e2e tests
3131
sync-unstable:
32-
image: ghcr.io/open-feature/sync-testbed-unstable:v0.5.3
32+
image: ghcr.io/open-feature/sync-testbed-unstable:v0.5.4
3333
ports:
3434
- 9091:9090
3535

providers/flagd/CONTRIBUTING.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@ In vscode for instance, the following settings are recommended:
2323
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
2424

2525
```
26-
docker run -p 8013:8013 ghcr.io/open-feature/flagd-testbed:latest
26+
docker-compose up -d
2727
```
2828
and then run
2929
```
3030
mvn test -P e2e
31-
```
31+
```
32+
33+
Note if your docker compose networking does not resolve to localhost, you can set a custom host
34+
```
35+
FLAGD_HOST=192.168.100.1 mvn test -P e2e
36+
```
37+
38+
If test-harness is being updated, commit the changes before running `mvn`.
39+
Otherwise, uncommitted changes will be overridden by maven test plugins.

providers/flagd/docker-compose.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
flagd:
3+
build:
4+
context: test-harness
5+
dockerfile: flagd/Dockerfile
6+
ports:
7+
- 8013:8013
8+
flagd-unstable:
9+
build:
10+
context: test-harness
11+
dockerfile: flagd/Dockerfile.unstable
12+
ports:
13+
- 8014:8013
14+
flagd-sync:
15+
build:
16+
context: test-harness
17+
dockerfile: sync/Dockerfile
18+
ports:
19+
- 9090:9090
20+
flagd-sync-unstable:
21+
build:
22+
context: test-harness
23+
dockerfile: sync/Dockerfile.unstable
24+
ports:
25+
- 9091:9090

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/targeting/Fractional.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ public Object evaluate(List arguments, Object data) throws JsonLogicEvaluationEx
4545
return null;
4646
}
4747

48-
bucketBy = properties.getTargetingKey();
48+
bucketBy = properties.getFlagKey() + properties.getTargetingKey();
4949
distibutions = arguments.toArray();
5050
}
5151

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

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

7271
// find distribution
73-
return distributeValue(hashKey, propertyList);
72+
return distributeValue(bucketBy, propertyList);
7473
}
7574

7675
private static String distributeValue(final String hashKey, final List<FractionProperty> propertyList)

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/process/FlagdInProcessSetup.java

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public static void setup() throws InterruptedException {
2121
FlagdInProcessSetup.provider = new FlagdProvider(FlagdOptions.builder()
2222
.resolverType(Config.Evaluator.IN_PROCESS)
2323
.deadline(3000)
24-
.host("localhost")
2524
.port(9090)
2625
.build());
2726
StepDefinitions.setProvider(provider);

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/reconnect/process/FlagdInProcessSetup.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public static void setup() throws InterruptedException {
1919
FeatureProvider workingProvider = new FlagdProvider(FlagdOptions.builder()
2020
.resolverType(Config.Evaluator.IN_PROCESS)
2121
.deadline(3000)
22-
.host("localhost")
2322
.port(9091)
2423
.build());
2524
StepDefinitions.setUnstableProvider(workingProvider);

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/targeting/FractionalTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void selfContainedFractionalA() throws JsonLogicEvaluationException {
2424

2525
/* Rule
2626
* [
27-
* "bucketKeyA", // this is resolved value of an expression
27+
* "flagAbucketKeyA", // this is resolved value of an expression
2828
* [
2929
* "red",
3030
* 50
@@ -37,7 +37,7 @@ void selfContainedFractionalA() throws JsonLogicEvaluationException {
3737
* */
3838

3939
final List<Object> rule = new ArrayList<>();
40-
rule.add("bucketKeyA");
40+
rule.add("flagAbucketKeyA");
4141

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

7070
/* Rule
7171
* [
72-
* "bucketKeyB", // this is resolved value of an expression
72+
* "flagAbucketKeyB", // this is resolved value of an expression
7373
* [
7474
* "red",
7575
* 50
@@ -82,7 +82,7 @@ void selfContainedFractionalB() throws JsonLogicEvaluationException {
8282
* */
8383

8484
final List<Object> rule = new ArrayList<>();
85-
rule.add("bucketKeyB");
85+
rule.add("flagAbucketKeyB");
8686

8787
final List<Object> bucket1 = new ArrayList<>();
8888
bucket1.add("red");

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/targeting/OperatorTest.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ void fractionalTestA() throws TargetingRuleException {
8585
final String targetingRule = "" +
8686
"{\n" +
8787
" \"fractional\": [\n" +
88-
" {\"var\": \"email\"},\n" +
88+
" {\"cat\":[\n" +
89+
" {\"var\":\"$flagd.flagKey\"},\n" +
90+
" {\"var\": \"email\"}\n" +
91+
" ]},\n" +
8992
" [\n" +
9093
" \"red\",\n" +
9194
" 25\n" +
@@ -123,7 +126,10 @@ void fractionalTestB() throws TargetingRuleException {
123126
final String targetingRule = "" +
124127
"{\n" +
125128
" \"fractional\": [\n" +
126-
" {\"var\": \"email\"},\n" +
129+
" {\"cat\":[\n" +
130+
" {\"var\":\"$flagd.flagKey\"},\n" +
131+
" {\"var\": \"email\"}\n" +
132+
" ]},\n" +
127133
" [\n" +
128134
" \"red\",\n" +
129135
" 25\n" +
@@ -161,7 +167,10 @@ void fractionalTestC() throws TargetingRuleException {
161167
final String targetingRule = "" +
162168
"{\n" +
163169
" \"fractional\": [\n" +
164-
" {\"var\": \"email\"},\n" +
170+
" {\"cat\":[\n" +
171+
" {\"var\":\"$flagd.flagKey\"},\n" +
172+
" {\"var\": \"email\"}\n" +
173+
" ]},\n" +
165174
" [\n" +
166175
" \"red\",\n" +
167176
" 25\n" +

providers/flagd/test-harness

0 commit comments

Comments
 (0)