• Stars
    star
    141
  • Rank 259,918 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A toolkit for testing TiDB

TiPocket

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

  • go-sqlsmith: go-sqlsmith is our Go implementation of sqlsmith, it's a fuzz-testing tool which can generate random MySQL-dialect SQL queries.
  • go-elle: Our Go port version of jepsen-io/elle, a general transactional consistency checker for black-box databases.

Nemesis

  • random_kill, all_kill, minor_kill, major_kill, kill_tikv_1node_5min, kill_pd_leader_5min: As their name implies, these nemeses inject unavailable in a specified period of time.
  • short_kill_tikv_1node, short_kill_pd_leader: Kill selected container, used to inject short duration of unavailable fault.
  • partition_one: Isolate single nodes
  • scaling: Scale up/down TiDB/PD/TiKV nodes randomly
  • shuffle-leader-scheduler/shuffle-region-scheduler/random-merge-scheduler: Just as there name implies
  • delay_tikv, delay_pd, errno_tikv, errno_pd, mixed_tikv, mixed_pd: Inject IO-related fault.
  • small_skews, subcritical_skews, critical_skews, big_skews, huge_skews: Clock skew, small_skews ~100ms, subcritical_skews ~200ms, critical_skews ~250ms, big_skews ~500ms and huge_skews ~5s.

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.

  • Start a TiDB cluster
tiup playground --kv 3
  • Specify that cluster address through -tidb-server -tikv-server and -pd-server
bin/${testcase} -tidb-server 127.0.0.1:4000 
  • If a cluster has many service addresses, you can pass a flag multiple times
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

  • bank transfers between rows of a shared table
  • pbank check bank accounts using a linearizability checker porcupine
  • vbank like bank but cover more TiKV features
  • ledger yet another bank test
  • rawkv-linearizability rawkv linearizability checker
  • tpcc use go-tpc testing consistency

Isolation

  • append checks for dependency cycles in transactions using Elle
  • register checks for write-read dependency cycles over read-write registers using Elle

More Repositories

1

tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
Go
37,055
star
2

talent-plan

open source training courses about distributed database and distributed systems
Rust
10,112
star
3

awesome-database-learning

A list of learning materials to understand databases internals
9,339
star
4

docs-cn

TiDB/TiKV/PD ไธญๆ–‡ๆ–‡ๆกฃ
Shell
1,811
star
5

ossinsight

Analysis, Comparison, Trends, Rankings of Open Source Software, you can also get insight from more than 7 billion with natural language (powered by OpenAI). Follow us on Twitter: https://twitter.com/ossinsight
TypeScript
1,744
star
6

parser

A MySQL Compatible SQL Parser
Go
1,409
star
7

tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
Go
1,221
star
8

tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
C++
944
star
9

tispark

TiSpark is built for running Apache Spark on top of TiDB/TiKV
Scala
883
star
10

failpoint

An implementation of failpoints for Golang.
Go
816
star
11

go-ycsb

A Go port of Yahoo! Cloud Serving Benchmark (YCSB)
Go
594
star
12

docs

TiDB database documentation. TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
Python
584
star
13

dm

Data Migration Platform
Go
456
star
14

tiflow

This repo maintains DM (a data migration platform) and TiCDC (change data capture for TiDB)
Go
426
star
15

tiup

A component manager for TiDB
Go
417
star
16

ossinsight-lite

๐Ÿšง[WIP] Yet another customizable free GitHub stats dashboard based on TiDB Serverless: https://ossinsight-lite.vercel.app, hand-drawn style.
TypeScript
383
star
17

presentations

367
star
18

tidb-docker-compose

Python
352
star
19

tidb-ansible

Python
326
star
20

tidb-binlog

A tool used to collect and merge tidb's binlog for real-time data backup and synchronization.
Go
292
star
21

tla-plus

TLA
292
star
22

tidb-tools

tidb-tools are some useful tool collections for TiDB.
Go
286
star
23

dumpling

Dumpling is a fast, easy-to-use tool written by Go for dumping data from the database(MySQL, TiDB...) to local/cloud(S3, GCP...) in multifarious formats(SQL, CSV...).
Go
281
star
24

community

TiDB community content
260
star
25

chaos

A test framework for linearizability check with Go
Go
206
star
26

tidb.ai

https://TiDB.AI is a Graph RAG based and conversational knowledge base tool built with TiDB Serverless Vector Storage and LlamaIndex. Open source and free to use.
TypeScript
186
star
27

go-tpc

A toolbox to benchmark TPC workloads in Go
Go
177
star
28

tidb-dashboard

A Web UI for monitoring, diagnosing and managing the TiDB cluster.
TypeScript
175
star
29

kvproto

Protocol buffer files for TiKV
CMake
152
star
30

tidb-lightning

This repository has been moved to https://github.com/pingcap/br
Go
142
star
31

blog-cn

Shell
126
star
32

br

A command-line tool for distributed backup and restoration of the TiDB cluster data
Go
123
star
33

tidb-dev-guide

A comprehensive development guide to help you be more and more familiar with the TiDB community and become an expert finally.
118
star
34

