|
|
|
@ -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)
|
|
|
|
|
|
|
|
|
|