{"id":13564530,"url":"https://github.com/rogerwelin/cassowary","last_synced_at":"2025-04-14T20:44:42.089Z","repository":{"id":37930536,"uuid":"204351794","full_name":"rogerwelin/cassowary","owner":"rogerwelin","description":":rocket: Modern cross-platform HTTP load-testing tool written in Go","archived":false,"fork":false,"pushed_at":"2025-03-25T19:22:53.000Z","size":214,"stargazers_count":786,"open_issues_count":6,"forks_count":35,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T18:05:11.637Z","etag":null,"topics":["cli","cross-platform","go","golang","http","linux","load-testing","macos","metrics","performance","testing","windows"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rogerwelin.png","metadata":{"files":{"readme":"README-ZH.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-25T21:28:34.000Z","updated_at":"2025-03-29T09:06:01.000Z","dependencies_parsed_at":"2024-01-08T16:09:25.949Z","dependency_job_id":"19988432-db00-4412-946b-61adffb11153","html_url":"https://github.com/rogerwelin/cassowary","commit_stats":{"total_commits":187,"total_committers":14,"mean_commits":"13.357142857142858","dds":"0.14438502673796794","last_synced_commit":"4c2c8324eb04a7849512942c4d26fb1778d91266"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerwelin%2Fcassowary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerwelin%2Fcassowary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerwelin%2Fcassowary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogerwelin%2Fcassowary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogerwelin","download_url":"https://codeload.github.com/rogerwelin/cassowary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248960288,"owners_count":21189981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cross-platform","go","golang","http","linux","load-testing","macos","metrics","performance","testing","windows"],"created_at":"2024-08-01T13:01:32.643Z","updated_at":"2025-04-14T20:44:42.079Z","avatar_url":"https://github.com/rogerwelin.png","language":"Go","funding_links":[],"categories":["Software Packages","软件包","Go","Go 工具","Go Tools","DevOps Tools"],"sub_categories":["DevOps Tools","DevOps 工具","devops 工具","代码分析"],"readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://github.com/rogerwelin/cassowary\"\u003e\u003cimg src=\"https://i.imgur.com/V9BaioC.png\" alt=\"cassowary\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://goreportcard.com/badge/github.com/rogerwelin/cassowary\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/rogerwelin/cassowary?style=for-the-badge\u0026logo=go\" alt=\"Go Report Card\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/rogerwelin/cassowary/actions/workflows/pullrequest.yaml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/rogerwelin/cassowary/pullrequest.yaml?branch=master\u0026style=for-the-badge\u0026logo=github\" alt=\"Build status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/avelino/awesome-go\"\u003e\u003cimg src=\"https://awesome.re/mentioned-badge.svg\" height=\"28\" alt=\"Mentioned in Awesome Go\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/rogerwelin/cassowary/blob/master/go.mod\"\u003e\u003cimg src=\"https://img.shields.io/github/go-mod/go-version/rogerwelin/cassowary?style=for-the-badge\u0026logo=go\" alt=\"Go version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/rogerwelin/cassowary/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/rogerwelin/cassowary?style=for-the-badge\u0026logo=github\u0026color=orange\" alt=\"Current Release\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://godoc.org/github.com/rogerwelin/cassowary\"\u003e\u003cimg src=\"https://godoc.org/github.com/rogerwelin/cassowary?status.svg\" height=\"28\" alt=\"godoc\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://gocover.io/github.com/rogerwelin/cassowary/pkg/client\"\u003e\u003cimg src=\"https://gocover.io/_badge/github.com/rogerwelin/cassowary/pkg/client\" height=\"28\" alt=\"Coverage\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/rogerwelin/cassowary/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/LICENSE-MIT-orange?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[English](README.md) | 中文\n\n**Cassowary** 是一个现代化的 HTTP/S 负载测试工具，采用 Go 语言开发，设计直观且跨平台，专为开发者、测试人员和系统管理员打造。Cassowary 受到 k6、ab 和 httpstat 等优秀项目的启发。\n\n---\n\n目录\n----\n\n- [功能特性](#功能特性)\n- [安装](#安装)\n- [运行 Cassowary](#运行-cassowary)\n  * [常规负载测试](#常规负载测试)\n  * [文件读取模式](#文件读取模式)\n  * [导出指标到文件](#导出指标到文件)\n  * [导出指标到 Prometheus](#导出指标到-prometheus)\n  * [导出指标到 Cloudwatch](#导出指标到-cloudwatch)\n  * [直方图](#直方图)\n  * [箱线图](#箱线图)\n  * [POST 数据负载测试](#post-数据负载测试)\n  * [指定测试持续时间](#指定测试持续时间)\n  * [添加 HTTP 头](#添加-http-头)\n  * [禁用 HTTP Keep-Alive](#禁用-http-keep-alive)\n  * [x509 认证](#x509-认证)\n  * [分布式负载测试](#分布式负载测试)\n- [将 Cassowary 导入为模块](#将-cassowary-导入为模块)\n- [版本控制](#版本控制)\n- [贡献](#贡献)\n\n功能特性  \n--------\n\n📌 **两种负载测试模式**：标准模式和扩展模式，扩展模式支持从文件中指定 URL 路径（适合测试多个底层微服务）  \n📌 **CI 友好**：非常适合集成到 CI 流水线中  \n📌 **灵活的指标输出**：支持 Cloudwatch 指标、Prometheus 指标（推送至 Prometheus PushGateway）以及 JSON 文件  \n📌 **高度可配置**：允许传入任意 HTTP 头，可自定义 HTTP 客户端配置  \n📌 **支持多种 HTTP 方法**：支持 GET、POST、PUT 和 PATCH，POST、PUT 和 PATCH 数据可通过文件定义  \n📌 **跨平台**：提供适用于 Linux、Mac OSX 和 Windows 的单一预编译二进制文件  \n📌 **可导入**：除了命令行工具外，Cassowary 还可作为模块导入到 Go 应用中  \n📌 **可视化支持**：Cassowary 可将请求数据导出为直方图和箱线图（PNG 格式）  \n\n\u003cimg src=\"https://imgur.com/ac8F8eD.gif\" /\u003e\n\n安装  \n--------\n\n从 [GitHub Releases 页面](https://github.com/rogerwelin/cassowary/releases) 下载预编译的二进制文件。你可以选择将 **cassowary** 二进制文件放入你的 `PATH` 中，以便在任意位置运行。或者，你也可以：\n\n### Homebrew（Mac OSX）  \n在 Mac 上使用 Homebrew 包管理器安装 **cassowary**：\n\n```bash\n$ brew update \u0026\u0026 brew install cassowary\n```\n\n### Docker  \n\n通过官方 Docker 镜像直接运行 **cassowary**：\n\n```bash\n$ docker run rogerw/cassowary:v0.14.1 -u http://www.example.com -c 1 -n 10\n```\n\n本地开发：\n\n```bash\n$ GOOS=linux go build -o dist/docker/cassowary cmd/cassowary/*.go\n$ docker build -f dist/docker/Dockerfile -t test_cassowary dist/docker\n$ docker run test_cassowary -u http://www.example.com -c 1 -n 10\n```\n\n若运行 `docker run` 时不带参数，将打印帮助信息。\n\n### ArchLinux/Manjaro\n\n从 [AUR](https://aur.archlinux.org/packages/cassowary-git) 安装 Cassowary 的开发版本：\n\n```bash\nyay -S cassowary-git\n```\n\n或手动构建和安装：\n\n```bash\ngit clone https://aur.archlinux.org/cassowary-git.git\ncd cassowary-git\nmakepkg -si\n```\n\n### Nix/NixOS\n\n通过 [Nix](https://nixos.org) 包管理器安装 Cassowary：\n\n```\nnix-env -iA cassowary\n```\n\n### CentOS/RHEL (RPM)\n\n若需自行构建 RPM 包，可使用 [cassowary.spec](https://github.com/rogerwelin/cassowary/blob/master/dist/rpm/cassowary.spec) 文件。\n\n运行 Cassowary  \n--------\n\n### 常规负载测试  \n示例：对 www.example.com 运行 **cassowary**，使用 10 个并发用户执行 100 个请求：\n\n```bash\n$ ./cassowary run -u http://www.example.com -c 10 -n 100\n\nStarting Load Test with 100 requests using 10 concurrent users\n\n 100% |████████████████████████████████████████| [1s:0s]            1.256773616s\n\n\n TCP Connect.....................: Avg/mean=101.90ms \tMedian=102.00ms\tp(95)=105ms\n Server Processing...............: Avg/mean=100.18ms \tMedian=100.50ms\tp(95)=103ms\n Content Transfer................: Avg/mean=0.01ms \tMedian=0.00ms\tp(95)=0ms\n\nSummary:\n Total Req.......................: 100\n Failed Req......................: 0\n DNS Lookup......................: 115.00ms\n Req/s...........................: 79.57\n```\n\n### 文件读取模式  \n示例：在文件读取模式下运行 **cassowary**，所有 URL 路径从外部文件指定（也可通过 HTTP 获取）。默认情况下，若未指定 `-n` 标志，Cassowary 将为文件中每个路径发起一次请求。使用 `-n` 标志可指定对这些 URL 路径的总请求数。示例：\n\n```bash\n$ ./cassowary run -u http://localhost:8000 -c 1 -f urlpath.txt\n\n# NOTE: from v0.10.0 and below file slurp mode had it's own command\n# $ ./cassowary run-file -u http://localhost:8000 -c 1 -f urlpath.txt\n\nStarting Load Test with 5 requests using 1 concurrent users\n\n[ omitted ]\n\n\n$ ./cassowary run -u http://localhost:8000 -c 10 -n 100 -f urlpath.txt\n\nStarting Load Test with 100 requests using 10 concurrent users\n\n 100% |████████████████████████████████████████| [0s:0s]            599.467161ms\n\n\n TCP Connect.....................: Avg/mean=1.80ms \tMedian=2.00ms\tp(95)=3ms\n Server Processing...............: Avg/mean=0.90ms \tMedian=0.00ms\tp(95)=3ms\n Content Transfer................: Avg/mean=0.00ms \tMedian=0.00ms\tp(95)=0ms\n\nSummary:\n Total Req.......................: 3925\n Failed Req......................: 0\n DNS Lookup......................: 2.00ms\n Req/s...........................: 6547.48\n```\n\n### 导出指标到文件  \n示例：将 **cassowary** 的 JSON 指标导出到文件：\n\n```bash\n$ ./cassowary run --json-metrics --json-metrics-file=metrics.json -u http://localhost:8000 -c 125 -n 100000\n\nStarting Load Test with 100000 requests using 125 concurrent users\n\n 100% |████████████████████████████████████████| [0s:0s]            984.9862ms\n\n\n TCP Connect.....................: Avg/mean=-0.18ms     Median=0.00ms   p(95)=1ms\n Server Processing...............: Avg/mean=0.16ms      Median=0.00ms   p(95)=1ms\n Content Transfer................: Avg/mean=0.01ms      Median=0.00ms   p(95)=0ms\n\nSummary:\n Total Req.......................: 100000\n Failed Req......................: 0\n DNS Lookup......................: 2.00ms\n Req/s...........................: 101524.27\n```\n\n\u003e 如果未指定 `json-metrics-file` 标志，默认文件名将为 `out.json`。\n\n若需所有请求的原始数据（CSV 格式），可使用 `--raw-output` 标志导出：\n\n\u003e 输出文件名将为 `raw.csv`。\n\n### 导出指标到 Prometheus  \n示例：通过指定 Prometheus PushGateway 的 URL，将 **cassowary** 指标导出到 Prometheus：\n\n```bash\n$ ./cassowary run -u http://localhost:8000 -c 125 -n 100000 -p http://pushgatway:9091\n\nStarting Load Test with 100000 requests using 125 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 导出指标到 Cloudwatch  \n**Cassowary** 可通过添加不带值的 `--cloudwatch` 标志将指标导出到 AWS Cloudwatch。请注意，你需要指定使用的 AWS 区域，最简单的方法是通过环境变量：\n\n```bash\n$ export AWS_REGION=eu-north-1 \u0026\u0026 ./cassowary run -u http://localhost:8000 -c 125 -n 100000 --cloudwatch\n\nStarting Load Test with 100000 requests using 125 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 直方图  \n通过添加不带值的 `--histogram` 标志，Cassowary 将生成请求总持续时间的直方图（PNG 格式，保存为当前目录下的 `hist.png`）。示例：\n\n\u003cimg src=\"https://i.imgur.com/VLEsVOY.png\" width=\"300\" height=\"300\" /\u003e\n\n### 箱线图  \n通过添加不带值的 `--boxplot` 标志，Cassowary 将生成请求总持续时间的箱线图（PNG 格式，保存为当前目录下的 `boxplot.png`）。\n\n### POST 数据负载测试  \n示例：对 POST 端点发起请求，POST 的 JSON 数据从文件中定义：\n\n```bash\n$ ./cassowary run -u http://localhost:8000/add-user -c 10 -n 1000 --postfile user.json\n\nStarting Load Test with 1000 requests using 10 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### PATCH 数据负载测试  \n示例：对 PATCH 端点发起请求，PATCH 的 JSON 数据从文件中定义：\n\n```bash\n$ ./cassowary run -u http://localhost:8000/add-user -c 5 -n 200 --patchfile user.json\n\nStarting Load Test with 200 requests using 5 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 指定测试持续时间  \n示例：为负载测试指定持续时间，以下命令将在 30 秒内发送 100 个请求：\n\n```bash\n$ ./cassowary run -u http://localhost:8000 -n 100 -d 30\n\nStarting Load Test with 100 requests using 1 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 添加 HTTP 头  \n示例：在运行 **cassowary** 时添加 HTTP 头：\n\n```bash\n$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 -H 'Host: www.example.com'\n\nStarting Load Test with 1000 requests using 10 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 禁用 HTTP Keep-Alive  \n示例：禁用 HTTP Keep-Alive（默认启用）：\n\n```bash\n$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 --disable-keep-alive\n\nStarting Load Test with 1000 requests using 10 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 指定 CA 证书  \n示例：指定 CA 证书：\n\n```bash\n$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 --ca /path/to/ca.pem\n\nStarting Load Test with 1000 requests using 10 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### x509 认证  \n示例：为 mTLS 指定客户端认证：\n\n```bash\n$ ./cassowary run -u https://localhost:8443 -c 10 -n 1000 --cert /path/to/client.pem --key /path/to/client-key.pem --ca /path/to/ca.pem\n\nStarting Load Test with 1000 requests using 10 concurrent users\n\n[ omitted for brevity ]\n\n```\n\n### 分布式负载测试  \n若需在多台机器上扩展负载测试，可通过分布式方式运行 Cassowary。最简单的方法是使用 Kubernetes 集群。使用 batch 类型，并通过 `spec.parallelism` 键指定同时运行的 Cassowary 实例数量：\n\n```yaml\napiVersion: batch/v1\nkind: Job\nmetadata:\n  name: cassowary\nspec:\n  parallelism: 10\n  template:\n    spec:\n      containers:\n      - command: [\"-u\", \"http://my-microservice.com:8000\", \"-c\", \"1\", \"-n\", \"10\"]\n        image: rogerw/cassowary:v0.14.1\n        name: cassowary\n      restartPolicy: Never\n```\n\n应用该 YAML 文件：\n\n```bash\n$ kubectl apply -f cassowary.yaml\n```\n\n将 Cassowary 导入为模块  \n--------\n\nCassowary 可作为模块导入到你的 Go 应用中。首先通过 go mod 获取依赖：\n\n```bash\n$ go mod init test \u0026\u0026 go get github.com/rogerwelin/cassowary/pkg/client\n```\n\n以下示例展示如何从代码中触发负载测试并打印结果：\n\n```go\npackage main\n\nimport (\n        \"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/rogerwelin/cassowary/pkg/client\"\n)\n\nfunc main() {\n\tcass := \u0026client.Cassowary{\n\t\tBaseURL:               \"http://www.example.com\",\n\t\tConcurrencyLevel:      1,\n\t\tRequests:              10,\n\t\tDisableTerminalOutput: true,\n\t}\n\tmetrics, err := cass.Coordinate()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n        // print results\n\tfmt.Printf(\"%+v\\n\", metrics)\n\n        // or print as json\n\tjsonMetrics, err := json.Marshal(metrics)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(string(jsonMetrics))\n}\n```\n\n更多模块示例 [可在此查看](docs/LIBRARY.md)。\n\n版本控制  \n--------\n\nCassowary 遵循语义化版本控制。公共库（pkg/client）在达到稳定 v1.0.0 版本之前，可能会破坏向后兼容性。\n\n贡献  \n--------\n\n欢迎贡献！如需请求新功能，请创建带有 `feature-request` 标签的问题。发现 bug？请创建带有 `bugs` 标签的问题。欢迎提交 Pull Request，但请先为请求的功能创建问题（除非是简单的 bug 修复或 README 修改）。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogerwelin%2Fcassowary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogerwelin%2Fcassowary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogerwelin%2Fcassowary/lists"}