Add OFREP failure-mode spec and ProviderInitFailureSpec#142
Merged
Conversation
2f53550 to
ba38ac2
Compare
b13ad71 to
1a3a5ec
Compare
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.
Summary
Implements #124 (B1 — OFREP WireMock failure stubs) and #125 (B2 — ProviderInitFailureSpec) from the 1.0-readiness milestone.
Stacked. Base branch is
feat/typed-errors-and-ofrep-validation(#139). This branch also merges infeat/init-timeout-and-sync-verify(#138) because both A1 (init timeout) and A4 (typed errors / classifier) are dependencies. The diff against #139 shows the merge of #138 plus the two new specs. Once #138 and #139 land inmain, retarget tomain.B1 — OFREP failure-mode integration suite
New
ofrep/src/test/scala/zio/openfeature/ofrep/OFREPFailureModeSpec.scalawith 5 WireMock-backed tests covering the FeatureFlags layer (not just direct provider calls — the typed-error classifier from #123 only fires there). Findings, all encoded as assertions:ProviderEvaluationwitherrorCodepopulated. The ZIOFeatureFlagslayer surfaces this as a successfulFlagResolutionwhoseerrorCodeis set — not as a typedUnauthorizederror. Operators alert onresolution.errorCode.isDefined. This is documented in the spec preamble so the contract is clear.Fault.CONNECTION_RESET_BY_PEER) and connection refused (server stopped mid-test): either the contrib provider catches the IOException and returnserrorCode, or the throw escapes and the classifier maps it (UnreachableforUnknownHostException/ConnectException,ProviderErroras fallback). Both shapes are accepted — the assertion proves the failure doesn't become a silent default-value evaluation.Left(FeatureFlagError.ProviderError(TimeoutException)). Asserted exactly.The pre-stop / post-stop test also proves the FeatureFlags layer flips behaviour live without process restart, which is important for OFREP-backed apps where the upstream may transiently flap.
B2 — ProviderInitFailureSpec
New
core/src/test/scala/zio/openfeature/ProviderInitFailureSpec.scalacomplementing the existingProviderInitHardeningSpec(which already covers issue cases 2/3/4). This spec adds the missing cases:initialize()that throws synchronously → layer build fails with the thrown exception (message preserved).PROVIDER_ERRORafter init → status reflectsError, evaluations fail withProviderNotReady(Error).ERROR → READY→ evaluations succeed.UnknownHostException, the OpenFeature Java SDK catches it and returns aFlagEvaluationDetailswitherrorCodepopulated; the typedUnreachabledoes not fire on this path. The classifier IS still exercised end-to-end via the OFREP failure suite above (where the throw originates outside the Java SDK's catch), and unit-tested directly inFeatureFlagErrorSpec([A4] Classify auth/network failures: add Unauthorized/Unreachable to FeatureFlagError #123). This test pins the boundary so a future refactor that changes it shows up here.Three inline test providers (
ThrowingInitProvider,EventDriverProvider,ThrowingEvalProvider) keep the spec free of testkit dependencies —corecan't depend ontestkit.Closes #124
Closes #125