cleanup of various configs & tests to use the new VTROOT structure

This commit is contained in:
Sugu Sougoumarane 2012-09-06 16:14:19 -07:00
Родитель 6ea812b5c1
Коммит 64cc603008
8 изменённых файлов: 108 добавлений и 116 удалений

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

@ -55,5 +55,6 @@ ln -snf $VTTOP/go/cmd/vtocc/vtocc $VTROOT/bin/vtocc
ln -snf $VTTOP/go/cmd/vttablet/vttablet $VTROOT/bin/vttablet
ln -snf $VTTOP/go/cmd/zk/zk $VTROOT/bin/zk
ln -snf $VTTOP/go/cmd/zkctl/zkctl $VTROOT/bin/zkctl
ln -snf $VTTOP/go/zk/zkctl/zksrv.sh $VTROOT/bin/zksrv.sh
echo "source dev.env in your shell to complete the setup."

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

@ -153,7 +153,7 @@ func Init(mt *Mysqld) error {
return err
}
cnfTemplatePath := os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/config/mycnf")
cnfTemplatePath := os.ExpandEnv("$VTROOT/config/mycnf")
configData, err := MakeMycnfForMysqld(mt, cnfTemplatePath, "tablet uid?")
if err == nil {
err = ioutil.WriteFile(mt.config.MycnfFile, []byte(configData), 0664)
@ -163,7 +163,7 @@ func Init(mt *Mysqld) error {
return err
}
dbTbzPath := os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/data/bootstrap/mysql-db-dir.tbz")
dbTbzPath := os.ExpandEnv("$VTROOT/data/bootstrap/mysql-db-dir.tbz")
relog.Info("decompress bootstrap db %v", dbTbzPath)
args := []string{"-xj", "-C", mt.config.DataDir, "-f", dbTbzPath}
_, tarErr := execCmd("tar", args, []string{}, "")
@ -175,7 +175,7 @@ func Init(mt *Mysqld) error {
relog.Error("failed starting, check %v", mt.config.ErrorLogPath())
return err
}
schemaPath := os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/data/bootstrap/_vt_schema.sql")
schemaPath := os.ExpandEnv("$VTROOT/data/bootstrap/_vt_schema.sql")
schema, err := ioutil.ReadFile(schemaPath)
if err != nil {
return err

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

@ -15,7 +15,6 @@ package tabletmanager
import (
"encoding/json"
"errors"
"flag"
"fmt"
"net"
@ -79,22 +78,12 @@ func (agent *ActionAgent) Tablet() *TabletInfo {
return tablet
}
// FIXME(msolomon) need a real path discovery mechanism, a config file
// or more command line args.
func (agent *ActionAgent) resolvePaths() error {
vtActionBinPaths := []string{
os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/go/cmd/vtaction/vtaction"),
os.ExpandEnv("$VTROOT/bin/vtaction"),
"/usr/local/bin/vtaction"}
for _, path := range vtActionBinPaths {
if _, err := os.Stat(path); err == nil {
agent.vtActionBinFile = path
break
}
}
if agent.vtActionBinFile == "" {
return errors.New("no vtaction binary found")
path := os.ExpandEnv("$VTROOT/bin/vtaction")
if _, err := os.Stat(path); err != nil {
return fmt.Errorf("vtaction binary %s not found: %v", path, err)
}
agent.vtActionBinFile = path
return nil
}

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

@ -32,6 +32,7 @@ def _add_proc(proc):
print >> f, proc.pid, os.path.basename(proc.args[0])
vttop = os.environ['VTTOP']
vtroot = os.environ['VTROOT']
hostname = socket.gethostname()
@ -126,11 +127,11 @@ def setup():
run('go build', cwd=vttop+'/go/cmd/zk')
# start mysql instance external to the test
setup_procs.append(run_bg(vttop+'/go/cmd/mysqlctl/mysqlctl -tablet-uid 62344 -port 6700 -mysql-port 3700 init'))
setup_procs.append(run_bg(vttop+'/go/cmd/mysqlctl/mysqlctl -tablet-uid 62044 -port 6701 -mysql-port 3701 init'))
setup_procs.append(run_bg(vttop+'/go/cmd/mysqlctl/mysqlctl -tablet-uid 41983 -port 6702 -mysql-port 3702 init'))
setup_procs.append(run_bg(vttop+'/go/cmd/mysqlctl/mysqlctl -tablet-uid 31981 -port 6703 -mysql-port 3703 init'))
setup_procs.append(run_bg(vttop+'/go/cmd/zkctl/zkctl -zk.cfg 1@'+hostname+':3801:3802:3803 init'))
setup_procs.append(run_bg(vtroot+'/bin/mysqlctl -tablet-uid 62344 -port 6700 -mysql-port 3700 init'))
setup_procs.append(run_bg(vtroot+'/bin/mysqlctl -tablet-uid 62044 -port 6701 -mysql-port 3701 init'))
setup_procs.append(run_bg(vtroot+'/bin/mysqlctl -tablet-uid 41983 -port 6702 -mysql-port 3702 init'))
setup_procs.append(run_bg(vtroot+'/bin/mysqlctl -tablet-uid 31981 -port 6703 -mysql-port 3703 init'))
setup_procs.append(run_bg(vtroot+'/bin/zkctl -zk.cfg 1@'+hostname+':3801:3802:3803 init'))
wait_procs(setup_procs)
with open('.test-zk-client-conf.json', 'w') as f:
@ -141,18 +142,18 @@ def setup():
json.dump(zk_cell_mapping, f)
os.putenv('ZK_CLIENT_CONFIG', '.test-zk-client-conf.json')
run(vttop+'/go/cmd/zk/zk touch -p /zk/test_nj/vt')
run(vttop+'/go/cmd/zk/zk touch -p /zk/test_ny/vt')
run(vttop+'/go/cmd/zk/zk touch -p /zk/test_ca/vt')
run(vtroot+'/bin/zk touch -p /zk/test_nj/vt')
run(vtroot+'/bin/zk touch -p /zk/test_ny/vt')
run(vtroot+'/bin/zk touch -p /zk/test_ca/vt')
def teardown():
if options.skip_teardown:
return
teardown_procs = []
for x in (62344, 62044, 41983, 31981):
teardown_procs.append(run_bg(vttop+'/go/cmd/mysqlctl/mysqlctl -tablet-uid %u -force teardown' % x))
teardown_procs.append(run_bg(vtroot+'/bin/mysqlctl -tablet-uid %u -force teardown' % x))
teardown_procs.append(run_bg(vttop+'/go/cmd/zkctl/zkctl -zk.cfg 1@'+hostname+':3801:3802:3803 teardown'))
teardown_procs.append(run_bg(vtroot+'/bin/zkctl -zk.cfg 1@'+hostname+':3801:3802:3803 teardown'))
wait_procs(teardown_procs, raise_on_error=False)
for proc in pid_map.values():
if proc.pid and proc.returncode is None:
@ -178,75 +179,75 @@ def teardown():
def run_test_sanity():
# Start up a master mysql and vttablet
run(vttop+'/go/cmd/vtctl/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
run(vtroot+'/bin/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace 0 master ""')
run(vttop+'/go/cmd/vtctl/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/0')
run(vttop+'/go/cmd/vtctl/vtctl Validate /zk/global/vt/keyspaces')
agent_62344 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace 0 master ""')
run(vtroot+'/bin/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/0')
run(vtroot+'/bin/vtctl Validate /zk/global/vt/keyspaces')
agent_62344 = run_bg(vtroot+'/bin/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
run(vttop+'/go/cmd/vtctl/vtctl Ping /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl Ping /zk/test_nj/vt/tablets/0000062344')
# Quickly check basic actions.
run(vttop+'/go/cmd/vtctl/vtctl SetReadOnly /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl SetReadOnly /zk/test_nj/vt/tablets/0000062344')
wait_db_read_only(62344)
run(vttop+'/go/cmd/vtctl/vtctl SetReadWrite /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl SetReadWrite /zk/test_nj/vt/tablets/0000062344')
check_db_read_write(62344)
run(vttop+'/go/cmd/vtctl/vtctl DemoteMaster /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl DemoteMaster /zk/test_nj/vt/tablets/0000062344')
wait_db_read_only(62344)
run(vttop+'/go/cmd/vtctl/vtctl Validate /zk/global/vt/keyspaces')
run(vtroot+'/bin/vtctl Validate /zk/global/vt/keyspaces')
agent_62344.kill()
def run_test_restart_during_action():
# Start up a master mysql and vttablet
run(vttop+'/go/cmd/vtctl/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
run(vtroot+'/bin/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace 0 master ""')
run(vttop+'/go/cmd/vtctl/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/0')
run(vttop+'/go/cmd/vtctl/vtctl Validate /zk/global/vt/keyspaces')
agent_62344 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace 0 master ""')
run(vtroot+'/bin/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/0')
run(vtroot+'/bin/vtctl Validate /zk/global/vt/keyspaces')
agent_62344 = run_bg(vtroot+'/bin/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
run(vttop+'/go/cmd/vtctl/vtctl Ping /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl Ping /zk/test_nj/vt/tablets/0000062344')
# schedule long action
run(vttop+'/go/cmd/vtctl/vtctl -no-wait Sleep /zk/test_nj/vt/tablets/0000062344 15s', stdout=devnull)
run(vtroot+'/bin/vtctl -no-wait Sleep /zk/test_nj/vt/tablets/0000062344 15s', stdout=devnull)
# ping blocks until the sleep finishes unless we have a schedule race
action_path, _ = run(vttop+'/go/cmd/vtctl/vtctl -no-wait Ping /zk/test_nj/vt/tablets/0000062344', trap_output=True)
action_path, _ = run(vtroot+'/bin/vtctl -no-wait Ping /zk/test_nj/vt/tablets/0000062344', trap_output=True)
# kill agent leaving vtaction running
agent_62344.kill()
# restart agent
agent_62344 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
agent_62344 = run_bg(vtroot+'/bin/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
# we expect this action with a short wait time to fail. this isn't the best
# and has some potential for flakiness.
run_fail(vttop+'/go/cmd/vtctl/vtctl -wait-time 2s WaitForAction ' + action_path)
run_fail(vtroot+'/bin/vtctl -wait-time 2s WaitForAction ' + action_path)
agent_62344.kill()
def _wipe_zk():
run(vttop+'/go/cmd/zk/zk rm -rf /zk/test_nj/vt')
run(vttop+'/go/cmd/zk/zk rm -rf /zk/test_ny/vt')
#run(vttop+'/go/cmd/zk/zk rm -rf /zk/test_ca/vt')
run(vttop+'/go/cmd/zk/zk rm -rf /zk/global/vt')
run(vtroot+'/bin/zk rm -rf /zk/test_nj/vt')
run(vtroot+'/bin/zk rm -rf /zk/test_ny/vt')
#run(vtroot+'/bin/zk rm -rf /zk/test_ca/vt')
run(vtroot+'/bin/zk rm -rf /zk/global/vt')
def _check_zk(ping_tablets=False):
if ping_tablets:
run(vttop+'/go/cmd/vtctl/vtctl -ping-tablets Validate /zk/global/vt/keyspaces')
run(vtroot+'/bin/vtctl -ping-tablets Validate /zk/global/vt/keyspaces')
else:
run(vttop+'/go/cmd/vtctl/vtctl Validate /zk/global/vt/keyspaces')
run(vtroot+'/bin/vtctl Validate /zk/global/vt/keyspaces')
def _check_db_addr(db_addr, expected_addr):
# Run in the background to capture output.
proc = run_bg(vttop+'/go/cmd/vtctl/vtctl -zk.local-cell=test_nj Resolve ' + db_addr, stdout=PIPE)
proc = run_bg(vtroot+'/bin/vtctl -zk.local-cell=test_nj Resolve ' + db_addr, stdout=PIPE)
stdout = proc.communicate()[0].strip()
if stdout != expected_addr:
raise TestError('wrong zk address', db_addr, stdout, expected_addr)
@ -255,27 +256,27 @@ def _check_db_addr(db_addr, expected_addr):
def run_test_reparent_down_master():
_wipe_zk()
run(vttop+'/go/cmd/vtctl/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
run(vtroot+'/bin/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
# Start up a master mysql and vttablet
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace 0 master ""')
agent_62344 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace 0 master ""')
agent_62344 = run_bg(vtroot+'/bin/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
# Create a few slaves for testing reparenting.
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062044 localhost 3701 6701 test_keyspace 0 replica /zk/global/vt/keyspaces/test_keyspace/shards/0/test_nj-62344')
agent_62044 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6701 -tablet-path /zk/test_nj/vt/tablets/0000062044 -logfile /vt/vt_0000062044/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062044 localhost 3701 6701 test_keyspace 0 replica /zk/global/vt/keyspaces/test_keyspace/shards/0/test_nj-62344')
agent_62044 = run_bg(vtroot+'/bin/vttablet -port 6701 -tablet-path /zk/test_nj/vt/tablets/0000062044 -logfile /vt/vt_0000062044/vttablet.log')
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000041983 localhost 3702 6702 test_keyspace 0 replica /zk/global/vt/keyspaces/test_keyspace/shards/0/test_nj-62344')
agent_41983 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6702 -tablet-path /zk/test_nj/vt/tablets/0000041983 -logfile /vt/vt_0000041983/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000041983 localhost 3702 6702 test_keyspace 0 replica /zk/global/vt/keyspaces/test_keyspace/shards/0/test_nj-62344')
agent_41983 = run_bg(vtroot+'/bin/vttablet -port 6702 -tablet-path /zk/test_nj/vt/tablets/0000041983 -logfile /vt/vt_0000041983/vttablet.log')
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_ny/vt/tablets/0000031981 localhost 3703 6703 test_keyspace 0 replica /zk/global/vt/keyspaces/test_keyspace/shards/0/test_nj-62344')
agent_31983 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6703 -tablet-path /zk/test_ny/vt/tablets/0000031981 -logfile /vt/vt_0000031981/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_ny/vt/tablets/0000031981 localhost 3703 6703 test_keyspace 0 replica /zk/global/vt/keyspaces/test_keyspace/shards/0/test_nj-62344')
agent_31983 = run_bg(vtroot+'/bin/vttablet -port 6703 -tablet-path /zk/test_ny/vt/tablets/0000031981 -logfile /vt/vt_0000031981/vttablet.log')
# Recompute the shard layout node - until you do that, it might not be valid.
run(vttop+'/go/cmd/vtctl/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/0')
run(vtroot+'/bin/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/0')
_check_zk()
# Force the slaves to reparent assuming that all the datasets are identical.
run(vttop+'/go/cmd/vtctl/vtctl -force ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/0 /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl -force ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/0 /zk/test_nj/vt/tablets/0000062344')
_check_zk()
# Make the master agent unavailable.
@ -286,33 +287,33 @@ def run_test_reparent_down_master():
_check_db_addr('test_keyspace.0.master:_vtocc', expected_addr)
# Perform a reparent operation - this will hang for some amount of time.
run_fail(vttop+'/go/cmd/vtctl/vtctl -wait-time 5s ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/0 /zk/test_nj/vt/tablets/0000062044')
run_fail(vtroot+'/bin/vtctl -wait-time 5s ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/0 /zk/test_nj/vt/tablets/0000062044')
# Should timeout and fail
run_fail(vttop+'/go/cmd/vtctl/vtctl -wait-time 5s ScrapTablet /zk/test_nj/vt/tablets/0000062344')
run_fail(vtroot+'/bin/vtctl -wait-time 5s ScrapTablet /zk/test_nj/vt/tablets/0000062344')
# Force the scrap action in zk even though tablet is not accessible.
run(vttop+'/go/cmd/vtctl/vtctl -force ScrapTablet /zk/test_nj/vt/tablets/0000062344')
run(vtroot+'/bin/vtctl -force ScrapTablet /zk/test_nj/vt/tablets/0000062344')
run_fail(vttop+'/go/cmd/vtctl/vtctl -force ChangeType /zk/test_nj/vt/tablets/0000062344 idle')
run_fail(vtroot+'/bin/vtctl -force ChangeType /zk/test_nj/vt/tablets/0000062344 idle')
# Remove pending locks (make this the force option to ReparentShard?)
run(vttop+'/go/cmd/vtctl/vtctl -force PurgeActions /zk/global/vt/keyspaces/test_keyspace/shards/0/action')
run(vtroot+'/bin/vtctl -force PurgeActions /zk/global/vt/keyspaces/test_keyspace/shards/0/action')
# Scrapping a tablet shouldn't take it out of the serving graph.
expected_addr = hostname + ':6700'
_check_db_addr('test_keyspace.0.master:_vtocc', expected_addr)
# Re-run reparent operation, this shoud now proceed unimpeded.
run(vttop+'/go/cmd/vtctl/vtctl ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/0 /zk/test_nj/vt/tablets/0000062044')
run(vtroot+'/bin/vtctl ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/0 /zk/test_nj/vt/tablets/0000062044')
_check_zk()
expected_addr = hostname + ':6701'
_check_db_addr('test_keyspace.0.master:_vtocc', expected_addr)
run(vttop+'/go/cmd/vtctl/vtctl -force ChangeType /zk/test_nj/vt/tablets/0000062344 idle')
run(vtroot+'/bin/vtctl -force ChangeType /zk/test_nj/vt/tablets/0000062344 idle')
idle_tablets, _ = run(vttop+'/go/cmd/vtctl/vtctl ListIdle /zk/test_nj/vt', trap_output=True)
idle_tablets, _ = run(vtroot+'/bin/vtctl ListIdle /zk/test_nj/vt', trap_output=True)
if '0000062344' not in idle_tablets:
raise TestError('idle tablet not found', idle_tablets)
@ -332,28 +333,28 @@ def run_test_reparent_graceful():
def _run_test_reparent_graceful(shard_id):
_wipe_zk()
run(vttop+'/go/cmd/vtctl/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
run(vtroot+'/bin/vtctl -force CreateKeyspace /zk/global/vt/keyspaces/test_keyspace')
# Start up a master mysql and vttablet
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace %(shard_id)s master ""' % vars())
agent_62344 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062344 localhost 3700 6700 test_keyspace %(shard_id)s master ""' % vars())
agent_62344 = run_bg(vtroot+'/bin/vttablet -port 6700 -tablet-path /zk/test_nj/vt/tablets/0000062344 -logfile /vt/vt_0000062344/vttablet.log')
# Create a few slaves for testing reparenting.
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062044 localhost 3701 6701 test_keyspace %(shard_id)s replica /zk/global/vt/keyspaces/test_keyspace/shards/%(shard_id)s/test_nj-62344' % vars())
agent_62044 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6701 -tablet-path /zk/test_nj/vt/tablets/0000062044 -logfile /vt/vt_0000062044/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000062044 localhost 3701 6701 test_keyspace %(shard_id)s replica /zk/global/vt/keyspaces/test_keyspace/shards/%(shard_id)s/test_nj-62344' % vars())
agent_62044 = run_bg(vtroot+'/bin/vttablet -port 6701 -tablet-path /zk/test_nj/vt/tablets/0000062044 -logfile /vt/vt_0000062044/vttablet.log')
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000041983 localhost 3702 6702 test_keyspace %(shard_id)s replica /zk/global/vt/keyspaces/test_keyspace/shards/%(shard_id)s/test_nj-62344' % vars())
agent_41983 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6702 -tablet-path /zk/test_nj/vt/tablets/0000041983 -logfile /vt/vt_0000041983/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_nj/vt/tablets/0000041983 localhost 3702 6702 test_keyspace %(shard_id)s replica /zk/global/vt/keyspaces/test_keyspace/shards/%(shard_id)s/test_nj-62344' % vars())
agent_41983 = run_bg(vtroot+'/bin/vttablet -port 6702 -tablet-path /zk/test_nj/vt/tablets/0000041983 -logfile /vt/vt_0000041983/vttablet.log')
run(vttop+'/go/cmd/vtctl/vtctl -force InitTablet /zk/test_ny/vt/tablets/0000031981 localhost 3703 6703 test_keyspace %(shard_id)s replica /zk/global/vt/keyspaces/test_keyspace/shards/%(shard_id)s/test_nj-62344' % vars())
agent_31983 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6703 -tablet-path /zk/test_ny/vt/tablets/0000031981 -logfile /vt/vt_0000031981/vttablet.log')
run(vtroot+'/bin/vtctl -force InitTablet /zk/test_ny/vt/tablets/0000031981 localhost 3703 6703 test_keyspace %(shard_id)s replica /zk/global/vt/keyspaces/test_keyspace/shards/%(shard_id)s/test_nj-62344' % vars())
agent_31983 = run_bg(vtroot+'/bin/vttablet -port 6703 -tablet-path /zk/test_ny/vt/tablets/0000031981 -logfile /vt/vt_0000031981/vttablet.log')
# Recompute the shard layout node - until you do that, it might not be valid.
run(vttop+'/go/cmd/vtctl/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/' + shard_id)
run(vtroot+'/bin/vtctl RebuildShard /zk/global/vt/keyspaces/test_keyspace/shards/' + shard_id)
_check_zk()
# Force the slaves to reparent assuming that all the datasets are identical.
pause("force ReparentShard?")
run(vttop+'/go/cmd/vtctl/vtctl -force ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/%s /zk/test_nj/vt/tablets/0000062344' % shard_id)
run(vtroot+'/bin/vtctl -force ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/%s /zk/test_nj/vt/tablets/0000062344' % shard_id)
_check_zk(ping_tablets=True)
expected_addr = hostname + ':6700'
@ -361,14 +362,14 @@ def _run_test_reparent_graceful(shard_id):
# Convert a replica to a spare. That should leave only one node serving traffic,
# but still needs to appear in the replication graph.
run(vttop+'/go/cmd/vtctl/vtctl ChangeType /zk/test_nj/vt/tablets/0000041983 spare')
run(vtroot+'/bin/vtctl ChangeType /zk/test_nj/vt/tablets/0000041983 spare')
_check_zk()
expected_addr = hostname + ':6701'
_check_db_addr('test_keyspace.%s.replica:_vtocc' % shard_id, expected_addr)
# Perform a graceful reparent operation.
pause("graceful ReparentShard?")
run(vttop+'/go/cmd/vtctl/vtctl ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/%s /zk/test_nj/vt/tablets/0000062044' % shard_id)
run(vtroot+'/bin/vtctl ReparentShard /zk/global/vt/keyspaces/test_keyspace/shards/%s /zk/test_nj/vt/tablets/0000062044' % shard_id)
_check_zk()
expected_addr = hostname + ':6701'
@ -380,7 +381,7 @@ def _run_test_reparent_graceful(shard_id):
agent_31983.kill()
# Test address correction.
agent_62044 = run_bg(vttop+'/go/cmd/vttablet/vttablet -port 6773 -tablet-path /zk/test_nj/vt/tablets/0000062044 -logfile /vt/vt_0000062044/vttablet.log')
agent_62044 = run_bg(vtroot+'/bin/vttablet -port 6773 -tablet-path /zk/test_nj/vt/tablets/0000062044 -logfile /vt/vt_0000062044/vttablet.log')
# Wait a moment for address to reregister.
time.sleep(1.0)

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

@ -57,29 +57,14 @@ func (zkd *Zkd) Start() error {
relog.Info("zkctl.Start")
// NOTE(msolomon) use a script here so we can detach and continue to run
// if the wrangler process dies. this pretty much the same as mysqld_safe.
dirs := []string{
os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/go/zk/zkctl"),
os.ExpandEnv("$VTROOT/bin"),
os.ExpandEnv("/usr/local/bin"),
}
var name string
var dir string
for _, dir = range dirs {
name = path.Join(dir, "zksrv.sh")
if _, statErr := os.Stat(name); statErr == nil {
break
}
}
args := []string{
zkd.config.LogDir(),
zkd.config.ConfigFile(),
zkd.config.PidFile(),
}
cmd := exec.Command(name, args...)
dir := os.ExpandEnv("$VTROOT/bin")
cmd := exec.Command(path.Join(dir, "zksrv.sh"), args...)
cmd.Env = os.Environ()
cmd.Dir = dir
@ -132,13 +117,8 @@ func (zkd *Zkd) Shutdown() error {
}
func (zkd *Zkd) makeCfg() (string, error) {
cnfTemplatePaths := []string{
os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/config/zkcfg/zoo.cfg"),
os.ExpandEnv("$VTROOT/share/vt/zkcfg/zoo.cfg"),
os.ExpandEnv("/usr/local/share/vt/zkcfg/zoo.cfg"),
}
return MakeZooCfg(cnfTemplatePaths, zkd.config,
"# generated by vt")
cnfTemplatePaths := []string{os.ExpandEnv("$VTROOT/config/zkcfg/zoo.cfg")}
return MakeZooCfg(cnfTemplatePaths, zkd.config, "# generated by vt")
}
func (zkd *Zkd) ConfigChanged() (bool, error) {

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

@ -26,7 +26,7 @@ class BareOCCConnection(db.VtOCCConnection):
class TestAuthentication(unittest.TestCase):
vttop = os.getenv("VTTOP")
vtroot = os.getenv("VTROOT")
def setUp(self):
for i in range(30):
@ -48,7 +48,7 @@ class TestAuthentication(unittest.TestCase):
klass.credentials = json.load(f)
klass.vtstderr = open("/tmp/vtocc_stderr.log", "a+")
klass.process = subprocess.Popen([klass.vttop +"/go/cmd/vtocc/vtocc",
klass.process = subprocess.Popen([klass.vtroot +"/bin/vtocc",
"-port", "9461",
"-auth-credentials", authcredentials,
"-dbconfig", dbconfig,

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

@ -3,6 +3,8 @@
# be found in the LICENSE file.
import os
import shlex
from subprocess import check_call, Popen, CalledProcessError, PIPE
import traceback
class MultiDict(dict):
@ -107,3 +109,19 @@ class Tailer(object):
size = newpos-self.pos
self.pos = newpos
return self.f.read(size)
# FIXME: Hijacked from go/vt/tabletserver/test.py
# Reuse when things come together
def execute(cmd, trap_output=False, verbose=False, **kargs):
args = shlex.split(cmd)
if trap_output:
kargs['stdout'] = PIPE
kargs['stderr'] = PIPE
if verbose:
print "Execute:", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems())
proc = Popen(args, **kargs)
proc.args = args
stdout, stderr = proc.communicate()
if proc.returncode:
raise TestError('cmd fail:', args, stdout, stderr)
return stdout, stderr

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

@ -37,7 +37,10 @@ class TestEnv(object):
vttop = os.getenv("VTTOP")
if vttop is None:
raise Exception("VTTOP not defined")
occpath = vttop+"/go/cmd/vtocc/"
vtroot = os.getenv("VTROOT")
if vtroot is None:
raise Exception("VTROOT not defined")
framework.execute('go build', verbose=options.verbose, cwd=vttop+'/go/cmd/vtocc')
with open(options.dbconfig) as f:
self.cfg = json.load(f)
@ -66,7 +69,7 @@ class TestEnv(object):
if self.cfg.get("memcache"):
self.memcached = subprocess.Popen(["memcached", "-s", self.cfg["memcache"]])
occ_args = [
vttop+"/go/cmd/vtocc/vtocc",
vtroot+"/bin/vtocc",
"-port", "9461",
"-dbconfig", options.dbconfig,
"-logfile", LOGFILE,