Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
Signed-off-by: yeya24 <[email protected]>
  • Loading branch information
yeya24 committed Mar 10, 2020
1 parent 28b7496 commit 2ed919c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea
tpcc_gener
tpccgen
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# tpccgen

A command line utility to generate/import/test via [go-tpc](https://github.com/pingcap/go-tpc)

## Install

```bash
go build -o tpccgen main.go
```

## Flags

```bash
Usage of ./tpccgen:
-all
do all the actions (default true)
-csv
generate tpcc csv files
-data-dir string
data source directory of lightning
-db string
test database name (default "tpcc")
-deploy-dir string
directory path of cluster deployment
-download-url string
url of the go-tpc binary to download (default "https://github.com/pingcap/go-tpc/releases/download/v1.0.0/go-tpc_1.0.0_linux_amd64.tar.gz")
-importer-ip string
ip address of tikv-importer
-lightning-ip string
ip address of tidb-lightnings
-restore
start lightning, importer and restore files
-skip-download
skip downloading the go-tpc binary
-test
run tpcc test
-threads int
number of threads (default 40)
-tidb-ip string
ip of tidb-server (default "127.0.0.1")
-tidb-port string
port of tidb-server (default "4000")
-warehouse int
number of warehouses (default 100)
```

## Usage

By default, tpccgen will automatically take 3 actions:

1. download [go-tpc](https://github.com/pingcap/go-tpc) binary
2. generate csv data
3. import csv data through [tidb-lightning](https://github.com/pingcap/tidb-lightning)

You can also add some flags you want. For example:

```bash
./tpccgen --lightning-ip 172.16.5.90 --importer-ip 172.16.5.89 --data-dir /data/lightning --tidb-ip 172.16.5.84 --tidb-port 4111 --deploy-dir /data/deploy --db test --threads 40 --warehouse 10
```

If you want to perform tpcc test, you must add `--test` flag just like the command below:

```bash
./tpccgen --test --lightning-ip 172.16.5.90 --tidb-ip 172.16.5.84 --tidb-port 4111 --db test --threads 40 --warehouse 10
```
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
)

var (
all = flag.Bool(nmAll, true, "do all the actions")
all = flag.Bool(nmAll, true, "do all the actions, test is not included")
csv = flag.Bool(nmCSV, false, "generate tpcc csv files")
test = flag.Bool(nmTest, false, "run tpcc test")
restore = flag.Bool(nmRestore, false, "start lightning, importer and restore files")
Expand Down Expand Up @@ -82,18 +82,18 @@ func main() {
os.Exit(1)
}

// If test flag is enabled, just run tpcc test.
if *test {
var checkTime time.Time
var testStart time.Time
if err = runTPCCTest(lightningIPs[0], *tidbIP, *tidbPort, *dbName, *warehouse, *threads); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
fmt.Println("tpcc test finished successfully!")
fmt.Println("prepare cost:", time.Since(start).String(), "test cost:", time.Since(checkTime).String())
fmt.Println("prepare cost:", time.Since(start).String(), "test cost:", time.Since(testStart).String())
os.Exit(0)
}


if *all || *csv {
if err = dropDB(*tidbIP, *tidbPort, *dbName); err != nil {
os.Exit(1)
Expand Down

0 comments on commit 2ed919c

Please sign in to comment.