Add TestInstanceOperationMisc with independent tests#154
Open
proud-parselmouth wants to merge 3 commits into
Open
Add TestInstanceOperationMisc with independent tests#154proud-parselmouth wants to merge 3 commits into
proud-parselmouth wants to merge 3 commits into
Conversation
ngngwr
reviewed
Mar 30, 2026
| _gSetupTool.getClusterManagementTool().setInstanceOperation(CLUSTER_NAME, | ||
| evacuateInstanceName, InstanceConstants.InstanceOperation.EVACUATE); | ||
|
|
||
| verifier(() -> { |
Collaborator
There was a problem hiding this comment.
I think this entire thing is essentially validateAssignmentInEv() in the TestInstanceOperationBase. You can directly use that.
Collaborator
Author
There was a problem hiding this comment.
Abstracted out the acceptable state set check and top state set check, and added validateAssignmentInEv below
ngngwr
reviewed
Mar 30, 2026
| ExternalView ev = assignment.get(resource); | ||
| for (String partition : ev.getPartitionSet()) { | ||
| AtomicInteger activeReplicaCount = new AtomicInteger(); | ||
| ev.getStateMap(partition).values().stream().filter( |
Collaborator
There was a problem hiding this comment.
These states varies from the acceptable states mentioned in testEvacuationWithOfflineInstancesInCluster
ngngwr
previously approved these changes
Apr 10, 2026
Collaborator
ngngwr
left a comment
There was a problem hiding this comment.
LGTM. Thanks for addressing the comments
19b1e52 to
deb4797
Compare
Base automatically changed from
anubagar/TestInstanceOperationEvacuationCancel
to
dev
April 16, 2026 11:56
Extract 6 miscellaneous tests from TestInstanceOperation into TestInstanceOperationMisc extending TestInstanceOperationBase: - testUnsetInstanceOperationOnSwapInWhenSwapping (expects HelixException) - testNodeSwapAddSwapInFirst (add SWAP_IN instance first) - testSwapEvacuateAddRemoveEvacuate (expects HelixException) - testUnknownDoesNotTriggerRebalance (UNKNOWN instances cause no rebalance) - testEvacuationWithOfflineInstancesInCluster (evacuate with 2 offline nodes) - testEvacuateWithDisabledPartition (disable then evacuate, verify no upward state transitions) All tests run independently with no dependsOnMethods chains. Tests call enabledTopologyAwareRebalance() explicitly. testEvacuateWithDisabledPartition adds test resources to _allDBs for proper @BeforeMethod cleanup. TestInstanceOperation is not modified. Made-with: Cursor
Replace inline hardcoded state filters with ACCEPTABLE_STATE_SET and TOP_STATE_SET from TestInstanceOperationBase. Add validateAssignmentInEv call after verifier for consistent assertion pattern. Remove stray FOLLOWER state that was not in ACCEPTABLE_STATE_SET. Made-with: Cursor
e3e2481 to
b228258
Compare
The default test DBs in TestInstanceOperationBase use LeaderStandby (top state = LEADER), but TOP_STATE_SET only contained MASTER. This made the evacuating-instance top-state check in TestInstanceOperationMisc.testEvacuationWithOfflineInstancesInCluster silently always pass, weakening the assertion compared to the original check (which used MASTER || LEADER) it was meant to replace. Aligns TOP_STATE_SET with ACCEPTABLE_STATE_SET, which already covers both MasterSlave and LeaderStandby state models. Made-with: Cursor
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.
Issues
This PR is part of the TestInstanceOperation dependency chain reduction effort. See TestInstanceOperation Dependency Chain Reduction for full analysis. Depends on #153
Description
What: Extracts 6 miscellaneous tests from the monolithic
TestInstanceOperationinto a new independent test classTestInstanceOperationMisc, extendingTestInstanceOperationBase.How:
TestInstanceOperationMisc.javawith 6 tests extracted fromTestInstanceOperation:testUnsetInstanceOperationOnSwapInWhenSwapping— expectsHelixExceptionwhen trying to ENABLE a SWAP_IN instance while the original instance with the same logicalId is still activetestNodeSwapAddSwapInFirst— add a SWAP_IN instance before any swap-out is set, verify the cluster convergestestSwapEvacuateAddRemoveEvacuate— expectsHelixExceptionwhen removing EVACUATE while an ENABLE instance with the same logicalId existstestUnknownDoesNotTriggerRebalance— add UNKNOWN instances (both new zone and same logicalId as existing node), verify no IdealState changestestEvacuationWithOfflineInstancesInCluster— evacuate an instance while 2 other instances are offline, verify min active replicas maintained and evacuating instance leaves top statetestEvacuateWithDisabledPartition— disable all partitions on an instance then evacuate, verify no upward state transitions occur; re-enable and re-disable partitions, verify no spurious transitionsenabledTopologyAwareRebalance()at its start to be fully self-contained (the base class@BeforeMethoddisables it by default).dependsOnMethodschains — every test runs independently.testEvacuateWithDisabledPartition, test resources are added to_allDBsfor proper@BeforeMethodcleanup, and a customStateTransitionCountStateModelFactoryparticipant is stopped at end to ensure clean teardown.removeOfflineOrInactiveInstances,dropTestDBs) removed from individual tests since@BeforeMethodhandles full isolation reset.TestInstanceOperation.javais not modified in this PR.Tests
TestInstanceOperationMisc.testUnsetInstanceOperationOnSwapInWhenSwappingTestInstanceOperationMisc.testNodeSwapAddSwapInFirstTestInstanceOperationMisc.testSwapEvacuateAddRemoveEvacuateTestInstanceOperationMisc.testUnknownDoesNotTriggerRebalanceTestInstanceOperationMisc.testEvacuationWithOfflineInstancesInClusterTestInstanceOperationMisc.testEvacuateWithDisabledPartitionmvn testcommand on the appropriate module:(If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
Changes that Break Backward Compatibility (Optional)
(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
Documentation (Optional)
(Link the GitHub wiki you added)
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)