Removing loadgen, it's not used.

This commit is contained in:
Alain Jobart 2015-05-28 15:04:33 -07:00
Родитель fabda37434
Коммит 6726dd31a9
2 изменённых файлов: 0 добавлений и 319 удалений

Просмотреть файл

@ -1,137 +0,0 @@
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"math/rand"
"os"
"sync"
"time"
"github.com/youtube/vitess/go/vt/client2/tablet"
)
func main() {
goroutines := flag.Int("goroutines", 100, "Number of client goroutines to run")
connections := flag.Int("connections", 20000, "Number of connections to create")
queries := flag.Int("queries", 1*1024*1024, "Numberof queries to run")
flag.Parse()
perconnections := *connections / *goroutines
perqueries := *queries / *goroutines
for i := 0; i < *goroutines; i++ {
if i != *goroutines-1 {
go run(perconnections, perqueries)
*connections -= perconnections
*queries -= perqueries
} else {
go run(*connections, *queries)
}
}
registry.Wait()
}
func run(connections, queries int) {
registry.Add(1)
defer registry.Done()
conns := make([]*tablet.Conn, connections)
for i := 0; i < connections; i++ {
var err error
conns[i], err = tablet.DialTablet(server, false)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return
}
}
time.Sleep(time.Second)
connid := 0
count := 0
bindVars := make(map[string]interface{})
for {
for _, plan := range distribution {
bindVars["id"] = rand.Intn(10000) + 1
for i := 0; i < plan.iterations; i++ {
_, err := conns[connid].Exec(baseQuery+plan.whereClause, bindVars)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return
}
count++
connid = (connid + 1) % connections
if count >= queries {
return
}
}
}
}
}
var registry sync.WaitGroup
var server = "localhost:9461/vt_test_keyspace"
var baseQuery = `
select
id,
num1,
char1,
char2,
num2,
char3,
char4,
char5,
num3,
char6,
char7,
date1,
char8,
char9,
num4,
char10,
num5,
num6,
num7,
num8,
char11,
num9,
num10,
num11,
num12,
num13,
num14,
char12,
num15,
num16,
num17,
num18,
num19
from vt_load
`
type RequestPlan struct {
rowsHint int
iterations, variations int
whereClause string
}
var distribution = []RequestPlan{
{1, 63000, 0, " where id = :id"},
{0, 14000, 0, " where id = 0"},
{10000, 1, 0, ""},
{2, 3000, 0, " where id >= :id limit 2"},
{1000, 1, 0, " where id >= :id limit 1000"},
{5, 3000, 0, " where id >= :id limit 5"},
{10, 3000, 0, " where id >= :id limit 10"},
{20, 6000, 0, " where id >= :id limit 20"},
{2000, 1, 0, " where id >= :id limit 2000"},
{50, 7000, 0, " where id >= :id limit 50"},
{100, 1000, 0, " where id >= :id limit 100"},
{5000, 1, 0, " limit 5000"},
{200, 1000, 0, " where id >= :id limit 200"},
{500, 1000, 0, " where id >= :id limit 500"},
}

Просмотреть файл

