feat: 测试交付 Q1 混沌压测骨架与 Q4 镜像骨架
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# Linux 容器内用 netem 做丢包(本机 Windows 不能直接跑 tc)
|
||||
|
||||
## 用法
|
||||
|
||||
对已经在同一网络里的目标容器网卡注入 20% 丢包(需要 `NET_ADMIN`):
|
||||
|
||||
```powershell
|
||||
# 示例:起一个带 net-tools/iproute2 的旁路容器,对网卡 eth0 丢包
|
||||
docker run --rm --name q-netem --cap-add=NET_ADMIN --network container:q-toxiproxy `
|
||||
nicolaka/netshoot `
|
||||
bash -lc "tc qdisc replace dev eth0 root netem loss 20%"
|
||||
```
|
||||
|
||||
或把本目录脚本挂进去:
|
||||
|
||||
```powershell
|
||||
docker run --rm --name q-netem --cap-add=NET_ADMIN --network container:<目标容器名> `
|
||||
-v ${PWD}/test/chaos/netem:/scripts:ro `
|
||||
nicolaka/netshoot `
|
||||
bash /scripts/apply-loss.sh eth0 20
|
||||
```
|
||||
|
||||
清除:
|
||||
|
||||
```powershell
|
||||
docker run --rm --name q-netem-clear --cap-add=NET_ADMIN --network container:<目标容器名> `
|
||||
nicolaka/netshoot `
|
||||
bash -lc "tc qdisc del dev eth0 root 2>/dev/null || true"
|
||||
```
|
||||
|
||||
用完删除容器(上面 `--rm` 已自动删)。不要把 NixMsg 业务端口写死进脚本。
|
||||
Reference in New Issue
Block a user