Skip to content

Commit

Permalink
Replacing all python %u by %d. Apparently it's what we need to do now.
Browse files Browse the repository at this point in the history
  • Loading branch information
alainjobart committed Aug 7, 2015
1 parent 612d4a0 commit ad4dcbd
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 103 deletions.
4 changes: 2 additions & 2 deletions py/zk/zkocc.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def _call(self, client_method, *args, **kwargs):
return getattr(self.simple_conn, client_method)(*args, **kwargs)
except Exception as e:
attempt += 1
logging.warning('zkocc: %s command failed %u times: %s', client_method, attempt, e)
logging.warning('zkocc: %s command failed %d times: %s', client_method, attempt, e)
if attempt >= self.max_attempts:
raise ZkOccError('zkocc %s command failed %u times: %s' % (client_method, attempt, e))
raise ZkOccError('zkocc %s command failed %d times: %s' % (client_method, attempt, e))

# try the next server if there is one, or retry our only server
self.dial()
Expand Down
8 changes: 4 additions & 4 deletions test/custom_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _insert_data(self, shard, start, count, table='data'):
for x in xrange(count):
bindvars = {
'id': start+x,
'name': 'row %u' % (start+x),
'name': 'row %d' % (start+x),
}
utils.vtgate.execute_shard(sql, 'test_keyspace', shard,
bindvars=bindvars)
Expand All @@ -77,7 +77,7 @@ def _check_data(self, shard, start, count, table='data'):
bindvars=bindvars)
self.assertEqual(len(qr['Rows']), 1)
v = qr['Rows'][0][0]
self.assertEqual(v, 'row %u' % (start+x))
self.assertEqual(v, 'row %d' % (start+x))