tidb-bench

A Simple Benchmark For TiDB
C
108
star
35

gdocwiki

A wiki based on Google Doc / Drive
TypeScript
102
star
36

tidb-map

A series of maps to help users and contributors
95
star
37

tipb

TiDB protobuf
CMake
92
star
38

style-guide

Style guide for PingCAP and TiKV code
80
star
39

benchmarksql

Unofficial mirror of benchmarksql on github
Java
79
star
40

go-randgen

a QA tool to random generate sql by bnf pattern
Go
75
star
41

mysql-tester

A Golang implementation of MySQL Test Framework
Go
63
star
42

weekly

57
star
43

tidb-prisma-vercel-demo

Virtual online bookstore application demo which you can find books of various categories and rate the books.
TypeScript
56
star
44

tiproxy

Go
56
star
45

advanced-statefulset

Go
55
star
46

blog

Python
49
star
47

docs-tidb-operator

Documentation for TiDB on Kubernetes. TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
Python
47
star
48

tikv-client-lib-java

TiKV Java client library
Java
44
star
49

tidiff

A toolset to improve efficiency
Go
41
star
50

meetup

37
star
51

fn

Go
35
star
52

tidb-vector-python

TiDB Vector SDK for Python, including code examples. Join our Discord: https://discord.gg/XzSW23Jg9p
Python
35
star
53

tiunimanager

TiUniManager
Go
34
star
54

thirdparty-ops

This repo is used for the operation and maintenance of third party tools.
Python
32
star
55

dead-mans-switch

A bypass monitoring prober
Go
32
star
56

ng-monitoring

Go
31
star
57

django-tidb

TiDB dialect for Django
Python
30
star
58

tidb-course-201-lab

Lab scripts for the PingCAP training course: TiDB SQL for Developers.
Python
30
star
59

tidb-vision

TiDB data visualization
JavaScript
28
star
60

tidb-inspect-tools

Python
27
star
61

monitoring

Shell
26
star
62

activerecord-tidb-adapter

TiDB adapter for ActiveRecord, allows the use of TiDB as a backend for ActiveRecord and Rails apps.
Ruby
24
star
63

diag

A tool to collect diagnostic data from TiDB Clusters
Go
24
star
64

docs-dm

Documentation for the TiDB Data Migration (DM) tool in both English and Chinese.
Python
23
star
65

LinguFlow

LinguFlow, a low-code tool designed for LLM application development, simplifies the building, debugging, and deployment process for developers.
TypeScript
23
star
66

website-docs

The next generation of PingCAP Docs. Powered by Gatsby โš›๏ธ.
TypeScript
22
star
67

book.tidb.net

JavaScript
22
star
68

kdt

Kernel Debug Toolkit
Shell
20
star
69

log

Go
17
star
70

octopus

A toolkit including many powerful distributed test tools
Go
15
star
71

Auto-GPT-TiDB-Serverless-Plugin

Python
15
star
72

errcode

Go
14
star
73

dbt-tidb

A dbt adapter for TiDB
Python
14
star
74

tidb_workload_analysis

Go
14
star
75

k8s-fluent-bit-stackdriver

Shell
11
star
76

website

The website of PingCAP. Powered by Gatsby โš›๏ธ and Rocket ๐Ÿš€.
JavaScript
11
star
77

tpcc-mysql

forked from https://code.launchpad.net/~percona-dev/perconatools/tpcc-mysql
C
11
star
78

tidb-insight

Python
11
star
79

tidb-loadbalance

Java
10
star
80

tso

Timestamp Oracle
Go
9
star
81

tiunimanager-ui

A web UI for TiUniManager
TypeScript
9
star
82

tidb-ctl

TiDB Controller
Go
9
star
83

hackernews-insight

Chat to query Hacker News database, based on Auto-GPT and TiDB Cloud Serverless Database
TypeScript
9
star
84

tidb-cloud-backup

Go
8
star
85

wordpress-tidb-plugin

PHP
8
star
86

docs-appdev

Python
7
star
87

wordpress-tidb-docker

WordPress x TiDB Serverless Tier Cluster
Shell
7
star
88

tidb-academy-labs

6
star
89

etcdv3-gateway

Gateway for etcdv3
Go
6
star
90

tispark-test

C
6
star
91

sysutil

sysutil is a library which implementats the gRPC service Diagnostics and shares the diagnostics functions between TiDB and PD.
Go
6
star
92

sqlalchemy-tidb

Python
5
star
93

oasis

Python
5
star
94

homebrew-brew

Homebrew taps for TiDB
Ruby
5
star
95

mysqlrelay

Go
4
star
96

tidb-lmdb

lmdb as storage engine for tidb
Go
4
star
97

cloud-assets-utils

Cloud assets utils by PingCAP FE.
OCaml
4
star
98

mpdriver

MySQL Protocol Driver, used to record MySQL query commands..
Go
4
star
99

tidb-helper

Shell
3
star
100

vldb-boss-2018

Slides and links for VLDB BOSS 2018
3
star