Skip to content

Conversation

@JasonXuDeveloper
Copy link
Contributor

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 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

Next PRs

  • PR 2/4: Executor pattern implementation (depends on this PR)
  • PR 3/4: Mode-agnostic CLI tools (depends on PR 2)
  • PR 4/4: Time-series benchmark example (depends on PR 3)

Related to #219

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
@JasonXuDeveloper
Copy link
Contributor Author

@microsoft-github-policy-service agree [company="microsoft"]

@JasonXuDeveloper
Copy link
Contributor Author

@microsoft-github-policy-service agree company="microsoft"

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.
@JasonXuDeveloper
Copy link
Contributor Author

see #219

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