@ -1,182 +0,0 @@
#!/usr/bin/env python
import json
import logging
import optparse
import os
import subprocess
import sys
import utils
from queryservice_tests import test_env
create_table = """
create table vt_load(
id bigint(20),
num1 int(10) unsigned,
char1 varchar(20),
char2 varchar(20),
num2 int(10) unsigned,
char3 varchar(140),
char4 char(1),
char5 varchar(40),
num3 int(10) unsigned,
char6 varchar(300),
char7 varchar(150),
date1 date,
char8 varchar(16),
char9 varchar(120),
num4 bigint(20),
char10 char(1),
num5 bigint(20),
num6 bigint(20),
num7 bigint(20),
num8 int(11),
char11 char(1),
num9 tinyint(3) unsigned,
num10 int(10) unsigned,
num11 bigint(20),
num12 bigint(20),
num13 bigint(20),
num14 int(10) unsigned,
char12 varchar(10),
num15 bigint(20) unsigned,
num16 bigint(20) unsigned,
num17 bigint(20) unsigned,
num18 bigint(20),
num19 int(10) unsigned,
PRIMARY KEY (id)
) ENGINE=InnoDB
"""
insert = """
insert into vt_load values(
%(id)s,
%(num1)s,
%(char1)s,
%(char2)s,
%(num2)s,
%(char3)s,
%(char4)s,
%(char5)s,
%(num3)s,
%(char6)s,
%(char7)s,
%(date1)s,
%(char8)s,
%(char9)s,
%(num4)s,
%(char10)s,
%(num5)s,
%(num6)s,
%(num7)s,
%(num8)s,
%(char11)s,
%(num9)s,
%(num10)s,
%(num11)s,
%(num12)s,
%(num13)s,
%(num14)s,
%(char12)s,
%(num15)s,
%(num16)s,
%(num17)s,
%(num18)s,
%(num19)s
)
"""
fixed_values = {
"num1": 1114367205,
"char1": "abcdef",
"char2": None,
"num2": 8736,
"char3": "asdasdas@asdasd.asdas",
"char4": "a",
"char5": "11.22.33.44",
"num3": 0,
"char6": "Asdihdfiuevkdj",
"char7": "Basdfihjdsfoieuw",
"date1": "1995-02-06",
"char8": 98765,
"char9": "Poidsf",
"num4": 12323,
"char10": "b",
"num5": 4641528869078863271,
"num6": 123,
"num7": 12345,
"num8": 784233,
"char11": "A",
"num9": 94,
"num10": 1360128451,
"num11": -1328510013,
"num12": None,
"num13": 89343,
"num14": 384734,
"char12": "en_US",
"num15": 0,
"num16": None,
"num17": 12609028137540273996,
"num18": 329527359100,
"num19": 0,
}
def init_data(env):
env.execute(create_table)
env.execute("begin")
for pk in range(10000):
fixed_values["id"] = pk + 1
env.execute(insert, fixed_values)
env.execute("commit")
if __name__ == "__main__":
parser = optparse.OptionParser(usage="usage: %prog [options] [test_names]")
# Options used by test_env
parser.add_option("-m", "--memcache", action="store_true", default=False,
help="starts a memcached, and tests rowcache")
parser.add_option("-e", "--env", default='vttablet,vtocc',
help="Environment that will be used. Valid options: vttablet, vtocc")
parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", default=1)
parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=1)
# Options for the load generator
parser.add_option("--gomaxprocs", type="int", default="8")
parser.add_option("--goroutines", type="int", default=50)
parser.add_option("--connections", type="int", default=15000)
parser.add_option("--queries", type="int", default=3000000)
(options, args) = parser.parse_args()
utils.options = options
logging.getLogger().setLevel(logging.ERROR)
if options.env == 'vttablet':
env = test_env.VttabletTestEnv()
elif options.env == 'vtocc':
env = test_env.VtoccTestEnv()
else:
raise Exception("Valid options for -e: vtocc, vttablet")
try:
os.environ["GOMAXPROCS"] = str(options.gomaxprocs)
env.setUp()
init_data(env)
subprocess.call([
'go',
'run',
'%s/test/goloadgen/goloadgen.go' % env.vttop,
"--goroutines=%d" % options.goroutines,
"--connections=%d" % options.connections,
"--queries=%d" % options.queries])
dvars = env.debug_vars()
print dvars["memstats"]["PauseNs"]
print dvars["memstats"]["BySize"]
dvars["memstats"]["PauseNs"] = None
dvars["memstats"]["BySize"] = None
json.dump(dvars, sys.stdout, indent=2, sort_keys=True)
print
json.dump(env.query_stats(), sys.stdout, indent=2)
print
finally:
env.tearDown()