test(batching): added more test coverage to check update transaction optimisations#353
Draft
krutibaraiya wants to merge 14 commits intomainfrom
Draft
test(batching): added more test coverage to check update transaction optimisations#353krutibaraiya wants to merge 14 commits intomainfrom
krutibaraiya wants to merge 14 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds test coverage around agentless batching and Consul transaction retry behavior to validate recent update-transaction optimizations and edge cases.
Changes:
- Added a large integration-style test suite covering batched txn execution and retry paths (stale index, missing checks, nil client, etc.).
- Added unit tests for
CheckUpdateBatcherflush behavior (timer flush, max-size flush, deduplication, stop behavior, concurrency). - Removed older “concept/demo” batching tests from
agentless_optimization_test.go.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
check_transaction_integration_test.go |
New integration tests exercising batched transactions and retry/revert edge cases. |
batcher_test.go |
New unit tests for batcher flushing/dedup/Stop and concurrent Add behavior. |
agentless_optimization_test.go |
Removes placeholder batching tests, keeping focused optimization/state tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
e2cc323 to
e8587d3
Compare
b9d6560 to
dbc2e47
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.
Test cases added
batcher_test.go — 7 tests
TestBatcher_TimerFlushTestBatcher_MaxBatchSizeFlushmaxBatchSizebefore the timerTestBatcher_StopFlushesStop()drains and processes all pending updates before shutting downTestBatcher_DeduplicationInQueueTestBatcher_AddAfterStopAdd()on a stopped batcher does not panicTestBatcher_ConcurrentAddsAdd()calls from multiple goroutines don't race or corrupt stateTestFlushLocked_ProcessFuncNilflushLocked()is a no-op and doesn't panic whenprocessFuncis nilagentless_optimization_test.go — 4 tests
TestCheckRunner_AgentlessOptimizationsbatcher=nil; agentless runner hasbatcherinitialised andisAgentless=trueTestCheckRunner_MaxBatchSizemaxTxnOpsconstant is 64 (Consul's transaction limit)TestCheckRunner_StateReversionrevertCheckState()correctly rolls back local check state; handles missing checks gracefully; enables natural retry by diverging local vs actual stateTestCheckRunner_OriginalStateInBatcherbatcher.Add()storesoldStatus/oldOutputalongside the new status so rollback is possible on failurecheck_transaction_integration_test.go — 22 tests (against a live Consul test server)
TestExecuteBatchTransaction_SuccessTestExecuteBatchTransaction_StaleIndexModifyIndex, triggering retry which succeedsTestExecuteBatchTransaction_NetworkErrorTestExecuteBatchTransaction_NonStaleErrorsTestExecuteBatchTransaction_EmptyOpsTestProcessBatchedUpdates_NilClientclient=nilreturns early without panicTestProcessBatchedUpdates_EmptyUpdatesTestProcessBatchedUpdates_NodeFetchErrorTestProcessBatchedUpdates_CheckNoLongerExistsTestRevertCheckState_MissingCheckrevertCheckState()with a check not in the local store — no panicTestHashCheck_WithoutServiceIDnode/checkIDTestHashCheck_WithServiceIDnode/serviceID/checkIDTestBatcher_NewCheckUpdateBatcher_ZeroMaxSizeMaxBatchSizein config falls back to themaxTxnOpsdefaultTestRetryFailedBatchOperations_CheckDeletedTestRetryFailedBatchOperations_InvalidIndexOpIndexout of bounds — handled without panicTestRetryFailedBatchOperations_NodeFetchErrorTestRetryFailedBatchOperations_RetryFailsrevertCheckStateTestRetryFailedBatchOperations_SuccessfulRetryTestRetryFailedBatchOperations_EmptyErrorsTxnErrorsslice passed to retry — returns immediatelyTestRetryFailedBatchOperations_CheckDeletedDuringRetryTestRetryFailedBatchOperations_RetryTransactionErrorTestHandleCheckUpdate_AgentfulModeisAgentless=false) takes thehandleCheckUpdateImmediatepath instead of batchingPCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.