# How to debug and test

## 1. Create a testbed

```bash
make testbed
```

### 2. Debug

```bash
$ make run
KUBECONFIG=kubeconfig.yml go run main.go
2022-04-28T21:48:58.270+0800    INFO    tidbcloud_cluster/main.go:42    create table succeed

2022-04-28T21:49:00.301+0800    INFO    tidbcloud_cluster/main.go:52    result: {cluster="db", cluster_id="tidb1373933076657977415", component="pd", ignoreAlerts="false", instance="db-pd-0", job="tidb1373933076657977415-db-pd", kubernetes_namespace="tidb1373933076657977415", name="c63d6d32", project="staging", receive="true", seed_api="https://172.20.0.1:443", seed_provider="aws", seed_region="us-west-2", shoot_infra="aws", shoot_name="c63d6d32", tenant="1369847559691367419", tenant_id="default-tenant", tidb_cluster="tidb1373933076657977415-db"} => 870.3780000209808 @[1651153738.318]
{cluster="db", cluster_id="tidb1373933076657977415", component="pd", ignoreAlerts="false", instance="db-pd-1", job="tidb1373933076657977415-db-pd", kubernetes_namespace="tidb1373933076657977415", name="c63d6d32", project="staging", receive="true", seed_api="https://172.20.0.1:443", seed_provider="aws", seed_region="us-west-2", shoot_infra="aws", shoot_name="c63d6d32", tenant="1369847559691367419", tenant_id="default-tenant", tidb_cluster="tidb1373933076657977415-db"} => 875.9179999828339 @[1651153738.318]
{cluster="db", cluster_id="tidb1373933076657977415", component="pd", ignoreAlerts="false", instance="db-pd-2", job="tidb1373933076657977415-db-pd", kubernetes_namespace="tidb1373933076657977415", name="c63d6d32", project="staging", receive="true", seed_api="https://172.20.0.1:443", seed_provider="aws", seed_region="us-west-2", shoot_infra="aws", shoot_name="c63d6d32", tenant="1369847559691367419", tenant_id="default-tenant", tidb_cluster="tidb1373933076657977415-db"} => 823.7980000972748 @[1651153738.318], warnings: []
2022-04-28T21:49:02.200+0800    INFO    tidbcloud_cluster/main.go:72    the tidb URL is: mysql://root:5631qmpWX%23t6uDV6@tidb.b48f320f.75f9bc8c.us-west-2.shared.aws.tidbcloud.com:4000
2022-04-28T21:49:02.247+0800    INFO    k8s/client.go:107       it should be noted that a long-running command will not be interrupted even the use case has ended. For more information, please refer to https://github.com/pingcap/test-infra/discussions/129
2022-04-28T21:50:03.919+0800    INFO    tidbcloud_cluster/main.go:81    stdout: [Current] PAYMENT - Takes(s): 6.8, Count: 3, TPM: 26.5, Sum(ms): 5222.2, Avg(ms): 1756.0, 50th(ms): 1811.9, 90th(ms): 1879.0, 95th(ms): 1879.0, 99th(ms): 1879.0, 99.9th(ms): 1879.0, Max(ms): 1879.0
[Current] DELIVERY - Takes(s): 8.0, Count: 1, TPM: 7.5, Sum(ms): 4895.5, Avg(ms): 4966.1, 50th(ms): 5100.3, 90th(ms): 5100.3, 95th(ms): 5100.3, 99th(ms): 5100.3, 99.9th(ms): 5100.3, Max(ms): 5100.3
[Current] NEW_ORDER - Takes(s): 2.8, Count: 1, TPM: 21.7, Sum(ms): 3768.8, Avg(ms): 3825.2, 50th(ms): 3892.3, 90th(ms): 3892.3, 95th(ms): 3892.3, 99th(ms): 3892.3, 99.9th(ms): 3892.3, Max(ms): 3892.3
[Current] ORDER_STATUS - Takes(s): 6.7, Count: 1, TPM: 8.9, Sum(ms): 1069.7, Avg(ms): 1057.0, 50th(ms): 1073.7, 90th(ms): 1073.7, 95th(ms): 1073.7, 99th(ms): 1073.7, 99.9th(ms): 1073.7, Max(ms): 1073.7
[Current] STOCK_LEVEL - Takes(s): 1.9, Count: 1, TPM: 32.3, Sum(ms): 734.2, Avg(ms): 721.4, 50th(ms): 738.2, 90th(ms): 738.2, 95th(ms): 738.2, 99th(ms): 738.2, 99.9th(ms): 738.2, Max(ms): 738.2
[Current] NEW_ORDER - Takes(s): 4.7, Count: 2, TPM: 25.4, Sum(ms): 6060.5, Avg(ms): 3019.9, 50th(ms): 2952.8, 90th(ms): 3221.2, 95th(ms): 3221.2, 99th(ms): 3221.2, 99.9th(ms): 3221.2, Max(ms): 3221.2
[Current] PAYMENT - Takes(s): 9.9, Count: 2, TPM: 12.1, Sum(ms): 3400.0, Avg(ms): 1711.3, 50th(ms): 1677.7, 90th(ms): 1811.9, 95th(ms): 1811.9, 99th(ms): 1811.9, 99.9th(ms): 1811.9, Max(ms): 1811.9
[Current] PAYMENT - Takes(s): 9.7, Count: 5, TPM: 30.9, Sum(ms): 8961.5, Avg(ms): 1791.8, 50th(ms): 1811.9, 90th(ms): 2013.3, 95th(ms): 2013.3, 99th(ms): 2013.3, 99.9th(ms): 2013.3, Max(ms): 2013.3
[Current] STOCK_LEVEL - Takes(s): 4.9, Count: 1, TPM: 12.3, Sum(ms): 718.2, Avg(ms): 721.4, 50th(ms): 738.2, 90th(ms): 738.2, 95th(ms): 738.2, 99th(ms): 738.2, 99.9th(ms): 738.2, Max(ms): 738.2
[Current] NEW_ORDER - Takes(s): 7.4, Count: 1, TPM: 8.1, Sum(ms): 3394.6, Avg(ms): 3422.6, 50th(ms): 3489.7, 90th(ms): 3489.7, 95th(ms): 3489.7, 99th(ms): 3489.7, 99.9th(ms): 3489.7, Max(ms): 3489.7
[Current] PAYMENT - Takes(s): 5.6, Count: 3, TPM: 32.2, Sum(ms): 5016.7, Avg(ms): 1666.5, 50th(ms): 1677.7, 90th(ms): 1811.9, 95th(ms): 1811.9, 99th(ms): 1811.9, 99.9th(ms): 1811.9, Max(ms): 1811.9
Finished
[Summary] DELIVERY - Takes(s): 38.0, Count: 1, TPM: 1.6, Sum(ms): 4895.5, Avg(ms): 4966.1, 50th(ms): 5100.3, 90th(ms): 5100.3, 95th(ms): 5100.3, 99th(ms): 5100.3, 99.9th(ms): 5100.3, Max(ms): 5100.3
[Summary] NEW_ORDER - Takes(s): 32.8, Count: 4, TPM: 7.3, Sum(ms): 13223.9, Avg(ms): 3321.9, 50th(ms): 3221.2, 90th(ms): 3892.3, 95th(ms): 3892.3, 99th(ms): 3892.3, 99.9th(ms): 3892.3, Max(ms): 3892.3
[Summary] NEW_ORDER_ERR - Takes(s): 32.8, Count: 1, TPM: 1.8, Sum(ms): 1653.1, Avg(ms): 1644.2, 50th(ms): 1677.7, 90th(ms): 1677.7, 95th(ms): 1677.7, 99th(ms): 1677.7, 99.9th(ms): 1677.7, Max(ms): 1677.7
[Summary] ORDER_STATUS - Takes(s): 36.7, Count: 1, TPM: 1.6, Sum(ms): 1069.7, Avg(ms): 1057.0, 50th(ms): 1073.7, 90th(ms): 1073.7, 95th(ms): 1073.7, 99th(ms): 1073.7, 99.9th(ms): 1073.7, Max(ms): 1073.7
[Summary] PAYMENT - Takes(s): 46.8, Count: 13, TPM: 16.7, Sum(ms): 22600.3, Avg(ms): 1742.2, 50th(ms): 1811.9, 90th(ms): 2013.3, 95th(ms): 2013.3, 99th(ms): 2013.3, 99.9th(ms): 2013.3, Max(ms): 2013.3
[Summary] STOCK_LEVEL - Takes(s): 31.9, Count: 2, TPM: 3.8, Sum(ms): 1452.4, Avg(ms): 721.4, 50th(ms): 738.2, 90th(ms): 738.2, 95th(ms): 738.2, 99th(ms): 738.2, 99.9th(ms): 738.2, Max(ms): 738.2
tpmC: 7.3, efficiency: 57.0%
stderr:
```

### 3. Destroy the testbed

```bash
make destroy-testbed
```
