Skip to content

Commit

Permalink
Dont call decode
Browse files Browse the repository at this point in the history
Patch by marcuse; reviewed by Michael Shuler for CASSANDRA-14241
  • Loading branch information
krummas committed Feb 26, 2018
1 parent 3d0d0f4 commit 7fd89e1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bootstrap_test.py
Expand Up @@ -335,7 +335,7 @@ def test_resumable_bootstrap(self):
stdout, stderr, _ = node3.stress(['read', 'n=1k', 'no-warmup', '-schema', 'replication(factor=2)', '-rate', 'threads=8'])

if stdout is not None:
assert "FAILURE" not in stdout.decode("utf-8")
assert "FAILURE" not in stdout

@since('2.2')
def test_bootstrap_with_reset_bootstrap_state(self):
Expand Down
2 changes: 1 addition & 1 deletion meta_tests/assertion_test.py
Expand Up @@ -8,7 +8,7 @@
assert_invalid, assert_length_equal, assert_none,
assert_one, assert_row_count, assert_stderr_clean,
assert_unauthorized, assert_unavailable)

import pytest

class TestAssertStderrClean(TestCase):

Expand Down
20 changes: 10 additions & 10 deletions offline_tools_test.py
Expand Up @@ -54,7 +54,7 @@ def test_sstablelevelreset(self):

output, error, rc = node1.run_sstablelevelreset("keyspace1", "standard1")
self._check_stderr_error(error)
assert re.search("Found no sstables, did you give the correct keyspace", output.decode("utf-8"))
assert re.search("Found no sstables, did you give the correct keyspace", output)
assert rc == 0, str(rc)

# test by writing small amount of data and flushing (all sstables should be level 0)
Expand All @@ -67,8 +67,8 @@ def test_sstablelevelreset(self):
cluster.stop(gently=False)

output, error, rc = node1.run_sstablelevelreset("keyspace1", "standard1")
self._check_stderr_error(error.decode("utf-8"))
assert re.search("since it is already on level 0", output.decode("utf-8"))
self._check_stderr_error(error)
assert re.search("since it is already on level 0", output)
assert rc == 0, str(rc)

# test by loading large amount data so we have multiple levels and checking all levels are 0 at end
Expand All @@ -82,7 +82,7 @@ def test_sstablelevelreset(self):
initial_levels = self.get_levels(node1.run_sstablemetadata(keyspace="keyspace1", column_families=["standard1"]))
_, error, rc = node1.run_sstablelevelreset("keyspace1", "standard1")
final_levels = self.get_levels(node1.run_sstablemetadata(keyspace="keyspace1", column_families=["standard1"]))
self._check_stderr_error(error.decode("utf-8"))
self._check_stderr_error(error)
assert rc == 0, str(rc)

logger.debug(initial_levels)
Expand All @@ -96,7 +96,7 @@ def test_sstablelevelreset(self):

def get_levels(self, data):
(out, err, rc) = data
return list(map(int, re.findall("SSTable Level: ([0-9])", out.decode("utf-8"))))
return list(map(int, re.findall("SSTable Level: ([0-9])", out)))

def wait_for_compactions(self, node):
pattern = re.compile("pending tasks: 0")
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_sstableofflinerelevel(self):
try:
output, error, _ = node1.run_sstableofflinerelevel("keyspace1", "standard1")
except ToolError as e:
assert re.search("No sstables to relevel for keyspace1.standard1", e.stdout.decode("utf-8"))
assert re.search("No sstables to relevel for keyspace1.standard1", e.stdout)
assert e.exit_status == 1, str(e.exit_status)

# test by flushing (sstable should be level 0)
Expand All @@ -157,7 +157,7 @@ def test_sstableofflinerelevel(self):
cluster.stop()

output, _, rc = node1.run_sstableofflinerelevel("keyspace1", "standard1")
assert re.search("L0=1", output.decode("utf-8"))
assert re.search("L0=1", output)
assert rc == 0, str(rc)

cluster.start(wait_for_binary_proto=True)
Expand Down Expand Up @@ -254,7 +254,7 @@ def test_sstableverify(self):
# map over each line of out and replace Java-normalized paths with Python equivalents.
outlines = [re.sub("(?<=path=').*(?=')",
lambda match: os.path.normcase(match.group(0)),
line) for line in out.decode("utf-8").splitlines()]
line) for line in out.splitlines()]