def test_custom_end_to_end(self):
"""This test case runs through the common operations of a custom
Expand Down Expand Up @@ -200,8 +200,8 @@ def test_custom_end_to_end(self):
self.assertEqual(len(rows), 20)
expected = {}
for i in xrange(10):
expected[100+i] = 'row %u' % (100+i)
expected[200+i] = 'row %u' % (200+i)
expected[100+i] = 'row %d' % (100+i)
expected[200+i] = 'row %d' % (200+i)
self.assertEqual(rows, expected)

if __name__ == '__main__':
Expand Down
28 changes: 14 additions & 14 deletions test/initial_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _mark_sharding_key_not_null(self):
def _insert_startup_value(self, tablet, table, id, msg):
tablet.mquery('vt_test_keyspace', [
'begin',
'insert into %s(id, msg) values(%u, "%s")' % (table, id, msg),
'insert into %s(id, msg) values(%d, "%s")' % (table, id, msg),
'commit'
], write=True)

Expand All @@ -166,15 +166,15 @@ def _insert_value(self, tablet, table, id, msg, keyspace_id):
if keyspace_id_type == keyrange_constants.KIT_BYTES:
k = base64.b64encode(pack_keyspace_id(keyspace_id))
else:
k = "%u" % keyspace_id
k = "%d" % keyspace_id
tablet.mquery('vt_test_keyspace', [
'begin',
'insert into %s(id, msg, keyspace_id) values(%u, "%s", 0x%x) /* EMD keyspace_id:%s user_id:%u */' % (table, id, msg, keyspace_id, k, id),
'insert into %s(id, msg, keyspace_id) values(%d, "%s", 0x%x) /* EMD keyspace_id:%s user_id:%d */' % (table, id, msg, keyspace_id, k, id),
'commit'
], write=True)

def _get_value(self, tablet, table, id):
return tablet.mquery('vt_test_keyspace', 'select id, msg, keyspace_id from %s where id=%u' % (table, id))
return tablet.mquery('vt_test_keyspace', 'select id, msg, keyspace_id from %s where id=%d' % (table, id))

def _check_value(self, tablet, table, id, msg, keyspace_id,
should_be_here=True):
Expand All @@ -186,12 +186,12 @@ def _check_value(self, tablet, table, id, msg, keyspace_id,
fmt = "%x"
if should_be_here:
self.assertEqual(result, ((id, msg, keyspace_id),),
("Bad row in tablet %s for id=%u, keyspace_id=" +
("Bad row in tablet %s for id=%d, keyspace_id=" +
fmt + ", row=%s") % (tablet.tablet_alias, id,
keyspace_id, str(result)))
else:
self.assertEqual(len(result), 0,
("Extra row in tablet %s for id=%u, keyspace_id=" +
("Extra row in tablet %s for id=%d, keyspace_id=" +
fmt + ": %s") % (tablet.tablet_alias, id, keyspace_id,
str(result)))

Expand All @@ -209,7 +209,7 @@ def _is_value_present_and_correct(self, tablet, table, id, msg, keyspace_id):
else:
fmt = "%x"
self.assertEqual(result, ((id, msg, keyspace_id),),
("Bad row in tablet %s for id=%u, keyspace_id=" + fmt) % (
("Bad row in tablet %s for id=%d, keyspace_id=" + fmt) % (
tablet.tablet_alias, id, keyspace_id))
return True

Expand Down Expand Up @@ -238,24 +238,24 @@ def _check_startup_values(self):
def _insert_lots(self, count, base=0):
for i in xrange(count):
self._insert_value(shard_master, 'resharding1', 10000 + base + i,
'msg-range1-%u' % i, 0xA000000000000000 + base + i)
'msg-range1-%d' % i, 0xA000000000000000 + base + i)
self._insert_value(shard_master, 'resharding1', 20000 + base + i,
'msg-range2-%u' % i, 0xE000000000000000 + base + i)
'msg-range2-%d' % i, 0xE000000000000000 + base + i)

# _check_lots returns how many of the values we have, in percents.
def _check_lots(self, count, base=0):
found = 0
for i in xrange(count):
if self._is_value_present_and_correct(shard_1_replica, 'resharding1',
10000 + base + i, 'msg-range1-%u' %
10000 + base + i, 'msg-range1-%d' %
i, 0xA000000000000000 + base + i):
found += 1
if self._is_value_present_and_correct(shard_1_replica, 'resharding1',
20000 + base + i, 'msg-range2-%u' %
20000 + base + i, 'msg-range2-%d' %
i, 0xE000000000000000 + base + i):
found += 1
percent = found * 100 / count / 2
logging.debug("I have %u%% of the data", percent)
logging.debug("I have %d%% of the data", percent)
return percent

def _check_lots_timeout(self, count, threshold, timeout, base=0):
Expand All @@ -270,10 +270,10 @@ def _check_lots_not_present(self, count, base=0):
found = 0
for i in xrange(count):
self._check_value(shard_0_replica, 'resharding1', 10000 + base + i,
'msg-range1-%u' % i, 0xA000000000000000 + base + i,
'msg-range1-%d' % i, 0xA000000000000000 + base + i,
should_be_here=False)
self._check_value(shard_0_replica, 'resharding1', 20000 + base + i,
'msg-range2-%u' % i, 0xE000000000000000 + base + i,
'msg-range2-%d' % i, 0xE000000000000000 + base + i,
should_be_here=False)

def test_resharding(self):
Expand Down
4 changes: 2 additions & 2 deletions test/mysql_flavor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def change_master_commands(self, host, port, pos):
(_flavor, gtid) = pos.split("/")
return [
"SET GLOBAL gtid_slave_pos = '%s'" % gtid,
"CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%u, "
"CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d, "
"MASTER_USER='vt_repl', MASTER_USE_GTID = slave_pos" %
(host, port)]

Expand Down Expand Up @@ -143,7 +143,7 @@ def change_master_commands(self, host, port, pos):
return [
"RESET MASTER",
"SET GLOBAL gtid_purged = '%s'" % gtid,
"CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%u, "
"CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d, "
"MASTER_USER='vt_repl', MASTER_AUTO_POSITION = 1" %
(host, port)]

Expand Down
2 changes: 1 addition & 1 deletion test/python_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TestPythonClient(unittest.TestCase):
CONNECT_TIMEOUT = 10.0

def setUp(self):
addr = 'localhost:%u' % vtgateclienttest_port
addr = 'localhost:%d' % vtgateclienttest_port
protocol = protocols_flavor().vtgate_python_protocol()
self.conn = vtgate_client.connect(protocol, addr, 30.0)

Expand Down
2 changes: 1 addition & 1 deletion test/reparent.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _check_db_addr(self, shard, db_type, expected_port, cell='test_nj'):
len(ep['entries']), 1, 'Wrong number of entries: %s' % str(ep))
port = ep['entries'][0]['port_map']['vt']
self.assertEqual(port, expected_port,
'Unexpected port: %u != %u from %s' % (port, expected_port,
'Unexpected port: %d != %d from %s' % (port, expected_port,
str(ep)))
host = ep['entries'][0]['host']
# Hostname was set explicitly to "localhost" with -tablet_hostname flag.
Expand Down
46 changes: 23 additions & 23 deletions test/resharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def __init__(self, tablet, object_name, user_id, keyspace_id):
if keyspace_id_type == keyrange_constants.KIT_BYTES:
self.str_keyspace_id = base64.b64encode(pack_keyspace_id(keyspace_id))
else:
self.str_keyspace_id = "%u" % keyspace_id
self.str_keyspace_id = "%d" % keyspace_id
self.done = False

self.tablet.mquery('vt_test_keyspace', [
'begin',
'insert into timestamps(name, time_milli, keyspace_id) values("%s", %u, 0x%x) /* EMD keyspace_id:%s user_id:%u */' %
'insert into timestamps(name, time_milli, keyspace_id) values("%s", %d, 0x%x) /* EMD keyspace_id:%s user_id:%d */' %
(self.object_name, long(time.time() * 1000), self.keyspace_id,
self.str_keyspace_id, self.user_id),
'commit'
Expand All @@ -144,7 +144,7 @@ def run(self):
while not self.done:
self.tablet.mquery('vt_test_keyspace', [
'begin',
'update timestamps set time_milli=%u where name="%s" /* EMD keyspace_id:%s user_id:%u */' % (long(time.time() * 1000), self.object_name, self.str_keyspace_id, self.user_id),
'update timestamps set time_milli=%d where name="%s" /* EMD keyspace_id:%s user_id:%d */' % (long(time.time() * 1000), self.object_name, self.str_keyspace_id, self.user_id),
'commit'
], write=True, user='vt_app')
time.sleep(0.2)
Expand Down Expand Up @@ -173,7 +173,7 @@ def run(self):
result = self.tablet.mquery('vt_test_keyspace', 'select time_milli from timestamps where name="%s"' % self.object_name)
if result:
lag = long(time.time() * 1000) - long(result[0][0])
logging.debug("MonitorLagThread(%s) got %u", self.object_name, lag)
logging.debug("MonitorLagThread(%s) got %d", self.object_name, lag)
self.sample_count += 1
self.lag_sum += lag
if lag > self.max_lag:
Expand Down Expand Up @@ -238,15 +238,15 @@ def _insert_value(self, tablet, table, id, msg, keyspace_id):
if keyspace_id_type == keyrange_constants.KIT_BYTES:
k = base64.b64encode(pack_keyspace_id(keyspace_id))
else:
k = "%u" % keyspace_id
k = "%d" % keyspace_id
tablet.mquery('vt_test_keyspace', [
'begin',
'insert into %s(id, msg, keyspace_id) values(%u, "%s", 0x%x) /* EMD keyspace_id:%s user_id:%u */' % (table, id, msg, keyspace_id, k, id),
'insert into %s(id, msg, keyspace_id) values(%d, "%s", 0x%x) /* EMD keyspace_id:%s user_id:%d */' % (table, id, msg, keyspace_id, k, id),
'commit'
], write=True)

def _get_value(self, tablet, table, id):
return tablet.mquery('vt_test_keyspace', 'select id, msg, keyspace_id from %s where id=%u' % (table, id))
return tablet.mquery('vt_test_keyspace', 'select id, msg, keyspace_id from %s where id=%d' % (table, id))

def _check_value(self, tablet, table, id, msg, keyspace_id,
should_be_here=True):
Expand All @@ -258,12 +258,12 @@ def _check_value(self, tablet, table, id, msg, keyspace_id,
fmt = "%x"
if should_be_here:
self.assertEqual(result, ((id, msg, keyspace_id),),
("Bad row in tablet %s for id=%u, keyspace_id=" +
("Bad row in tablet %s for id=%d, keyspace_id=" +
fmt + ", row=%s") % (tablet.tablet_alias, id,
keyspace_id, str(result)))
else:
self.assertEqual(len(result), 0,
("Extra row in tablet %s for id=%u, keyspace_id=" +
("Extra row in tablet %s for id=%d, keyspace_id=" +
fmt + ": %s") % (tablet.tablet_alias, id, keyspace_id,
str(result)))

Expand All @@ -281,7 +281,7 @@ def _is_value_present_and_correct(self, tablet, table, id, msg, keyspace_id):
else:
fmt = "%x"
self.assertEqual(result, ((id, msg, keyspace_id),),
("Bad row in tablet %s for id=%u, keyspace_id=" + fmt) % (
("Bad row in tablet %s for id=%d, keyspace_id=" + fmt) % (
tablet.tablet_alias, id, keyspace_id))
return True

Expand Down Expand Up @@ -335,24 +335,24 @@ def _check_startup_values(self):
def _insert_lots(self, count, base=0):
for i in xrange(count):
self._insert_value(shard_1_master, 'resharding1', 10000 + base + i,
'msg-range1-%u' % i, 0xA000000000000000 + base + i)
'msg-range1-%d' % i, 0xA000000000000000 + base + i)
self._insert_value(shard_1_master, 'resharding1', 20000 + base + i,
'msg-range2-%u' % i, 0xE000000000000000 + base + i)
'msg-range2-%d' % i, 0xE000000000000000 + base + i)

# _check_lots returns how many of the values we have, in percents.
def _check_lots(self, count, base=0):
found = 0
for i in xrange(count):
if self._is_value_present_and_correct(shard_2_replica2, 'resharding1',
10000 + base + i, 'msg-range1-%u' %
10000 + base + i, 'msg-range1-%d' %
i, 0xA000000000000000 + base + i):
found += 1
if self._is_value_present_and_correct(shard_3_replica, 'resharding1',
20000 + base + i, 'msg-range2-%u' %
20000 + base + i, 'msg-range2-%d' %
i, 0xE000000000000000 + base + i):
found += 1
percent = found * 100 / count / 2
logging.debug("I have %u%% of the data", percent)
logging.debug("I have %d%% of the data", percent)
return percent

def _check_lots_timeout(self, count, threshold, timeout, base=0):
Expand All @@ -361,8 +361,8 @@ def _check_lots_timeout(self, count, threshold, timeout, base=0):
if value >= threshold:
return
if timeout == 0:
self.fail("timeout waiting for %u%% of the data" % threshold)
logging.debug("sleeping until we get %u%%", threshold)
self.fail("timeout waiting for %d%% of the data" % threshold)
logging.debug("sleeping until we get %d%%", threshold)
time.sleep(1)
timeout -= 1

Expand All @@ -371,10 +371,10 @@ def _check_lots_not_present(self, count, base=0):
found = 0
for i in xrange(count):
self._check_value(shard_3_replica, 'resharding1', 10000 + base + i,
'msg-range1-%u' % i, 0xA000000000000000 + base + i,
'msg-range1-%d' % i, 0xA000000000000000 + base + i,
should_be_here=False)
self._check_value(shard_2_replica2, 'resharding1', 20000 + base + i,
'msg-range2-%u' % i, 0xE000000000000000 + base + i,
'msg-range2-%d' % i, 0xE000000000000000 + base + i,
should_be_here=False)

def _check_binlog_server_vars(self, tablet):
Expand All @@ -395,12 +395,12 @@ def _check_binlog_player_vars(self, tablet, seconds_behind_master_max = 0):
if seconds_behind_master_max != 0:
self.assertTrue(v['BinlogPlayerSecondsBehindMaster'] <
seconds_behind_master_max,
'BinlogPlayerSecondsBehindMaster is too high: %u > %u' % (
'BinlogPlayerSecondsBehindMaster is too high: %d > %d' % (
v['BinlogPlayerSecondsBehindMaster'],
seconds_behind_master_max))
self.assertTrue(v['BinlogPlayerSecondsBehindMasterMap']['0'] <
seconds_behind_master_max,
'BinlogPlayerSecondsBehindMasterMap is too high: %u > %u' % (
'BinlogPlayerSecondsBehindMasterMap is too high: %d > %d' % (
v['BinlogPlayerSecondsBehindMasterMap']['0'],
seconds_behind_master_max))

Expand Down Expand Up @@ -721,11 +721,11 @@ def test_resharding(self):
monitor_thread_2.done = True
insert_thread_1.done = True
insert_thread_2.done = True
logging.debug("DELAY 1: %s max_lag=%u avg_lag=%u",
logging.debug("DELAY 1: %s max_lag=%d avg_lag=%d",
monitor_thread_1.object_name,
monitor_thread_1.max_lag,
monitor_thread_1.lag_sum / monitor_thread_1.sample_count)
logging.debug("DELAY 2: %s max_lag=%u avg_lag=%u",
logging.debug("DELAY 2: %s max_lag=%d avg_lag=%d",
monitor_thread_2.object_name,
monitor_thread_2.max_lag,
monitor_thread_2.lag_sum / monitor_thread_2.sample_count)
Expand Down
12 changes: 6 additions & 6 deletions test/rowcache_invalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ def tearDown(self):
self.perform_delete()

def replica_stats(self):
url = 'http://localhost:%u/debug/table_stats' % replica_tablet.port
url = 'http://localhost:%d/debug/table_stats' % replica_tablet.port
return framework.MultiDict(json.load(urllib2.urlopen(url)))

def replica_vars(self):
url = 'http://localhost:%u/debug/vars' % replica_tablet.port
url = 'http://localhost:%d/debug/vars' % replica_tablet.port
return framework.MultiDict(json.load(urllib2.urlopen(url)))

def perform_insert(self, count):
Expand Down Expand Up @@ -212,12 +212,12 @@ def test_stop_replication(self):
for timeout in xrange(300):
time.sleep(0.1)
inv_count1 = self.replica_stats()['Totals']['Invalidations']
logging.debug('Got %u invalidations' % inv_count1)
logging.debug('Got %d invalidations' % inv_count1)
if inv_count1 == 100:
break
inv_count1 = self.replica_stats()['Totals']['Invalidations']
self.assertEqual(inv_count1, 100,
'Unexpected number of invalidations: %u' % inv_count1)
'Unexpected number of invalidations: %d' % inv_count1)

# stop replication insert more data, restart replication
replica_tablet.mquery('vt_test_keyspace', 'stop slave')
Expand All @@ -230,11 +230,11 @@ def test_stop_replication(self):
for timeout in xrange(300):
time.sleep(0.1)
inv_count2 = self.replica_stats()['Totals']['Invalidations']
logging.debug('Got %u invalidations' % inv_count2)
logging.debug('Got %d invalidations' % inv_count2)
if inv_count2 == 200:
break
inv_count2 = self.replica_stats()['Totals']['Invalidations']
self.assertEqual(inv_count2, 200, 'Unexpected number of invalidations: %u' %
self.assertEqual(inv_count2, 200, 'Unexpected number of invalidations: %d' %
inv_count2)

# check and display some stats
Expand Down
4 changes: 2 additions & 2 deletions test/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TestSchema(unittest.TestCase):
def setUp(self):
for t in tablets:
t.create_db(db_name)

def tearDown(self):
# This test assumes that it can reset the tablets by simply cleaning their
# databases without restarting the tablets.
Expand All @@ -126,7 +126,7 @@ def tearDown(self):
def _check_tables(self, tablet, expectedCount):
tables = tablet.mquery(db_name, 'show tables')
self.assertEqual(len(tables), expectedCount,
'Unexpected table count on %s (not %u): got tables: %s' %
'Unexpected table count on %s (not %d): got tables: %s' %
(tablet.tablet_alias, expectedCount, str(tables)))

def _check_db_not_created(self, tablet):
Expand Down
Loading

0 comments on commit ad4dcbd

Please sign in to comment.