Repository navigation
refactor: test suite - #299
Open
vazarkevych wants to merge 20 commits into
Open
vazarkevych wants to merge 20 commits into
vazarkevych wants to merge 20 commits into
Conversation
added 5 commits
November 1, 2026 00:01
Decode the whole file strictly instead of joining lines and trimming, so cached payloads keep their line breaks and surrounding whitespace, and malformed bytes surface as a CharacterCodingException.
…ntract tests Move tests into packages that mirror lib's main sources, add GbCacheManager and features-repository contract tests (shared with the cache modules via lib's test fixtures, which are not published), and add shared test helpers.
# Conflicts: # lib/src/test/java/growthbook/sdk/java/ConditionEvaluatorTest.java # lib/src/test/java/growthbook/sdk/java/StickyBucketServiceFailureTest.java # lib/src/test/java/growthbook/sdk/java/multiusermode/ExperimentTrackerTest.java # lib/src/test/java/growthbook/sdk/java/multiusermode/GrowthBookClientTest.java # lib/src/test/java/growthbook/sdk/java/multiusermode/configurations/OptionsValidatorTest.java
The @AfterEach hook appended every served request to /tmp/gbaudit/wm.log, a leftover from local debugging that fails on any machine without that directory.
Confidence Score: 5/5
[Medium impact] This PR appears safe to merge. Reviews (8) · Last reviewed commit: "Merge branch 'refactor/client-core' into..." · Reviewed by Greptile |
This comment has been minimized.
This comment has been minimized.
added 3 commits
November 20, 2026 09:45
WireMock 2.35 notifies request listeners before it records the request in its journal, so awaiting the listener and then reading the journal raced and failed intermittently on CI. Record the track requests in the listener itself and read them from there.
The GbCacheManager contract and InMemoryCachingManagerImplTest bracketed writes between two wall-clock reads, so a clock adjustment could fail a correct adapter. The contract now owns a mutable clock that adapters taking a Clock read from, and asserts the exact reported write time; FileCachingManagerImpl, whose times come from file mtimes, compares against the file's own mtime. InMemoryCachingManagerImpl gains a package-private Clock constructor; its public constructor is unchanged.
# Conflicts: # lib/src/test/java/growthbook/sdk/java/NativeJavaGbFeatureRepositoryMainBehaviorTest.java # lib/src/test/java/growthbook/sdk/java/evaluators/internal/ForcedValuesTest.java # lib/src/test/java/growthbook/sdk/java/multiusermode/internal/FeatureValuesTest.java # lib/src/test/java/growthbook/sdk/java/repository/LocalGbFeatureRepositoryBehaviorTest.java # lib/src/test/java/growthbook/sdk/java/repository/LruETagCacheTest.java
Collaborator
Author
|
@greptile review |
# Conflicts: # lib/src/test/java/growthbook/sdk/java/NativeJavaGbFeatureRepositoryRefreshTest.java # lib/src/test/java/growthbook/sdk/java/plugin/PluginIntegrationTest.java # lib/src/test/java/growthbook/sdk/java/repository/LocalGbFeatureRepositoryBehaviorTest.java
6 tasks done
Collaborator
Author
|
@greptile review |
Collaborator
Author
|
@greptile review |
Collaborator
Author
|
@greptile review |
…resh never runs Every poll returning null made both assertSame checks pass, so a scheduler dropping all forced refreshes went unnoticed.
The diagnostics provider read the wall clock, so the tests built their fetch, cache and expiry times from it too; a clock adjustment between the two reads could break the exact age assertions. The provider and the client's initialization-error timestamp now take an injectable Clock (system UTC by default), and the tests pass a fixed one.
Collaborator
Author
|
@greptile review |
Moves the repository-core case into the lifecycle test that holds the other SSE initialization cases, and lets InMemoryCacheManager report per-key last-updated timestamps (none by default).
…est fails A failed awaitFetchStarted skipped gate.countDown, leaving a non-daemon loader blocked forever. The gate release, cache shutdown and loader cleanup now run in finally, and the loader is a daemon thread.
Collaborator
Author
|
@greptile review |
Collaborator
Author
|
@greptile review |
This branch has not been deployed
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.
Base:
refactor/client-core· stacked on #298; review after it, this diff only shows the test stage.What
ConditionEvaluatorTest→evaluators/,UrlUtilsTest→util/. They follow one style: a plain behaviour sentence in@DisplayName, a package-private method named after the behaviour, and// Given/// When/// Thenbodies.GbCacheManagercontract tests, shared with the cache modules throughlib's test fixtures (java-test-fixtures). Those fixtures are not published: thetestFixtures*variants are skipped in the component.GBFeaturesRepositoryandNativeJavaGbFeatureRepository.testhelpersand the test fixtures.fix(sandbox).FileCachingManagerImpldecodes the whole cache file strictly instead of joining lines and trimming. Cached payloads keep their line breaks and surrounding whitespace, and malformed bytes surface as aCharacterCodingException.main's new tests from #287, #292 and #235 are moved into this structure:$inGroup/$notInGroupcases joinevaluators/ConditionEvaluatorTestas parameterized cases;GrowthBookStickyBucketServiceFailureTest;markIfFirst/untrack/ bounded-size cases joinExperimentTrackerTest;stickyBucketTimeoutcases joinOptionsValidatorTest.The tests added on the lower PRs of the stack are written in this style in their new packages: repository isolation of the parsed features, plugin start after a failed construction, and the tracking plugin's
close()waiting for a batch held on a caller-supplied executor.Why
Tests were spread across packages that did not match the code, depended on reflection and real time, and duplicated setup. Mirrored packages, shared contract tests and common helpers make it clear where a test belongs, and run every cache adapter and both repositories against the same expectations.
Verification
./gradlew build javadocon JDK 17, merged with currentmain:libgrowthbook-cache-caffeinegrowthbook-cache-jcachegrowthbook-cache-redisThe skipped tests are failing-storage and shared-storage contract cases that do not apply to the in-memory, file and Caffeine adapters; two are charset cases that run only on a non-UTF-8 platform.
Six test classes that came from
mainare in the right packages but still use the older style:GrowthBookClientTrackingTest,GrowthBookClientStickyBucketTest,StickyBucketManagerTest;GrowthBookClientAsyncApiTest,GrowthBookClientStickyBucketConformanceTest,LettuceAsyncStickyBucketServiceTest.Restyling them is left for a follow-up.
Checklist
feat:/fix:drive the release version)AGENTS.md)--release 8on JDK 9+; the Java 8 matrix job is the backstop)CHANGELOG.md,versions.txt,Version.java,gradle.propertiesversion)libunchanged — or the change is deliberate and markedfeat!:/BREAKING CHANGE:lib(or explicitly approved); cache providers staycompileOnly