Home

Awesome

<img src="static/logo.png" alt="TiPocket" width="300"/>

TiPocket is a testing toolkit designed to test TiDB, it encapsulates some testing tools which are also suitable for testing other databases.

TiPocket is inspired by jepsen-io/jepsen, a famous library on the distributed system field. TiPocket focuses on stability testing on TiDB, it uses chaos-mesh to inject all-round kinds of nemesis on a TiDB cluster.

Requirements

Toolkit

Nemesis

Create a new case

run make init c=$case, for example:

$ make init c=demo
GO15VENDOREXPERIMENT="1" CGO_ENABLED=1 GOOS= GOARCH=amd64 GO111MODULE=on go build -ldflags '-s -w -X "github.com/pingcap/tipocket/pkg/test-infra/fixture.BuildTS=2021-02-05 07:13:54" -X "github.com/pingcap/tipocket/pkg/test-infra/fixture.BuildHash=a70411f45605864da28a5000aff72a226a1ab27f"'  -o bin/tipocket cmd/tipocket/*.go
bin/tipocket init -c demo
create a new case `demo`: testcase/demo

Debug and Run

If you have a K8s cluster, you can use the below commands to deploy and run the case on a TiDB cluster.

On a K8s cluster

Access directly

make build
export KUBECONFIG=${YOUR_KUBECONFIG_PATH}

# direct connect
bin/${testcase} -namespace=${ns} -hub=docker.io -image-version=nightly -storage-class=local-path

This method can't resolve the k8s cluster network accessing and DNS resolution issues, but it's useful for most cases.

Access by a proxy on k8s cluster

export KUBECONFIG=${YOUR_KUBECONFIG_PATH}
kubectl apply -f hacks/debug/k8s-proxy.yaml -n ${ns}
bin/${testcase} -mysql-proxy=socks5://${a_node_ip}:30080 -namespace=${ns} -hub=docker.io -image-version=nightly -storage-class=local-path

This method overcomes the k8s cluster network accessing problem, but one flaw is retained: DNS resolution, so proxychains-ng is recommended here (if you don't mind to install it: brew install proxychains-ng).

export KUBECONFIG=${YOUR_KUBECONFIG_PATH}
kubectl apply -f hacks/debug/k8s-proxy.yaml -n ${ns}
# edit hacks/debug/proxychains.conf, replace REPLACE_ME_WITH_REAL_NODE_IP with a k8s node ip,
# you can connect to the k8s administrator to get a k8s node ip
proxychains4 -f hacks/debug/proxychains.conf bin/${testcase} -mysql-proxy=socks5://${a_node_ip}:30080 -namespace=${ns} -hub=docker.io -image-version=nightly -storage-class=local-path

On the local environment

Another convenient way we recommend you is using tiup to deploy a cluster on local and use it to debug cases.

tiup playground --kv 3
bin/${testcase} -tidb-server 127.0.0.1:4000 
bin/${testcase} -tikv-server 127.0.0.1:20160 -tikv-server 127.0.0.1:20161

Workloads

TiPocket includes some consistency, isolation and other kinds of tests

Consistency

Isolation