Skip to content

Commit 34aa7f3

Browse files
committed
test(ofrep): keep the conformance suite out of the default build, and say so
Same change as the flagd adoption's, for the same reason: the TCK suite is excluded from `poe test` and `poe cov`, gets a `poe test-tck` of its own, and the README records the policy and the tally -- 2 failed, 37 passed, 16 skipped, 1 xfailed, where both failures are canonical flags flagd-testbed v3.8.0 does not seed and the xfail is the one genuine provider gap. It had been running in the default build, so this branch's build was red too. SettledControl also needed correcting, and the correction is a reversal of its own premise. It claimed `POST /start` "is not specified to return only once that state is being served". It is, and it already was at the pin this branch carried: control-api.yaml says "MUST NOT return until the seeded flag state is actually being served", and names this very case -- "the reference implementation exhibits this: its /start returns roughly 40ms before flagd's file sources reach the flag store". So this is not a gap in the contract that the adoption fills in; it is a backend that breaks the contract, and flagd-testbed#394 is open and unmerged. That changes what the file is, for the better. Appendix F now states that a suite must not paper over such a backend from the shared harness -- a fixed delay there "buys silence, not correctness" and every future adopter inherits it -- and that the wait belongs in the adoption, "set explicitly and citing the defect, so that it reads as a named workaround for a specific backend and disappears when the backend is fixed". SettledControl is exactly that, so it now says so instead of arguing for itself. It also forwards `control_api` from the control it delegates to, which the base's now-required protocol member makes necessary and which is the honest answer: the normative control path is still the HTTP control API, and this adds a readiness probe over the provider's own public endpoint rather than replacing anything. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
1 parent 9574a86 commit 34aa7f3

4 files changed

Lines changed: 90 additions & 24 deletions

File tree

‎providers/openfeature-provider-ofrep/README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ api.set_provider(OFREPProvider())
2323

2424
<!-- TODO: add configuration options -->
2525

26+
## Provider conformance suite
27+
28+
This provider runs the [OpenFeature Provider Conformance Suite][tck] against a flagd-testbed stack
29+
serving OFREP, in `tests/tck`. The suite owns the container stack: `tests/tck/conftest.py` declares
30+
a Compose file and the port the provider connects to, and nothing else.
31+
32+
**It is excluded from the default build, and a maintainer runs it by hand before merging a change to
33+
it.**
34+
35+
```
36+
poe test-tck # needs Docker
37+
poe test # everything else, which is what CI runs
38+
```
39+
40+
The exclusion is a decision rather than an oversight. It needs Docker, and — the part that actually
41+
decides it — a conformance suite reports what is true of the *stack* under test. A full run today is
42+
**2 failed, 37 passed, 16 skipped, 1 xfailed**: both failures are canonical flags that flagd-testbed
43+
v3.8.0 does not seed yet, and the `xfail` is the one genuine provider gap, recorded as a
44+
`KnownDeviation` rather than hidden. A gate that has to be green cannot hold a suite whose honest
45+
output is red, and turning the two backend gaps into `xfail`s would say the provider is at fault
46+
where the backend is.
47+
48+
`tests/tck/conftest.py` and `tests/tck/test_ofrep_conformance.py` account for each one, so a
49+
reviewer running the suite can tell a new failure from a known one.
50+
51+
`tests/tck/settled_control.py` is worth reading before you touch the suite: it is a named workaround
52+
for one backend defect — flagd-testbed's `/start` returns about 40 ms before it serves the flag set,
53+
which the control API forbids — and the specification prescribes that such a wait live in the
54+
adoption, citing the defect, rather than in the shared harness.
55+
56+
[tck]: ../../tools/openfeature-tck/README.md
57+
2658
## License
2759

2860
Apache 2.0 - See [LICENSE](./LICENSE) for more information.

‎providers/openfeature-provider-ofrep/pyproject.toml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,16 @@ disallow_any_generics = false
7979
strict = true
8080