# check output is correct for each sstable
sstables = self._get_final_sstables(node1, "keyspace1", "standard1")
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_sstableexpiredblockers(self):
session.execute("delete from ks.cf where key = 3")
node1.flush()
out, error, _ = node1.run_sstableexpiredblockers(keyspace="ks", column_family="cf")
assert "blocks 2 expired sstables from getting dropped" in out.decode("utf-8")
assert "blocks 2 expired sstables from getting dropped" in out

# 4.0 removes back compatibility with pre-3.0 versions, so testing upgradesstables for
# paths from those versions to 4.0 is invalid (and can only fail). There isn't currently
Expand Down Expand Up @@ -467,7 +467,7 @@ def _get_final_sstables(self, node, ks, table):
env = common.make_cassandra_env(node.get_install_cassandra_root(), node.get_node_cassandra_root())
p = subprocess.Popen(args, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
tmpsstables = list(map(os.path.normcase, stdout.decode("utf-8").splitlines()))
tmpsstables = list(map(os.path.normcase, stdout.splitlines()))

ret = list(set(allsstables) - set(tmpsstables))
else:
Expand Down
12 changes: 6 additions & 6 deletions repair_tests/incremental_repair_test.py
Expand Up @@ -50,7 +50,7 @@ def _get_repaired_data(cls, node, keyspace):
out = node.run_sstablemetadata(keyspace=keyspace).stdout

def matches(pattern):
return filter(None, [pattern.match(l) for l in out.decode("utf-8").split('\n')])
return filter(None, [pattern.match(l) for l in out.split('\n')])
names = [m.group(1) for m in matches(_sstable_name)]
repaired_times = [int(m.group(1)) for m in matches(_repaired_at)]

Expand Down Expand Up @@ -360,7 +360,7 @@ def test_sstable_marking(self):
node.nodetool('compact keyspace1 standard1')

for out in (node.run_sstablemetadata(keyspace='keyspace1').stdout for node in self.cluster.nodelist()):
assert 'Repaired at: 0' not in out.decode("utf-8")
assert 'Repaired at: 0' not in out

def test_multiple_repair(self):
"""
Expand Down Expand Up @@ -468,8 +468,8 @@ def test_sstable_repairedset(self):
node2.run_sstablerepairedset(keyspace='keyspace1')
node2.start(wait_for_binary_proto=True)

initialOut1 = node1.run_sstablemetadata(keyspace='keyspace1').stdout.decode("utf-8")
initialOut2 = node2.run_sstablemetadata(keyspace='keyspace1').stdout.decode("utf-8")
initialOut1 = node1.run_sstablemetadata(keyspace='keyspace1').stdout
initialOut2 = node2.run_sstablemetadata(keyspace='keyspace1').stdout

matches = findall('(?<=Repaired at:).*', '\n'.join([initialOut1, initialOut2]))
logger.debug("Repair timestamps are: {}".format(matches))
Expand Down Expand Up @@ -500,10 +500,10 @@ def test_sstable_repairedset(self):

finalOut1 = node1.run_sstablemetadata(keyspace='keyspace1').stdout
if not isinstance(finalOut1, str):
finalOut1 = finalOut1.decode("utf-8")
finalOut1 = finalOut1
finalOut2 = node2.run_sstablemetadata(keyspace='keyspace1').stdout
if not isinstance(finalOut2, str):
finalOut2 = finalOut2.decode("utf-8")
finalOut2 = finalOut2

matches = findall('(?<=Repaired at:).*', '\n'.join([finalOut1, finalOut2]))

Expand Down
2 changes: 1 addition & 1 deletion tools/assertions.py
Expand Up @@ -285,7 +285,7 @@ def assert_stderr_clean(err, acceptable_errors=None):
"Failed to connect over JMX; not collecting these stats"]

regex_str = "^({}|\s*|\n)*$".format("|".join(acceptable_errors))
err_str = err.decode("utf-8").strip()
err_str = err.strip()
# empty string, as good as we can get for a clean stderr output!
if not err_str:
return
Expand Down

0 comments on commit 7fd89e1

Please sign in to comment.