Skip to content

Commit

Permalink
Merge pull request #24 from vitessio/shards
Browse files Browse the repository at this point in the history
add ShardsQueried to vtbenchstat & misc cleanups
  • Loading branch information
systay authored Sep 20, 2024
2 parents 0fc34cc + fc153be commit e13a54c
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 154 deletions.
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
.PHONY: all build test tidy clean vitess-tester vtbenchstat

GO := go

default: build
REQUIRED_GO_VERSION := 1.23

# Version check
check_version:
@GO_VERSION=$$($(GO) version | awk '{print $$3}' | sed 's/go//'); \
MAJOR_VERSION=$$(echo $$GO_VERSION | cut -d. -f1); \
MINOR_VERSION=$$(echo $$GO_VERSION | cut -d. -f2); \
if [ "$$MAJOR_VERSION" -eq 1 ] && [ "$$MINOR_VERSION" -lt 23 ]; then \
echo "Error: Go version $(REQUIRED_GO_VERSION) or higher is required. Current version is $$GO_VERSION"; \
exit 1; \
else \
echo "Go version is acceptable: $$GO_VERSION"; \
fi

default: check_version build

build: vitess-tester vtbenchstat

Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ Vitess tester tests Vitess using the same test files as the [MySQL Test Framewor

## Install

If you only want the `vitess-tester` binary, install it using the following command:

```
go install github.com/vitessio/vitess-tester@latest
```

The `vtbenchstat` binary can be had by running:

```
go install github.com/vitessio/vitess-tester/src/cmd/vtbenchstat@latest
```

## Testing methodology

To ensure compatibility and correctness, our testing strategy involves running identical queries against both MySQL and vtgate, then comparing the results and errors from the two systems. This approach helps us verify that vtgate behaves as expected in a variety of scenarios, mimicking MySQL's behavior as closely as possible.
Expand Down Expand Up @@ -76,6 +84,8 @@ Usage of ./vitess-tester:
logs at or above this threshold go to stderr (default 2)
-topo-flavor string
choose a topo server from etcd2, zk2 or consul (default "etcd2")
-trace string
Do a vexplain trace on all queries and store the output in the given file.
-v value
log level for V logs
-vmodule value
Expand All @@ -100,6 +110,31 @@ vitess-tester -vtexplain-vschema t/vtexplain-vschema.json t/vtexplain.test # run

The test files can be amended with directives to control the testing process. Check out `directives.test` to see examples of what directives are available.

## Tracing and comparing execution plans

`vitess-tester` can run in tracing mode. When it does, it will not only run the tests but also generate a trace of the query execution plan.
The trace is created using `vexplain trace`, a tool that provides detailed information about how a query is executed.

To run `vitess-tester` in tracing mode, use the `-trace` flag:

```bash
vitess-tester --sharded -trace=trace-log.json t/tpch.test
```

This will create a trace log, which you can then either summarize using `vtbenchstat` or compare with another trace log.

Running `vtbenchstat` will provide a summary of the trace log, including the number of queries, the number of rows returned, and the time taken to execute the queries.

```bash
vtbenchstat trace-log.json
```

To compare two trace logs, use the `vtbenchstat` command with two trace logs as arguments:

```bash
vtbenchstat trace-log1.json trace-log2.json
```

## Contributing

Contributions are welcomed and greatly appreciated. You can help by:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/vitessio/vitess-tester

go 1.22.5
go 1.23.1

require (
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32
Expand All @@ -9,6 +9,7 @@ require (
)

require (
github.com/alecthomas/chroma v0.10.0
github.com/jstemmer/go-junit-report/v2 v2.1.0
github.com/olekukonko/tablewriter v0.0.5
golang.org/x/term v0.22.0
Expand All @@ -26,7 +27,6 @@ require (
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
github.com/DataDog/sketches-go v1.4.6 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/aquarapid/vaultlib v0.5.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/vtbenchstat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ func main() {
}

if len(traces) == 1 {
printSummary(traces[0])
printSummary(os.Stdout, terminalWidth(), highlightQuery, traces[0])
} else {
compareTraces(traces[0], traces[1])
compareTraces(os.Stdout, terminalWidth(), highlightQuery, traces[0], traces[1])
}
}

Loading

0 comments on commit e13a54c

Please sign in to comment.