Skip to content

v3#334

Draft
nvloff-f3 wants to merge 29 commits intomasterfrom
nvloff-v3
Draft

v3#334
nvloff-f3 wants to merge 29 commits intomasterfrom
nvloff-v3

Conversation

@nvloff-f3
Copy link
Copy Markdown
Contributor

No description provided.

nvloff-f3 added 29 commits March 9, 2026 10:39
Remove deprecated Fluentd support:
- FLUENTD_HOST and FLUENTD_PORT env vars from envsettings
- Fluentd struct and Settings.Fluentd field
- Warning when Fluentd env vars were set
Drop PNG chart export and rely on ASCII chart output only.
- Remove go-chart usage from chart command
- Remove --filename flag
- Run go mod tidy to clean up transitive deps
Delete the chart command and its package, which depended on these
libraries.
Replace logrus with slog for logging. Remove WithLogrusLogger and
rename StandardLogger to Logger, which now returns *slog.Logger.

BREAKING CHANGE: Logger() now returns *slog.Logger instead of
*logrus.Logger. WithLogrusLogger() has been removed. Use
WithLogger(*slog.Logger) instead.
BREAKING CHANGE: remove pkg/f1/metrics package and GetMetrics() function.
The internal metrics API is no longer exposed as a public API.
Use WithStaticMetrics for metric label configuration instead.
BREAKING CHANGE: remove T.Time method and all metrics references from
pkg/f1/testing. The testing package no longer depends on internal metrics.
Setup and iteration timings are still recorded by the framework.
BREAKING CHANGE: remove deprecated testing.NewT. Use NewTWithOptions instead.
BREAKING CHANGE: rename testing package to f1testing to avoid conflict
with stdlib. Update imports from github.com/form3tech-oss/f1/v2/pkg/f1/testing
to github.com/form3tech-oss/f1/v2/pkg/f1/f1testing.
BREAKING CHANGE: remove --verbose-fail flag. The option was deprecated
and no longer had any effect.
- Add grouped flag sections in run command help (Output, Duration & limits,
  Concurrency, Failure handling, Shutdown, Trigger options)
- Standardize help text and examples across triggers
- Document short-flag meanings per trigger (Long field on api.Builder)
- Simplify help implementation by delegating to pflag FlagUsages()

BREAKING CHANGE: Renamed flags for consistency:
- staged/gaussian: iterationFrequency → iteration-frequency
- root: cpuprofile → cpu-profile, memprofile → mem-profile
Update module path and imports from github.com/form3tech-oss/f1/v2 to
github.com/form3tech-oss/f1/v3. Update README examples to use f1testing.

BREAKING CHANGE: Module path changed from github.com/form3tech-oss/f1/v2
to github.com/form3tech-oss/f1/v3. Update imports accordingly.
BREAKING CHANGE: ScenarioFn and RunFn now take context.Context as the first
parameter. Update all scenario functions to use:
  ScenarioFn func(ctx context.Context, t *T) RunFn
  RunFn func(ctx context.Context, t *T)

Context is cancelled when the run is interrupted (SIGINT/SIGTERM), times out,
or reaches max iterations. Pass it to context-aware operations or check
ctx.Done() to abort long-running work.
- Replace ExecuteWithArgs with Run(ctx context.Context, args []string)
- newSignalContext accepts parent context for inheritance
- Pass execCtx through buildRootCmd to run.Cmd for contextcheck
- Use context.TODO() in tests
Replace F1.Add and Scenarios.Add with AddScenario for clarity.
Remove deprecated Add methods.

BREAKING CHANGE: Add has been removed. Use AddScenario instead.
Replace options.Apply(...) with NewRun(scenarios, trigger, ...,
opts ...RunOption). Matches f1.New pattern and removes
the extra Apply indirection.

BREAKING CHANGE: NewRun signature changed from
(options.RunOptions, scenarios, trigger, ...) to
(scenarios, trigger, ..., opts ...RunOption).
Remove options.Apply() from call sites.
Change Error and Fatal to accept args ...any instead of err error,
matching testing.T and allowing shared test helpers between f1
scenarios and standard go tests.

- Error, Errorf, Fatal, Fatalf log at ERROR level (not via Log/Logf)
- Log/Logf use fmt.Sprintln for formatting (aligned with testing.T)
- Log/Logf add iteration and vuid context to all output
- Add commonTInterface for compile-time signature verification
- Add tests for exact logging format (level, msg, iteration, vuid)

Based on #286 by @sirockin

