Skip to content

Commit b771775

Browse files
feat: add disabled flag evaluation test scenarios (#376)
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
1 parent b507289 commit b771775

6 files changed

Lines changed: 171 additions & 1 deletion

File tree

evaluator/flags/testkit-flags.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,50 @@
655655
"targeting": {
656656
"sem_ver": [{"var": "version"}, "="]
657657
}
658+
},
659+
"disabled-boolean-flag": {
660+
"state": "DISABLED",
661+
"variants": {
662+
"on": true,
663+
"off": false
664+
},
665+
"defaultVariant": "on"
666+
},
667+
"disabled-string-flag": {
668+
"state": "DISABLED",
669+
"variants": {
670+
"greeting": "hi",
671+
"parting": "bye"
672+
},
673+
"defaultVariant": "greeting"
674+
},
675+
"disabled-integer-flag": {
676+
"state": "DISABLED",
677+
"variants": {
678+
"one": 1,
679+
"ten": 10
680+
},
681+
"defaultVariant": "ten"
682+
},
683+
"disabled-float-flag": {
684+
"state": "DISABLED",
685+
"variants": {
686+
"tenth": 0.1,
687+
"half": 0.5
688+
},
689+
"defaultVariant": "half"
690+
},
691+
"disabled-object-flag": {
692+
"state": "DISABLED",
693+
"variants": {
694+
"empty": {},
695+
"template": {
696+
"showImages": true,
697+
"title": "Check out these pics!",
698+
"imagesPerPage": 100
699+
}
700+
},
701+
"defaultVariant": "template"
658702
}
659703
},
660704
"$evaluators": {

evaluator/gherkin/disabled.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@disabled
2+
Feature: Evaluator disabled flag evaluation
3+
4+
# Validates that disabled flags resolve with reason=DISABLED. The evaluator
5+
# substitutes the caller-provided default value and omits the variant.
6+
# Flags are configured in evaluator/flags/testkit-flags.json.
7+
# Relates to: https://github.com/open-feature/flagd/issues/1965
8+
9+
Scenario Outline: Resolve disabled flag returns reason DISABLED with the default value
10+
Given an evaluator
11+
And a <type>-flag with key "<key>" and a fallback value "<default>"
12+
When the flag was evaluated with details
13+
Then the resolved details value should be "<default>"
14+
And the reason should be "DISABLED"
15+
16+
Examples:
17+
| key | type | default |
18+
| disabled-boolean-flag | Boolean | false |
19+
| disabled-string-flag | String | bye |
20+
| disabled-integer-flag | Integer | 1 |
21+
| disabled-float-flag | Float | 0.1 |
22+
| disabled-object-flag | Object | {} |

flagd/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG FLAGD_BASE_IMAGE=ghcr.io/open-feature/flagd:v0.15.5
1+
ARG FLAGD_BASE_IMAGE=ghcr.io/open-feature/flagd:v0.16.0
22
ARG TARGETARCH
33

44
FROM ${FLAGD_BASE_IMAGE} AS flagd

flags/disabled-flags.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"flags": {
3+
"disabled-boolean-flag": {
4+
"state": "DISABLED",
5+
"variants": {
6+
"on": true,
7+
"off": false
8+
},
9+
"defaultVariant": "on"
10+
},
11+
"disabled-string-flag": {
12+
"state": "DISABLED",
13+
"variants": {
14+
"greeting": "hi",
15+
"parting": "bye"
16+
},
17+
"defaultVariant": "greeting"
18+
},
19+
"disabled-integer-flag": {
20+
"state": "DISABLED",
21+
"variants": {
22+
"one": 1,
23+
"ten": 10
24+
},
25+
"defaultVariant": "ten"
26+
},
27+
"disabled-float-flag": {
28+
"state": "DISABLED",
29+
"variants": {
30+
"tenth": 0.1,
31+
"half": 0.5
32+
},
33+
"defaultVariant": "half"
34+
},
35+
"disabled-object-flag": {
36+
"state": "DISABLED",
37+
"variants": {
38+
"empty": {},
39+
"template": {
40+
"showImages": true,
41+
"title": "Check out these pics!",
42+
"imagesPerPage": 100
43+
}
44+
},
45+
"defaultVariant": "template"
46+
},
47+
"cross-flagset-flag": {
48+
"state": "DISABLED",
49+
"variants": {
50+
"on": true,
51+
"off": false
52+
},
53+
"defaultVariant": "on"
54+
}
55+
}
56+
}

flags/selector-flags.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
"bar": "bar"
88
},
99
"defaultVariant": "foo"
10+
},
11+
"cross-flagset-flag": {
12+
"state": "ENABLED",
13+
"variants": {
14+
"on": true,
15+
"off": false
16+
},
17+
"defaultVariant": "on"
1018
}
19+
},
20+
"metadata": {
21+
"flagSetId": "selector-set"
1122
}
1223
}

gherkin/disabled.feature

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@disabled @in-process @rpc
2+
Feature: Disabled flag evaluation
3+
4+
# Test coverage for disabled flag behavior. A flag with state=DISABLED resolves
5+
# successfully with reason=DISABLED; the evaluator substitutes the caller-provided
6+
# default value and omits the variant.
7+
# Relates to: https://github.com/open-feature/flagd/issues/1965
8+
9+
Scenario Outline: Evaluating a disabled flag returns reason DISABLED and code default
10+
Given an option "cache" of type "CacheType" with value "disabled"
11+
And a stable flagd provider
12+
And a <type>-flag with key "<key>" and a default value "<default>"
13+
When the flag was evaluated with details
14+
Then the resolved details value should be "<default>"
15+
And the reason should be "DISABLED"
16+
17+
Examples:
18+
| key | type | default |
19+
| disabled-boolean-flag | Boolean | false |
20+
| disabled-string-flag | String | bye |
21+
| disabled-integer-flag | Integer | 1 |
22+
| disabled-float-flag | Float | 0.1 |
23+
| disabled-object-flag | Object | {} |
24+
25+
Scenario Outline: Flag disabled in one flag set, enabled in another
26+
Given an option "cache" of type "CacheType" with value "disabled"
27+
And an option "selector" of type "String" with value "<selector>"
28+
And a stable flagd provider
29+
And a Boolean-flag with key "cross-flagset-flag" and a default value "false"
30+
When the flag was evaluated with details
31+
Then the resolved details value should be "<resolved_value>"
32+
And the reason should be "<reason>"
33+
34+
Examples:
35+
| selector | resolved_value | reason |
36+
| flags/allFlags.json | false | DISABLED |
37+
| rawflags/selector-flags.json | true | STATIC |

0 commit comments

Comments
 (0)