Skip to content

Comments

feat(local-server-stress-tests): add support for dynamic generator weights#26324

Merged
anthony-murphy merged 4 commits intomicrosoft:mainfrom
anthony-murphy-agent:fix/dynamic-generator-weights
Feb 5, 2026
Merged

feat(local-server-stress-tests): add support for dynamic generator weights#26324
anthony-murphy merged 4 commits intomicrosoft:mainfrom
anthony-murphy-agent:fix/dynamic-generator-weights

Conversation

@anthony-murphy-agent
Copy link
Contributor

@anthony-murphy-agent anthony-murphy-agent commented Jan 29, 2026

Summary

  • Add dynamicWeightGenerator.ts with createWeightedAsyncGeneratorWithDynamicWeights
  • Enable generator weights to be functions that receive state and return a weight
  • This allows weights to vary based on the current test state

The standard createWeightedAsyncGenerator from stochastic-test-utils only supports static numeric weights. This enhancement enables dynamic weighting based on runtime conditions like container attach state.

Test plan

  • local-server-stress-tests pass
  • No breaking changes to existing behavior (weights can still be static numbers)

related to AB#8839

🤖 Generated with Claude Code

…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>
@anthony-murphy
Copy link
Contributor

/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

@anthony-murphy
Copy link
Contributor

/azp run Build - test-tools, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

Copilot AI left a 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.ts with support for both static and dynamic (function-based) weights
  • Updates baseModel.ts to 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

@anthony-murphy
Copy link
Contributor

/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 - test-tools

@anthony-murphy
Copy link
Contributor

/azp run repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

…ation

Simplify the dynamic weight generator by evaluating shouldAccept during
the cumulative sums calculation phase rather than using rejection sampling
after selection. This means cumulativeSums only contains valid entries,
eliminating the need for the do-while loop.

Co-Authored-By: anthony-murphy <anthony.murphy@microsoft.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@anthony-murphy
Copy link
Contributor

/azp run Build - client packages, Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build - test-tools

@anthony-murphy
Copy link
Contributor

/azp run Build site, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@anthony-murphy
Copy link
Contributor

/azp run Build site, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@anthony-murphy
Copy link
Contributor

/azp run Build - client packages, Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build - test-tools

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@anthony-murphy-agent
Copy link
Contributor Author

Azure Pipelines commands (copy and post separately, limit of 10 at a time):

/azp run Build - client packages, Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build - test-tools
/azp run Build site, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@anthony-murphy anthony-murphy merged commit 8b7ff27 into microsoft:main Feb 5, 2026
30 checks passed
anthony-murphy-agent added a commit to anthony-murphy-agent/FluidFramework that referenced this pull request Feb 6, 2026
Resolve merge conflicts in baseModel.ts and dynamicWeightGenerator.ts
after upstream changes from PR microsoft#26324 were merged to main. Preserved
the detached operation phasing logic from this PR while adopting the
updated acceptance condition filtering from upstream.

Co-Authored-By: anthony-murphy <anthony.murphy@microsoft.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
anthony-murphy added a commit that referenced this pull request Feb 6, 2026
…26325)

## Summary

Introduces operation phasing during the detached state before attach:

- **Creation phase** (first 7 ops): prioritizes `createDataStore` and
`createChannel` with high weights
- **DDS ops phase** (ops 8-20): prioritizes `DDSModelOp` operations with
increased weight

This ensures tests create sufficient data structure (datastores and
channels) before exercising DDS operations, providing better test
coverage.

## Dependencies

- Depends on #26324 (dynamic generator weights)

## Test plan

- [x] local-server-stress-tests pass
- [x] Verified phasing behavior produces expected operation distribution

related to
[AB#8839](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/8839)


🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: anthony-murphy-agent <anthony-murphy-agent@users.noreply.github.com>
Co-authored-by: anthony-murphy <anthony.murphy@microsoft.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: yann-achard-MS <97201204+yann-achard-MS@users.noreply.github.com>
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.

3 participants