-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add ModeConfig interface with backward compatibility (1/4) #220
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
Closed
JasonXuDeveloper
wants to merge
6
commits into
Azure:main
from
JasonXuDeveloper:mode-config-interface
Closed
feat: add ModeConfig interface with backward compatibility (1/4) #220
JasonXuDeveloper
wants to merge
6
commits into
Azure:main
from
JasonXuDeveloper:mode-config-interface
Conversation
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
Add ModeConfig interface to enable self-configuring execution modes and provide backward compatibility for legacy LoadProfile format. ## Changes ### New files: - api/types/mode_config.go: ModeConfig interface and helpers - api/types/weighted_random_config.go: WeightedRandomConfig implementation - api/types/timeseries_config.go: TimeSeriesConfig implementation - Split test files for better organization ### Modified files: - api/types/load_traffic.go: - Add ExecutionMode type - Update LoadProfileSpec with Mode and ModeConfig fields - Add UnmarshalYAML/UnmarshalJSON for backward compatibility - Fix typo: RequestList.Selector (was "seletor") - Update Validate() method ## Features **ModeConfig Interface:** - Self-configuring modes declare their own overridable fields - Automatic CLI override extraction via BuildOverridesFromCLI() - Mode-specific validation and client configuration - Clean separation between mode logic and CLI tools **Backward Compatibility:** - Legacy format (rate/total/requests fields) auto-migrates to weighted-random mode - Both YAML and JSON unmarshaling supported - Existing load profiles continue to work without changes ## Testing All tests pass including: - Polymorphic deserialization tests - Backward compatibility tests for legacy format - CLI override extraction tests - Mode-specific configuration tests
Contributor
Author
|
@microsoft-github-policy-service agree [company="microsoft"] |
Contributor
Author
|
@microsoft-github-policy-service agree company="microsoft" |
This was referenced Dec 15, 2025
xinWeiWei24
reviewed
Dec 15, 2025
The interval field in TimeSeriesConfig is redundant since timing is already specified via StartTime in each RequestBucket. Removing it simplifies the configuration. ## Changes - Remove Interval field from TimeSeriesConfig struct - Update GetOverridableFields() to return empty array (no CLI overrides) - Update ApplyOverrides() to reject any override attempts - Update all tests to remove interval references - Update comment examples to remove interval mentions ## Benefits - Simpler configuration - Less redundant data - Timing is determined by bucket StartTime values
Update all code that previously accessed LoadProfileSpec fields directly (Rate, Total, Duration, Requests) to now access them via ModeConfig. ## Changes **request/schedule.go**: - Access rate, total, duration from WeightedRandomConfig **request/random.go**: - Access requests array from WeightedRandomConfig **cmd/kperf/commands/runner/runner.go**: - Access rate, total, duration from WeightedRandomConfig for CLI overrides **contrib/cmd/runkperf/commands/bench/utils.go**: - Access total, duration, requests from WeightedRandomConfig **contrib/cmd/runkperf/commands/warmup/command.go**: - Access total, rate from WeightedRandomConfig ## Validation All functions verify they're working with WeightedRandomConfig via type assertion, returning clear error messages if incorrect mode is used. The entire project now builds successfully with the new ModeConfig interface.
Contributor
Author
|
see #219 |
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.
Overview
Part 1 of 4 PRs implementing executor pattern architecture. See issue #219 for full context.
This PR establishes the foundation by adding the ModeConfig interface and splitting config types, with full backward compatibility for existing load profiles.
Changes
New files:
api/types/mode_config.go: ModeConfig interface and helpersapi/types/weighted_random_config.go: WeightedRandomConfig implementationapi/types/timeseries_config.go: TimeSeriesConfig implementationModified files:
api/types/load_traffic.go:Features
ModeConfig Interface:
BuildOverridesFromCLI()Backward Compatibility:
Testing
✅ All tests pass including:
Next PRs
Related to #219