# How to debug and test

## 1. Create a testbed

prepare a testbed spec in testbed.yaml:

```yaml
---
generateName: testbed-
items:
  - name: tc
    type: TIDB_CLUSTER
    spec:
      pd:
        replicas: 1
        image: pingcap/pd:v5.0.0
      tidb:
        replicas: 1
        image: pingcap/tidb:v5.0.0
      tikv:
        replicas: 1
        image: pingcap/tikv:v5.0.0
  - name: go-tpc-workload
    type: WORKLOAD_NODE
    spec:
      container:
        name: go-tpc
        image: hub.pingcap.net/qa/go-tpc:v1.0.7
        command:
          - tail
          - "-f"
          - "/dev/null"
        resources:
          requests:
            memory: 64Mi
            cpu: 1000m
```

Then request the testbed:

```bash
make testbed
```

### 2. Debug

```bash
$ KUBECONFIG=PATH_TO_KUBECONFIG make run
...
Finished
[Summary] DELIVERY - Takes(s): 299.7, Count: 2381, TPM: 476.7, Sum(ms): 195177.3, Avg(ms): 82.1, 50th(ms): 71.3, 90th(ms): 130.0, 95th(ms): 151.0, 99th(ms): 201.3, 99.9th(ms): 260.0, Max(ms): 318.8
[Summary] NEW_ORDER - Takes(s): 299.9, Count: 27294, TPM: 5459.8, Sum(ms): 565669.8, Avg(ms): 20.7, 50th(ms): 19.9, 90th(ms): 27.3, 95th(ms): 31.5, 99th(ms): 46.1, 99.9th(ms): 117.4, Max(ms): 142.6
[Summary] NEW_ORDER_ERR - Takes(s): 299.9, Count: 2, TPM: 0.4, Sum(ms): 23.2, Avg(ms): 11.5, 50th(ms): 9.4, 90th(ms): 14.2, 95th(ms): 14.2, 99th(ms): 14.2, 99.9th(ms): 14.2, Max(ms): 14.2
[Summary] ORDER_STATUS - Takes(s): 299.9, Count: 2435, TPM: 487.2, Sum(ms): 19028.3, Avg(ms): 7.8, 50th(ms): 8.4, 90th(ms): 10.5, 95th(ms): 11.5, 99th(ms): 15.2, 99.9th(ms): 18.9, Max(ms): 18.9
[Summary] ORDER_STATUS_ERR - Takes(s): 299.9, Count: 1, TPM: 0.2, Sum(ms): 6.2, Avg(ms): 6.0, 50th(ms): 6.3, 90th(ms): 6.3, 95th(ms): 6.3, 99th(ms): 6.3, 99.9th(ms): 6.3, Max(ms): 6.3
[Summary] PAYMENT - Takes(s): 300.0, Count: 26239, TPM: 5248.7, Sum(ms): 375387.6, Avg(ms): 14.3, 50th(ms): 13.1, 90th(ms): 22.0, 95th(ms): 26.2, 99th(ms): 35.7, 99.9th(ms): 48.2, Max(ms): 88.1
[Summary] PAYMENT_ERR - Takes(s): 300.0, Count: 1, TPM: 0.2, Sum(ms): 6.2, Avg(ms): 6.0, 50th(ms): 6.3, 90th(ms): 6.3, 95th(ms): 6.3, 99th(ms): 6.3, 99.9th(ms): 6.3, Max(ms): 6.3
[Summary] STOCK_LEVEL - Takes(s): 299.9, Count: 2502, TPM: 500.5, Sum(ms): 35053.0, Avg(ms): 14.0, 50th(ms): 13.6, 90th(ms): 16.3, 95th(ms): 17.8, 99th(ms): 21.0, 99.9th(ms): 92.3, Max(ms): 117.4
tpmC: 5459.8, efficiency: 10614.0%
```

### 3. Destroy the testbed

```bash
make destroy-testbed
```
