Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rogerwelin/cassowary
:rocket: Modern cross-platform HTTP load-testing tool written in Go
https://github.com/rogerwelin/cassowary
cli cross-platform go golang http linux load-testing macos metrics performance testing windows
Last synced: 5 days ago
JSON representation
:rocket: Modern cross-platform HTTP load-testing tool written in Go
- Host: GitHub
- URL: https://github.com/rogerwelin/cassowary
- Owner: rogerwelin
- License: mit
- Created: 2019-08-25T21:28:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T07:44:00.000Z (3 months ago)
- Last Synced: 2024-12-01T14:00:07.922Z (12 days ago)
- Topics: cli, cross-platform, go, golang, http, linux, load-testing, macos, metrics, performance, testing, windows
- Language: Go
- Homepage:
- Size: 184 KB
- Stars: 774
- Watchers: 6
- Forks: 35
- Open Issues: 8
-
Metadata Files:
- Readme: README-ZH.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ccamel - rogerwelin/cassowary - :rocket: Modern cross-platform HTTP load-testing tool written in Go (Go)
- awesome-go-extra - cassowary - platform HTTP load-testing tool written in Go|607|24|7|2019-08-25T21:28:34Z|2022-07-19T15:13:17Z| (Go Tools / DevOps Tools)
README
**Cassowary** 是一个最新的跨平台HTTP/S负载测试工。我使用了Go编辑Cassowary,希望Developer, tester 以及sysadmins都可以便捷的进行负载测试。Cassowary受到了很多经典的开源项目的启发,比如k6, ab和httestat。
---
目录
----
- [功能](#功能)
- [安装](#安装)
- [使用](#使用)
- [反馈](#反馈)功能
--------
- 两种测试模式:标准和自定义。在自定义模式下可以选择URL路径
- CI友好
- 灵活的算法: 可以向Prometheus PushGateway直接发送算法,也可以以JSON文件的形式发送算法
- 灵活调节:可以自由选择使用哪种HTTP头字段
- 跨平台: 一个二进制文件可同时支持Linux,Mac OSX和Windows安装
--------从GitHub Releases page下载二进制文件。可以选择把Cassowary二进制文件放在PATH里,这样在任何页面写都可以运行Cassowary。
### Nix/NixOS
Cassowary可以安装在Nix OS上。
使用
--------示例:10个用户同时向www.example.com 发送100个访问
```bash
$ ./cassowary run -u http://www.example.com -c 10 -n 100Starting Load Test with 100 requests using 10 concurrent users
100% |████████████████████████████████████████| [1s:0s] 1.256773616s
TCP Connect.....................: Avg/mean=101.90ms Median=102.00ms p(95)=105ms
Server Processing...............: Avg/mean=100.18ms Median=100.50ms p(95)=103ms
Content Transfer................: Avg/mean=0.01ms Median=0.00ms p(95)=0msSummary:
Total Req.......................: 100
Failed Req......................: 0
DNS Lookup......................: 115.00ms
Req/s...........................: 79.57
```示例:访问外部文件指定的URL路径(外部文件也可以是http路径的)
```bash
$ ./cassowary run -u http://localhost:8000 -c 10 -f urlpath.txtStarting Load Test with 3925 requests using 10 concurrent users
100% |████████████████████████████████████████| [0s:0s] 599.467161ms
TCP Connect.....................: Avg/mean=1.80ms Median=2.00ms p(95)=3ms
Server Processing...............: Avg/mean=0.90ms Median=0.00ms p(95)=3ms
Content Transfer................: Avg/mean=0.00ms Median=0.00ms p(95)=0msSummary:
Total Req.......................: 3925
Failed Req......................: 0
DNS Lookup......................: 2.00ms
Req/s...........................: 6547.48
```示例:导出Cassowary的Json算法
```bash
$ ./cassowary run --json-metrics --json-metrics-file=metrics.json -u http://localhost:8000 -c 125 -n 100000Starting Load Test with 100000 requests using 125 concurrent users
[ omitted for brevity ]
```
> 如果没有指定Json算法的导出文件名,系统会使用默认文件名out.json.
示例:指定一个Prometheus Pushgateway URL,把Cassowary的Json算法导出到Prometheus
```bash
$ ./cassowary run -u http://localhost:8000 -c 125 -n 100000 -p http://pushgatway:9091Starting Load Test with 100000 requests using 125 concurrent users
[ omitted for brevity ]
```
示例:添加HTTP头字段
```bash
$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 -H 'Host: www.example.com'Starting Load Test with 1000 requests using 10 concurrent users
[ omitted for brevity ]
```
示例:关闭http-keep-alive(http-keep-alive在默认下是激活的)
```bash
$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 --disable-keep-aliveStarting Load Test with 1000 requests using 10 concurrent users
[ omitted for brevity ]
```
示例:指定自定义 ca 证书
```bash
$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 --ca /path/to/ca.pemStarting Load Test with 1000 requests using 10 concurrent users
[ omitted for brevity ]
```
示例:指定客户端证书信息
```bash
$ ./cassowary run -u http://localhost:8000 -c 10 -n 1000 --cert /path/to/client.pem --key /path/to/client-key.pemStarting Load Test with 1000 requests using 10 concurrent users
[ omitted for brevity ]
```
**以模块或者library导入Cassowary**
Cassowary可以以模块的形式倒入/使用在你的Go程序。我们从使用go mod下载依赖关系开始
```bash
$ go mod init test && go get github.com/rogerwelin/cassowary/pkg/client
```以下是一个简单示例:如何激活一个load test并且显示结果
```go
package mainimport (
"encoding/json"
"fmt""github.com/rogerwelin/cassowary/pkg/client"
)func main() {
cass := &client.Cassowary{
BaseURL: "http://www.example.com",
ConcurrencyLevel: 1,
Requests: 10,
DisableTerminalOutput: true,
}
metrics, err := cass.Coordinate()
if err != nil {
panic(err)
}// print results
fmt.Printf("%+v\n", metrics)// or print as json
jsonMetrics, err := json.Marshal(metrics)
if err != nil {
panic(err)
}fmt.Println(string(jsonMetrics))
}
```反馈
--------非常欢迎收到各种意见和建议!如果你觉得有某项功能可以更加完善,可以在Issue下发帖,最好能使用feature-request标签。如果你找到一个bug,一定要在issue下发帖告诉我,使用bugs标签。也非常欢迎Pull requests,一样的在issue下发帖,使用feature-request标签就好。