8181
[tool.poe.tasks]
82-
test = "pytest tests"
83-
test-cov = "coverage run -m pytest tests"
82+
# `tests/tck` is excluded from the default build on purpose, and a maintainer
83+
# runs `poe test-tck` by hand before merging a change to it. It needs Docker,
84+
# and more to the point a conformance suite reports what is true of the *stack*
85+
# under test: two of its failures today are canonical flags flagd-testbed does
86+
# not seed yet, which are the report rather than something to hide. A gate that
87+
# has to be green cannot hold a suite whose honest output is red. See
88+
# tests/tck/conftest.py for the tally, and the TCK's README for the policy.
89+
test = "pytest tests --ignore=tests/tck"
90+
test-cov = "coverage run -m pytest tests --ignore=tests/tck"
91+
test-tck = "pytest tests/tck"
8492
cov-report = "coverage xml"
8593
cov = [
8694
"test-cov",

‎providers/openfeature-provider-ofrep/tests/tck/conftest.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ def ofrep_control(tck_backend: RunningBackend, ofrep_base_url: str) -> SettledCo
7171
``prepare_scenario`` takes the documented ``/start`` fallback. The probe
7272
costs one 404 for the whole session.
7373
74-
Wrapped in :class:`SettledControl` because ``/start`` returns before the
75-
backend serves the flag set, and a stateless provider has no initialisation
76-
to hide that window behind. See that module -- it is a finding about the
77-
control API's guarantee, not a convenience, and it is a readiness probe over
78-
the provider's own public endpoint rather than a sleep.
74+
Wrapped in :class:`SettledControl` because this backend's ``/start``
75+
returns before it serves the flag set -- which ``control-api.yaml`` forbids
76+
in those words -- and a stateless provider has no initialisation to hide
77+
that window behind. See that module: it is a named workaround for one
78+
backend's defect, which is where Appendix F says such a wait belongs, and it
79+
is a readiness probe over the provider's own public endpoint rather than a
80+
sleep.
7981
"""
8082
return SettledControl(tck_backend.control, ofrep_base_url)
8183

‎providers/openfeature-provider-ofrep/tests/tck/settled_control.py‎

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
"""``HttpControl``, plus a wait for the backend to actually serve the flag set.
2-
3-
**The problem this exists for is worth stating carefully, because it is a
4-
finding rather than a workaround.**
5-
6-
``POST /start`` is specified to reseed flag state to the named configuration's
7-
baseline (normative requirement 2 in the TCK's ``control-api.yaml``). It is not
8-
specified to *return only once that state is being served*, and flagd-testbed's
9-
launchpad does not: it returns as soon as flagd answers ``/readyz``
10-
(``launchpad/pkg/flagd.go``), which flagd does before its file sources have been
11-
loaded into the flag store. Measured against this testbed, the window is short
12-
-- around 40ms -- but it is real and reliably hit:
1+
"""``HttpControl``, plus a wait for a backend that returns before it serves.
2+
3+
**This is a named workaround for one backend's defect, and it belongs here
4+
rather than in the shared harness.** That is not a preference; it is what the
5+
specification prescribes. ``control-api.yaml`` requires every state-changing
6+
endpoint to serve the new state before it returns, and Appendix F adds that a
7+
suite must not paper over a backend that breaks it -- a fixed delay in the
8+
harness "buys silence, not correctness", is un-tunable because the window
9+
belongs to the backend, and would be inherited by every future adopter without
10+
knowing why. Where an adopter is stuck with such a backend, "the wait belongs in
11+
**that adoption**, set explicitly and citing the defect, so that it reads as a
12+
named workaround for a specific backend and disappears when the backend is
13+
fixed". This file is that.
14+
15+
**The defect.** ``POST /start`` reseeds flag state to the named configuration's
16+
baseline and **MUST NOT return until that state is actually being served** --
17+
the control API says so in those words, and names this very case: "the reference
18+
implementation exhibits this: its ``/start`` returns roughly 40ms before flagd's
19+
file sources reach the flag store". flagd-testbed's launchpad returns as soon as
20+
flagd answers ``/readyz`` (``launchpad/pkg/flagd.go``), which flagd does before
21+
its file sources have been loaded into the flag store.
22+
`flagd-testbed#394 <https://github.com/open-feature/flagd-testbed/pull/394>`_
23+
would close it and is open and unmerged, so the window is still there. Measured
24+
against the pinned image it is short -- around 40ms -- but real and reliably
25+
hit:
1326
1427
start:200 {"errorCode":"FLAG_NOT_FOUND","errorDetails":"flag `float-flag` does not exist"}
1528
start:200 {"value":0.5,"key":"float-flag","reason":"STATIC","variant":"half"}
@@ -24,10 +37,10 @@
2437
provider.
2538
2639
**A stateless provider is the first adopter with no initialisation to hide a
27-
backend's warm-up behind**, which makes it the one that discovers whether the
28-
control API's guarantee is strong enough. It is not: "reseeded" and "serving"
29-
need to be the same instant, or every stateless provider reimplements this. That
30-
belongs in the control API contract, and until it is there it belongs here.
40+
backend's warm-up behind**, which is what made it the one that found this. The
41+
guarantee itself is not in doubt -- "reseeded" and "serving" are already
42+
required to be the same instant -- so what is left is a backend that does not
43+
keep it, and this wait goes away the day the testbed does.
3144
3245
**Why this is not cheating.** It manipulates nothing. It is a readiness probe
3346
over the same public OFREP endpoint the provider uses, on a canonical flag,
@@ -48,7 +61,7 @@
4861
import urllib.error
4962
import urllib.request
5063

51-
from openfeature.contrib.tools.tck import HttpControl
64+
from openfeature.contrib.tools.tck import ControlApi, HttpControl
5265

5366
__all__ = ["SettledControl"]
5467

@@ -87,6 +100,17 @@ def __init__(
87100
def description(self) -> str:
88101
return f"{self._control.description}, awaited through the OFREP endpoint"
89102

103+
@property
104+
def control_api(self) -> ControlApi:
105+
"""Whatever the control being delegated to says, which is ``"http"``.
106+
107+
Forwarded rather than answered, because this class adds a readiness
108+
probe and manipulates nothing: the normative control path is still the
109+
HTTP control API, and a report that said otherwise would understate what
110+
was exercised.
111+
"""
112+
return self._control.control_api
113+
90114
def prepare_scenario(self) -> None:
91115
self._control.prepare_scenario()
92116
self._await_flags()

0 commit comments

Comments
 (0)