-
Notifications
You must be signed in to change notification settings - Fork 562
feat(local-server-stress-tests): add support for dynamic generator weights #26324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(local-server-stress-tests): add support for dynamic generator weights #26324
Conversation
…ights Enable generator weights to be functions that receive state and return a weight, instead of only supporting static numeric weights. This allows weights to vary based on the current test state. Co-Authored-By: anthony-murphy <anthony.murphy@microsoft.com> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Azure Pipelines commands (copy and post separately, limit of 10 at a time): |
|
/azp run Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - client packages, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build site |
|
/azp run Build - test-tools, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious |
|
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds infrastructure for dynamic weight functions in weighted random generators for the local-server-stress-tests package. Currently, the stochastic-test-utils library only supports static numeric weights, but this enhancement enables weights that can be computed dynamically based on runtime test state.
Changes:
- Introduces
dynamicWeightGenerator.tswith support for both static and dynamic (function-based) weights - Updates
baseModel.tsto use the new dynamic weight generator instead of the static one from stochastic-test-utils - Maintains full backward compatibility - existing code with static weights continues to work
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/test/local-server-stress-tests/src/dynamicWeightGenerator.ts |
New module implementing createWeightedAsyncGeneratorWithDynamicWeights, a variant of the stochastic-test-utils function that evaluates weight functions dynamically at runtime |
packages/test/local-server-stress-tests/src/baseModel.ts |
Updated to use the new dynamic weight generator, with type changes from AsyncWeights to DynamicAsyncWeights |
| * evaluated at runtime with the current state. | ||
| * | ||
| * @param weights - Array of [generator, weight, acceptanceCondition?] tuples where | ||
| * weight can be a number or a function (state) =\> number |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arrow in the JSDoc comment is escaped with a backslash. Remove the backslash so it renders correctly as (state) => number instead of (state) =\> number.
| * weight can be a number or a function (state) =\> number | |
| * weight can be a number or a function (state) => number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! However, the backslash escape is actually required here. The project uses TSDoc and has an ESLint rule (tsdoc/syntax) that requires the > character to be escaped to avoid confusion with HTML tags. If I remove the backslash, the build fails with:
tsdoc-escape-greater-than: The ">" character should be escaped using a backslash to avoid confusion with an HTML tag
So the escaped version =\> is correct for TSDoc, even though it may look slightly odd in the rendered documentation.
Summary
dynamicWeightGenerator.tswithcreateWeightedAsyncGeneratorWithDynamicWeightsThe standard
createWeightedAsyncGeneratorfrom stochastic-test-utils only supports static numeric weights. This enhancement enables dynamic weighting based on runtime conditions like container attach state.Test plan
🤖 Generated with Claude Code