test(client): add unit coverage for client utilities and services#19222
Merged
Conversation
…ss review findings - Fix two compile errors in TestHoodieTableServiceManagerClient: import HoodieTableType from common.model, and declare the checked UnsupportedEncodingException from URLDecoder.decode via throws IOException. - TABLE_SERVICE_MANAGER_DEPLOY_EXTRA_PARAMS now defaults to the empty string: its getter uses getStringOrDefault, which throws for no-default properties, so every compact/clean/cluster call through HoodieTableServiceManagerClient failed with HoodieException unless hoodie.table.service.manager.deploy.extra.params was explicitly set. - FileSystemBasedLockProvider.acquireLock writes the owner lock info unconditionally after the atomic create: the previous 'if (!storage.exists(lockFile))' guard ran right after create() and was always false, so lock files were empty and lock-conflict messages from LockManager and TimeGeneratorBase carried no owner info. - Consolidate filesystem lock provider tests in hudi-client-common: move the default-lock-path and non-reentrancy cases from hudi-spark-client's TestFileBasedLockProvider (which used no Spark) into TestFileSystemBasedLockProvider and delete the old file. - Test nits: drop an inert retry-wait property, import TypedProperties instead of inline qualification, use assertEquals over assertTrue(equals).
voonhous
marked this pull request as ready for review
July 20, 2026 14:00
voonhous
approved these changes
Jul 20, 2026
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.
Describe the issue this Pull Request addresses
hudi-client-commonclient utilities and services had thin unit coverage. This PR adds focused JUnit 5 tests for two client classes that are straightforward to exercise deterministically without a cluster: the DFS-based lock provider and the table service manager client. Writing the tests surfaced two production bugs, both fixed here.Summary and Changelog
Adds two new test suites:
TestFileSystemBasedLockProvider(org.apache.hudi.client.transaction.lock): exercisesFileSystemBasedLockProvideragainst a local temp directory. Covers acquire/release, contention between two providers over the same lock file (including reading the owner's lock info), expiry-based reclamation (the lock file's modification time is aged deterministically viaHoodieStorage.setModificationTime, no sleeps), the zero-expiry case that never reclaims, idempotent unlock, non-reentrancy of the same provider, the default lock path derived from the table base path, negative-expiry validation, and thegetLockConfighelper producing usable properties. This consolidates and replacesTestFileBasedLockProvider, which lived inhudi-spark-clientdespite using no Spark; its unique cases were moved here and the old file is deleted.TestHoodieTableServiceManagerClient(org.apache.hudi.client): mocks the HTTP transport with an in-processcom.sun.net.httpserver.HttpServer. Asserts the request path per action (compact / clean / cluster) and the query parameters sent (action, db_name, table_name, basepath, instant, execution_engine, parallelism), plus retry/error handling: a 500 response is retried and surfacesHoodieRemoteException, and an unreachable endpoint also surfacesHoodieRemoteException.Production fixes surfaced by the new tests:
HoodieTableServiceManagerConfig.TABLE_SERVICE_MANAGER_DEPLOY_EXTRA_PARAMShad no default value while its getter usesgetStringOrDefault, which throws for no-default properties. Since the getter runs on every compact/clean/cluster call, the table service manager client failed withHoodieExceptionunlesshoodie.table.service.manager.deploy.extra.paramswas explicitly set. The property now defaults to the empty string, matching the sibling deploy properties.FileSystemBasedLockProvider.acquireLocknever wrote the owner lock info: the dehadoop refactor ([HUDI-8092] Replace FileSystem and related classes to dehadoop hudi-client-common #11805) movedstorage.create(lockFile, false)in front of the pre-existingif (!exists)guard, turning the write into dead code, so lock files have been empty and the owner info embedded inLockManager/TimeGeneratorBaselock-conflict messages has been an empty string. The info is now written unconditionally after the atomic create (create with overwrite=false only succeeds for the file's creator), restoring the original behavior from [HUDI-5377] Write call stack information to lock file #7440.Impact
The table service manager client now works with default configuration instead of throwing on every call, and filesystem lock files again carry owner/call-stack info for debugging lock conflicts. No API changes.
Risk Level
low
Tests use local filesystem temp directories and an in-process HTTP server on an ephemeral port. No cluster, no external services, and no
Thread.sleep-based timing; lock expiry is simulated by setting the lock file modification time. The production changes are a config default and restoring a write guarded by an atomic create.Documentation Update
hoodie.table.service.manager.deploy.extra.paramsnow documents a default of empty string on the generated config page.Contributor's checklist