Repository navigation
refactor(provider-tck): factories for the backend controls, and keep the gate out of the API - #1925
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
…t no implementation One rule instead of a judgement per class: a control is obtained from a BackendControl factory, never constructed, and no implementation class is exported. `BackendControl.overHttp(baseUrl, backendConfiguration)` restores a capability this branch removed. Making HttpBackendControl package-private is right for the class and wrong for the capability: an adopter whose backend speaks the canonical control API but was not started by ContainerizedProviderTckTest -- already running, brought up by an external orchestrator, CI with no Docker daemon -- had no way left to reach the one conformant client, and control-api.yaml is a published contract we should not make anyone re-implement. The failure that follows is the kind this suite exists to prevent: a hand-rolled client that gets readiness subtly wrong. `BackendControl.inProcess()` does the same for the other direction, so the rule holds both ways. It returns InProcessControl rather than BackendControl because createProvider() is not on BackendControl and a plain BackendControl would strand the adopter with no way to obtain the provider -- in-process the flag store and the provider are one object. InProcessBackendControl is now package-private; nothing outside this module referenced it. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
…ad of moving it Moving CapabilityGate to `internal` forced Capability.inexpressibleBecause() from package-private to public, because the gate reads it across a package boundary. That trades a class no adopter would ever call -- final, private constructor, static-only -- for an accessor on the one enum every adopter holds. Across all three adoptions the only Capability member anyone calls is declarableExcept(), plus the enum constants. tag(), reserved(), inexpressible(), inexpressibleBecause(), fromTag(), declarable() and requireDeclarable() have no caller outside this module. So the gate goes back beside Capability and becomes package-private, leaving the API altogether rather than moving to another package while staying public. The steps reach it through TckRuntime.gateScenario(), already the public entry point they call for the suite lifecycle, so nothing new is exported -- one fewer public class and one fewer public method than before. Also fixes TckRuntime's message, which told the reader to supply an HttpBackendControl, a class this branch had made unreachable. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
The step classes and their step methods are public because Cucumber requires it, not as a style choice: PicoFactory.isInstantiable tests Modifier.isPublic and !isAbstract before registering a component, and MethodScanner enumerates candidates with Class.getMethods(), which returns public methods only. Neither complains when it finds nothing. A scenario whose steps cannot be resolved is reported undefined, and a non-strict run reads as a pass -- so demoting glue while tidying turns conformance green by removing the questions. That is the same shape as go-sdk#596, where 30 scenarios reported undefined and the test passed. The test reads the glue package from the artifact's code source rather than a hard-coded list, so a step class added later is covered without anyone remembering. The extension README now states the requirement too, since that is where an extension author looks. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
aepfli
force-pushed
the
chore/tck-seams
branch
2 times, most recently
from
October 16, 2026 21:14
811f477 to
0737475
Compare
ProviderTck held nine public String constants, a private constructor and nothing else. Every reference to them was already inside the tck package -- the @ConfigurationParameter annotations on ProviderTckTest -- and no adoption names the class at all, so most of them had no reason to be public. They move onto what was TckRuntime, which the extension README already sends an extension author to for the harness and backend control. That makes one class the thing an extension talks to. Three constants stay public, the three an extension needs: EXTENSIONS (the directory its feature files go in), EXTENSION_GLUE (the package its steps go in) and ALL_GLUE (for ALL_GLUE + ",com.vendor.steps"). FEATURES, GLUE, PLUGINS, OBJECT_FACTORY, PARALLEL_EXECUTION_ENABLED and FEATURE_EXECUTION_MODE are package-private; they configure the suite, they do not describe it. HARNESS_SELECTOR_PROPERTY goes too -- it names a system property, so the contract is the -Dopenfeature.tck.harness=... flag the README documents, not the Java constant, which was read only inside the class. get() is gone with it, and that is a fix rather than a tidy. It had two callers, both in AbstractSteps, and both dereferenced it immediately -- nobody held the instance. But stop() nulls the singleton while an instance already handed out keeps its own harness and backendControl fields, so an extension author who cached get() in a field -- the obvious thing to do with a getter -- would go on getting answers from a suite that had already torn down. harness() and backendControl() are static now and re-read the singleton, so nothing can go stale; startIfNeeded() returns void, its result never having been used. No ProviderTck instance escapes the class. The merged class takes the name ProviderTck rather than keeping TckRuntime, because the rest of the adopter-facing API is already ProviderTckTest, ContainerizedProviderTckTest and ProviderTckHarness -- the name was the one missing from that family, not an addition to it. It also leaves ProviderTck.ALL_GLUE reading exactly as it did before this PR. One public type and nine public constants become zero and three, and the entry point has no instance to misuse. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
aepfli
force-pushed
the
chore/tck-seams
branch
from
October 16, 2026 21:20
0737475 to
f300076
Compare
…r own ObjectFactory (#1926) Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
… default BackendType gains CUSTOM and backendType() is a default method returning it, so an implementation the TCK does not ship reports honestly without being asked, and cannot overstate by guessing HTTP. One that genuinely drives openapi/control-api.yaml overrides to HTTP and claims the comparability that goes with it. Closed set rather than a String: the enum matters only to a custom control, which owns its own type anyway, and CUSTOM already covers the case a third value would be invented for -- while a String would be wider than the vocabulary a report can compare across providers. DeclarationApiTest previously pinned backendType() as abstract so a custom control had to state it. That is inverted on purpose: silence now yields the weaker claim, which the test asserts through an anonymous BackendControl. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
aepfli
force-pushed
the
chore/tck-seams
branch
from
October 17, 2026 09:28
ff87500 to
7032466
Compare
… singleton TckLifecycle is an instance owned by TckObjectFactory, started on the first scenario that factory serves. Cucumber supplies one factory per run for sequential scenarios and one per thread for parallel ones (SingletonObjectFactorySupplier against ThreadLocalObjectFactorySupplier), so that ownership is what decides whether threads share a backend or each get their own. Enabling parallel execution now gives a thread its own harness and its own Compose stack. It stays off here: that is a separate decision with an N-times-Docker cost. @BeforeAll no longer starts anything. It marks the suite running and keeps the fail-fast capability check, so a misdeclared suite fails once and cleanly rather than inside the first scenario of every thread. @afterall drains a registry, because it runs on one thread and cannot otherwise stop what another thread started. Two statics remain, neither holding a harness: the suite-running flag, which is what stops extension-only glue starting a backend nobody asked for, and the registry teardown needs. ObjectFactory has no per-run or per-thread hook -- start() and stop() are per scenario -- so suite-scoped teardown cannot be done without one. TckLifecycleTest, in the same package, covers the three properties this turns on: two lifecycles own separate controls, endSuite stops the ones other threads started, and a failed start is torn down rather than left registered. startedCount() exists for those assertions and is package-private. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
Every port a containerized suite declares is a container port. The stack must not pin host ports, so Compose maps each to an arbitrary one and BackendEndpoint resolves the mapping -- which is why createProvider(BackendEndpoint) is handed an endpoint rather than reading the declarations back. Dialling a declared port reaches nothing, and the README example modelled the right thing without saying why. Also records what a parallel run costs, measured against flagd rather than reasoned about. Enabling cucumber.execution.parallel.enabled works: each thread gets its own object factory, so each gets its own harness and backend, and both suites reported the same 59 passed, 2 skipped, 4 failed as a serial run. But fixed.parallelism is a ForkJoinPool target, not a cap, and these steps block on events and control calls -- so the pool grew to 10 and 8 workers and started 18 Compose stacks for 130 scenarios, gaining 12% of wall-clock. Pinning fixed.max-pool-size=2 gave 4 stacks, two per suite, and 24%. Random host ports are what make this possible at all: two stacks with pinned ports would collide on bind. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
The suite set cucumber.execution.parallel.enabled=false through a @ConfigurationParameter, which is a discovery-request parameter and so beats both -D and an adopter's junit-platform.properties. An adopter could not turn parallelism on at all. Cucumber's own default is false, so dropping the annotation and the PARALLEL_EXECUTION_ENABLED constant leaves the suite sequential while making the decision theirs. The two test suites that want a deterministic serial run now say "false" themselves rather than borrowing the constant. FEATURE_EXECUTION_MODE stays at same_thread, which now means something useful: an adopter who enables parallelism gets feature-level concurrency rather than scenario-level, bounding threads by the feature count. Measured against flagd, with the pool capped to match parallelism: two threads cut the suites from 82.9s to 62.0s for four stacks, four threads to 53.2s for eight. Uncapped, ForkJoinPool compensation grew to 18 threads and 18 stacks for a third of that gain. Same 59 passed, 2 skipped, 4 failed in every configuration. Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1923, taking its comment trim and
steps/move. Includes #1926. Nine commits with one aim: the smallest public API that still lets an adopter run the suite and extend it.The public API
An adopter writes against nine types:
ProviderTckTest(no backend) orContainerizedProviderTckTest(Docker Compose) — or implementProviderTckHarnessCapability(four methods),KnownDeviationBackendControl.overHttp(..)/.inProcess(), returningBackendControl/InProcessControl;BackendTypeonly if you write your ownBackendEndpointAn extension author adds four:
TckState,FlagUnderTest,ProviderEventRecord, andProviderTck's three constants.Nothing else is API.
HttpBackendControl,InProcessBackendControl,TckLifecycle,CanonicalFlagsandReportNamesare package-private. The eight public types underinternalare framework mechanics, not design: Cucumber discovers glue withClass.getMethods(), andServiceLoaderinstantiates the listener and the object factory.What changed
openapi/control-api.yamlbut was not started by the TCK otherwise has no conformant client, and Appendix F makes that the normative path, not the carve-out.CapabilityGateis gone, its four rules areCapability.requireDeclared(..), andinexpressibleBecause()stays package-private instead of being forced public.GlueVisibilityTestpins that step classes and their methods are public. Cucumber reports undefined rather than failing when they are not, so demoting glue turns conformance green by deleting the questions — go-sdk#596 had 30 scenarios undefined and a passing test.ProviderTck: nine public constants down to three, and no instance escapes the class.ObjectFactory; the suite lifecycle becomes a package-privateTckLifecyclebeside the glue it serves;Capabilitynarrows from eight public members to four.BackendTypereplacesControlApi, withCUSTOMas the default. A control the TCK does not ship reports honestly without being asked, and cannot overstate by guessingHTTP.@AfterAlldrains, sinceObjectFactory's only lifecycle hooks are per scenario.Verification
mvn -pl tools/tck test— 254 tests, 0 failures.flagd on testbed v3.10.3,
tools/tckbuilt in the reactor,cleanboth sides: both suites 65 scenarios, 59 passed, 2 skipped,4 failed, two backends, and the same four named failures — float narrowing, integral-float coercion, large-integer precision,
Example #1.8.
The pre-1925 base gives exactly the same, with the identical flagd commits replayed onto it and run the same way. So these eight
commits are conformance-neutral against a real adoption, not merely green on their own tests.
Open
internal.stepsis the only reasonrequireDeclarable(),requireDeclared(),TckValues.convert()andTckSuiteListener.currentSuite()are public. Amodule-info.java, or collapsing the package into the one it serves, is the real fix — worth deciding before this merges.Parallel execution is now the adopter's call. The suite used to pin
cucumber.execution.parallel.enabled=falsethrough a@ConfigurationParameter— a discovery-requestparameter, which beats both
-Dand their ownjunit-platform.properties, so they could not turn iton. That pin is gone; Cucumber's default keeps the suite sequential.
Measured against flagd, with the pool capped to match parallelism, and the same 59 passed, 2 skipped,
4 failed in every configuration:
Uncapped, ForkJoinPool compensation grew to 18 threads and 18 stacks for a third of the gain, because
each thread starts a backend of its own.
ProviderTckTest's javadoc says so, with the numbers. Notpinned either: a bound we set would be as unoverridable as the one just removed.