## 1. 安装 tcctl，申请 token 之类, 参照群公告
## 2. 在 staging 环境跑一下负载测试，如下
```
git clone https://github.com/dbsid/endless.git
cd endless
git checkout perftest
cd testcase/perftest/daily/bench
tcctl testbed create -f testbed-1tidb-3tikv.yaml -r http://rms-staging.pingcap.net:30007 && sh -x ./test.sh
```
## 3. 生成环境提交一个one shot plan
## 4. 确认 daily plan 是否正常运气
## 5. 提交 oneshot plan, 对比prepared-plan-cache 开启和关闭的性能对比
## 6. staging 环境如何看监控下
```
chenhuansheng@Mac bench % tcctl testbed list -r http://rms-staging.pingcap.net:30007
I1112 11:08:14.083747   17677 log.go:15] using config file: /Users/chenhuansheng/.tcctl.yml
NAME                           LEASE    EXPIRE DATE
----                           -----    -----------
testbed-restore-monitor-scd7n  24h0m0s  2021/11/13 00:41:20.000 +08:00
chenhuansheng@Mac bench % kubectl -n release-perftest-tpcc-hybrid-pr-001--tps-390446-1-644 port-forward  pods/tiup-0 28000:13000
```
## 7. 如何登录 pod
```
KUBECONFIG=./kubeconfig.yml  kubectl -n testbed-perftest-r265m exec -it tiup-0 bash
```

## 8. 生产环境如果恢复grafana
文档 https://github.com/pingcap/test-infra/blob/main/docs/user-guide/plan_execution.md
### 1. 按照文档找到test-bed 名称
### 2 假设 test-bed 名称 release-perftest-sysbench-hybrid-001-tps-540014-1-334, 拼出如下 URL，获取 tiup.data.promtheus-19090.tar 分享链接，把 链接存入一个文件，比如v5.3.0.txt
```
http://minio.pingcap.net:9000/minio/test-infra-testground/archive/release-perftest-sysbench-hybrid-001-tps-540014-1-334/tiup/
```

### 3 restore-motnitor
通过以下命令恢复监控，会生成 `grafana-0` 和 `promtheus-0` 两个pod
```
tcctl testbed restore-monitor --cluster-type tiup --prom-tarball-url \`cat v5.3.0.txt\`
I1122 12:24:01.995754  326752 log.go:15] using config file: /home/perfdata/.tcctl.yml
I1122 12:24:02.206478  326752 log.go:15] monitor restored, to access: kubectl -n testbed-restore-monitor-cvrv9 port-forward pods/grafana-0 8088:3000
I1122 12:24:02.206503  326752 log.go:15] Dashboard in: http://127.0.0.1:8088, wait 1 minute till it works
[perfdata@IDC-172-16-6-48 restore-monitor]$ kubectl  -n testbed-restore-monitor-cvrv9 get pods
NAME           READY   STATUS    RESTARTS   AGE
grafana-0      1/1     Running   0          103s
prometheus-0   1/1     Running   0          103s
```

### 4 创建 grafana 端口映射

```
kubectl -n testbed-restore-monitor-cvrv9 port-forward pods/grafana-0 8088:3000  --address='0.0.0.0'
```

## 9 如何访问正在执行的 case 的监控
通过调用 `auth.sh` 脚本, 如下命令把 `tiup-0` 13000 grafa 端口映射到本机的 13000 端口
```
[perfdata@IDC-172-16-6-48 ~]$ cat auth.sh
#tcctl testbed auth $1 -r http://rms.pingcap.net:30007
tcctl testbed auth $1 -r http://172.16.4.29:30007
kubectl --kubeconfig=kubeconfig.yml -n $1 port-forward pods/$2 $3:$3 --address='0.0.0.0'
[perfdata@IDC-172-16-6-48 ~]$ ./auth.sh release-perftest-tpcc-hybrid-pr-001--tps-540027-1-399 tiup-0 13000
```

### 注意事项
1. case 需要 go mod init 自己起一个 go mod，目前不能跟 endless 共用
   且 go.mod 里面要有 `replace google.golang.org/grpc => google.golang.org/grpc v1.29.1

   原因是 caselib 引用了 ticdc，有依赖问题

2. 编译跟调试 case 的时候需要 disable cgo 和加一个编译期参数，也是因为 caselib 的依赖问题
   `CGO_ENABLED=0 ginkgo build -ldflags "-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn"`


3. 目前还有些 case 里用到的接口没有支持，在 NOTE 里有说明，这些都会这两天做完兼容
