1
0
Fork 0

Support both execute and query benchmarking

master
Philip O'Toole 4 years ago
parent 7bb3b8850d
commit 5f4ec0c607

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"time"
)
@ -24,6 +25,11 @@ func NewHTTPTester(addr, path string) *HTTPTester {
}
}
// String returns a string representation of the tester.
func (h *HTTPTester) String() string {
return h.url
}
// Prepare prepares the tester for execution.
func (h *HTTPTester) Prepare(stmt string, bSz int, tx bool) error {
s := make([]string, bSz)
@ -55,6 +61,11 @@ func (h *HTTPTester) Once() (time.Duration, error) {
}
defer resp.Body.Close()
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
return 0, err
}
if resp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("received %s", resp.Status)
}

@ -16,6 +16,7 @@ var batchSz int
var modPrint int
var tx bool
var tp string
var path string
const name = `rqbench`
const desc = `rqbench is a simple load testing utility for rqlite.`
@ -27,6 +28,7 @@ func init() {
flag.IntVar(&modPrint, "m", 0, "Print progress every m requests")
flag.BoolVar(&tx, "x", false, "Use explicit transaction per request")
flag.StringVar(&tp, "t", "http", "Transport to use")
flag.StringVar(&path, "p", "/db/execute", "Endpoint to use")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "\n%s\n\n", desc)
fmt.Fprintf(os.Stderr, "Usage: %s [arguments] <SQL statement>\n", name)
@ -48,11 +50,12 @@ func main() {
fmt.Fprintf(os.Stderr, "not a valid transport: %s\n", tp)
}
tester := NewHTTPTester(addr, "/db/execute")
tester := NewHTTPTester(addr, path)
if err := tester.Prepare(stmt, batchSz, tx); err != nil {
fmt.Println("failed to prepare test:", err.Error())
os.Exit(1)
}
fmt.Println("Test target:", tester.String())
d, err := run(tester, numReqs)
if err != nil {

Loading…
Cancel
Save