test(azure): concurrency timing test for parallel dispatcher (closes #262)#873
test(azure): concurrency timing test for parallel dispatcher (closes #262)#873cristim wants to merge 2 commits into
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review Generated by Claude Code |
|
🧠 Learnings used✅ Action performedFull review finished. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…er (closes #262) Introduce four package-level newXxxClientFn vars (defaulting to the real compute/database/cache/cosmosdb constructors) so tests can inject fake clients without changing production behaviour. Add three tests in recommendations_test.go: - TestGetRecommendations_Parallelism: 4 fakes sleep 100ms each; asserts wall-clock < 200ms, proving concurrent dispatch (serial would be ~400ms). - TestGetRecommendations_OrderPreservation: staggered sleeps force out-of-order completion; asserts merged slice is compute->db->cache->cosmos. - TestGetRecommendations_ErrorIsolation: one fake errors; asserts the other three services still contribute recs (no sibling cancellation).
…etic TestGetRecommendations_Parallelism was failing (~300-700ms wall clock vs 200ms threshold) because the savingsplans and advisor goroutines used real constructors that made ARM network calls, adding unbounded latency outside the four fakeServiceClient mocks. Add newSavingsPlansClientFn package-level var (parallel to the other four) and a getAdvisorRecsFn field on RecommendationsClientAdapter (defaulting to r.getAdvisorRecommendations, with a nil guard for struct-literal adapters in existing tests). Wire newSavingsPlansClientFn in GetRecommendations to replace the direct savingsplans.NewClient call. In the three concurrency tests (Parallelism, OrderPreservation, ErrorIsolation) inject noopAdvisorFn and a zero-sleep fakeServiceClient for savingsplans so all latency comes exclusively from the four injectable mocks. Tests are now fully hermetic: no real ARM calls, deterministic rec count, pass consistently under -race. 699 azure provider tests pass; 0 lint issues in touched files.
Summary
serviceRecsGetterinterface + 4newXxxClientFnpackage-level vars inrecommendations.go(defaults to real constructors; no behaviour change)recommendations_test.go: parallelism timing proof, order preservation, error isolationChanges
providers/azure/recommendations.go— DI seam only:serviceRecsGetterinterface (GetRecommendations(ctx, params) ([]Recommendation, error))newComputeClientFn,newDatabaseClientFn,newCacheClientFn,newCosmosDBClientFnvars wrapping the real constructorsGetRecommendationscallsnewXxxClientFn(...)instead ofxxx.NewClient(...)directlyproviders/azure/recommendations_test.go— three tests:TestGetRecommendations_Parallelism: 4 fakes × 100ms sleep; asserts elapsed < 200ms (vs ~400ms serial)TestGetRecommendations_OrderPreservation: staggered sleeps (10–40ms) complete out-of-order; asserts merged slice is compute→db→cache→cosmosdbTestGetRecommendations_ErrorIsolation: database fake returns error; asserts other 3 services' recs still presentTest plan
go build ./providers/azure/...cleango test github.com/LeanerCloud/CUDly/providers/azure/...— 663 passed, 14 packages