Skip to content

Test poller target halves on ResourceExhausted#2392

Open
veeral-patel wants to merge 1 commit into
mainfrom
veeral/poller-autoscaling-halving-test
Open

Test poller target halves on ResourceExhausted#2392
veeral-patel wants to merge 1 commit into
mainfrom
veeral/poller-autoscaling-halving-test

Conversation

@veeral-patel

Copy link
Copy Markdown

What

Adds TestAutoscalingHalvesOnResourceExhausted to ScalableTaskPollerSuite in internal/internal_worker_base_test.go.

The test drives pollScalerReportHandle.handleError (built through the production newScalableTaskPoller wiring) and asserts the live pollerSemaphore max permits follow the halving sequence:

Error Target maxPermits
ResourceExhausted 16 → 8 8
ResourceExhausted 8 → 4 4
other (Internal) 4 → 3 3
ResourceExhausted 3 → 1 1 (clamped at min)
ResourceExhausted 1 → 1 1

Why

Asserting the exact step size — 16→8→4 for ResourceExhausted versus 4→3 for a non-ResourceExhausted error — is what distinguishes halving (t/2) from a plain -1 decrement. A regression in either direction (RE stops halving, or halving leaks to other error types) fails the test.

This complements the existing PollScalerReportHandleSuite.TestErrorScaleDown, which asserts the same arithmetic against a mock scaleCallback. The new test additionally verifies the halved value reaches the real pollerSemaphore through the scaleCallback → updatePermits wiring that newScalableTaskPoller sets up.

Notes

  • Deterministic and fast; no Temporal server required.
  • Reuses the suite's existing semaphoreProbeTaskPoller and readSemaphoreState helpers; no production code changes.

Test

go test ./internal/ -run 'TestScalableTaskPollerSuite/TestAutoscalingHalvesOnResourceExhausted' -count=1

Add TestAutoscalingHalvesOnResourceExhausted to ScalableTaskPollerSuite,
asserting that a ResourceExhausted poll error halves the poller target
(16 -> 8 -> 4) while other errors only decrement by one, and that the
halved value reaches the live pollerSemaphore via the scaleCallback
wiring set up by newScalableTaskPoller.

This complements TestErrorScaleDown (which asserts the same arithmetic
against a mock scaleCallback) by verifying the real semaphore is resized.
@veeral-patel veeral-patel requested a review from a team as a code owner June 8, 2026 21:22

@yuandrew yuandrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like go run . check is failing

serverSupportsAutoscaling := &atomic.Bool{}
serverSupportsAutoscaling.Store(true)

poller := newScalableTaskPoller(&semaphoreProbeTaskPoller{}, ilog.NewNopLogger(), behavior, serverSupportsAutoscaling)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use newSemaphoreProbeTaskPoller here? All of the other tests use this helper to create the poller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants