百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

f1

> 数据库
开源

一个用于在 Golang 中编写负载测试场景的工具,具有强大的命令行运行器

190 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个用于在 Golang 中编写负载测试场景的工具,具有强大的命令行运行器

f1

f1 is a flexible load testing framework using the go language for test scenarios. This allows test scenarios to be developed as code, utilising full development principles such as test driven development. Test scenarios with multiple stages and multiple modes are ideally suited to this environment.

At Form3, many of our test scenarios using this framework combine REST API calls with asynchronous notifications from message queues. To achieve this, we need to have a worker pool listening to messages on the queue and distribute them to the appropriate instance of an active test run. We use this with thousands of concurrent test iterations in tests covering millions of iterations and running for multiple days.

Usage

Writing load tests

Test scenarios consist of two stages:

  • Setup - represented by ScenarioFn which is called once at the start of a test; this may be useful for generating resources needed for all tests, or subscribing to message queues.
  • Run - represented by RunFn which is called for every iteration of the test, often in parallel with multiple goroutines.

Cleanup functions can be provided for both stages: Setup and Run which will be executed in LIFO order. These ScenarioFn and RunFn functions are defined as types in f1:

go
// ScenarioFn initialises a scenario and returns the iteration function (RunFn) to be invoked for every iteration
// of the tests.
type ScenarioFn func(t *T) RunFn

// RunFn performs a single iteration of the scenario. 't' may be used for asserting
// results or failing the scenario.
type RunFn func(t *T)

Writing tests is simply a case of implementing the types and registering them with f1:

…

Running load tests

Once you have written a load test and compiled a binary test runner, you can use the various "trigger modes" that f1 supports. These are available as subcommands to the run command, so try running f1 run --help for more information). The trigger modes currently implemented are as follows:

  • constant - applies load at a constant rate (e.g. one request per second, irrespective of request duration).
  • staged - applies load at various stages (e.g. one request per second for 10s, then two per second for 10s).
  • users - applies load from a pool of users (e.g. requests from two users being sent sequentially - they are as fast or as slow as the requests themselves).
  • gaussian - applies load based on a Gaussian distribution (e.g. varies load throughout a given duration with a mean and standard deviation).
  • ramp - applies load constantly increasing or decreasing an initial load during a given ramp duration (e.g. from 0/s requests to 100/s requests during 10s).
  • file - applies load based on a yaml config file - the file can contain any of the previous load modes (e.g. "config-file-example.yaml").

Output description

Currently, output from running f1 load tests looks like that:

[   1s]  ✔    20  ✘     0 (20/s)   avg: 72ns, min: 125ns, max: 27.590042ms

It provides the following information:

  • [ 1s] how long the test has been running for,
  • ✔ 20 number of successful iterations,
  • ✘ 0 number of failed iterations,
  • (20/s) (attempted) rate,
  • avg: 72ns, min: 125ns, max: 27.590042ms average, min and max iteration times.

Environment variables

Name Format Default Description
PROMETHEUS_PUSH_GATEWAY string - host:port or ip:port "" Configures the address of a Prometheus Push Gateway for exposing metrics. The prometheus job name configured will be f1-{scenario_name}. Disabled by default.
PROMETHEUS_NAMESPACE string "" Sets the metric label namespace to the specified value. Label is omitted if the value provided is empty.
PROMETHEUS_LABEL_ID string "" Sets the metric label id to the specified value. Label is omitted if the value provided is empty.
LOG_FILE_PATH string "" Specify the log file path used if --verbose is disabled. The logfile path will be an automatically generated temp file if not specified.
F1_LOG_LEVEL string "info" Specify the log level of the default logger, one of: debug, warn, error
F1_LOG_FORMAT string "" Specify the log format of the default logger, defaults to text formatter, allows json

Contributions

If you'd like to help improve f1, please fork this repo and raise a PR!

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogolangload-generatorload-testingperformance

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库