BREAKING CHANGE: Error(err error) and Fatal(err error) are now
Error(args ...any) and Fatal(args ...any). Single-error call sites
remain valid: Error(err) and Fatal(err) still compile and behave
as before.

Closes #278
Closes #286
Comprehensive migration guide covering all breaking changes:
module path (v2→v3), imports (testing→f1testing), Run API
(ExecuteWithArgs→Run), functional options for New, AddScenario,
context in ScenarioFn/RunFn, T changes (Error/Fatal, Logger,
T.Time, NewT), metrics removal, CLI flags, and removed features
(chart, Fluentd, Logrus). Includes before/after examples and
migration checklist.
BREAKING CHANGE: T.Iteration is now uint64 instead of string. Use
f1testing.IterationSetup (0) for the setup phase; run iterations are
1-based. This removes string allocation on every iteration.
- Use cmd.OutOrStdout() instead of os.Stdout for testability
- Add Short and Long help text for ls subcommand
- Remove redundant sort (GetScenarioNames already returns sorted)
- WithDescription sets Scenario.Description
- WithParameter appends to Scenario.Parameters
- AddScenario + GetScenario behavior
- GetScenarioNames returns sorted names
- Build Scenarios via exported APIs, run ls via Cobra
- Assert output is newline-delimited and sorted
- Assert ls Short and Long help are non-empty
Add functional options that let callers configure Prometheus and logging
settings without relying on environment variables. New options:

  WithPrometheusPushGateway, WithPrometheusNamespace, WithPrometheusLabelID
  WithLogFilePath, WithLogLevel, WithLogFormat
  WithoutEnvSettings

Precedence: programmatic options > env vars > defaults.
WithLogger takes precedence over log level/format options.

Construction order in New():
  1. Load settings from environment variables
  2. Apply options (overrides or WithoutEnvSettings)
  3. Build default output from final settings unless WithLogger was used

Default behavior (no new options) is unchanged.

Tests cover: env vars used by default, programmatic push gateway
override, log level/format application, WithLogger precedence over
log options, and WithoutEnvSettings ignoring env vars.
Add "Programmatic configuration" section to README covering:
- Table mapping each env var to its programmatic Option equivalent
- WithoutEnvSettings for ignoring all env vars
- Precedence order: programmatic options > env vars > defaults
- Note that WithLogger disables log level/format options
- Usage examples for overrides, WithoutEnvSettings, and WithLogger
Introduce public Settings types (Settings, PrometheusSettings,
LoggingSettings, LogFormat) for strongly-typed configuration without
string-key APIs. All options consolidated in options.go; types in
settings.go.

Key changes:
- WithSettings(Settings) replaces WithoutEnvSettings; pass Settings{}
  to ignore all env vars
- WithLogLevel(slog.Level) and WithLogFormat(LogFormat) replace
  string-based equivalents for compile-time safety
- DefaultSettings() loads from env vars (backward-compat baseline)
- Fix concurrent map write in cobra template func registration
  (sync.Once in help.go)

Design decisions (justified in CODEBASE_REVIEW.md):
- No Config struct: bundles unrelated concerns (Settings+Logger+Metrics)
- No SettingsProvider: lazy evaluation adds no benefit since New()
  consumes settings immediately
- Public types convert to internal envsettings.Settings at execution
  boundary, avoiding import cycles

Precedence unchanged: programmatic options > env vars > defaults.
WithLogger takes precedence over logging settings.

Default behavior (no new options) is unchanged.
Restructure configuration tests to eliminate env-mutation from
options_test.go:

- Move TestEnvVarsUsedByDefault to f1_test.go (already exempted from
  paralleltest for signal testing)
- Remove env-mutation tests now redundant with WithSettings-based tests
- All options_test.go tests now call t.Parallel
- Remove golangci.yml paralleltest exclusion for options_test.go

Add precedence assertion tests:
- TestWithSettingsOverridesFinegrained: WithSettings placed last wins
- TestWithLoggerTakesPrecedenceOverWithSettings: WithLogger overrides
  Settings logging config
- TestWithSettingsAllFields: all Settings fields flow through correctly
- TestWithSettingsEmptyDisablesAllSettings: zero-value baseline
Merge README "Environment variables" and "Programmatic configuration"
into a single "Configuration" section covering:

- Settings reference table mapping env vars to typed programmatic options
- How to configure without env vars (WithSettings)
- Full Settings struct example
- Precedence order: programmatic > env vars > defaults
- WithLogger interaction (disables log level/format settings)
- Default env-backed behaviour for backward compatibility
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.

1 participant