From 71ada20a0e362db3cb5ce2a4afa753082f62f9cd Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Fri, 21 Feb 2020 21:36:48 +0100 Subject: [PATCH] qa/tasks: get rid of cStringIO for py3 Signed-off-by: Kyr Shatskyy --- qa/tasks/osd_failsafe_enospc.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/qa/tasks/osd_failsafe_enospc.py b/qa/tasks/osd_failsafe_enospc.py index 8d89919035dce..6aec322ea85b2 100644 --- a/qa/tasks/osd_failsafe_enospc.py +++ b/qa/tasks/osd_failsafe_enospc.py @@ -1,8 +1,9 @@ """ Handle osdfailsafe configuration settings (nearfull ratio and full ratio) """ -from cStringIO import StringIO +from io import BytesIO import logging +import six import time from teuthology.orchestra import run @@ -64,7 +65,7 @@ def task(ctx, config): 'ceph', '-w' ], stdin=run.PIPE, - stdout=StringIO(), + stdout=BytesIO(), wait=False, ) @@ -74,7 +75,7 @@ def task(ctx, config): proc.stdin.close() # causes daemon-helper send SIGKILL to ceph -w proc.wait() - lines = proc.stdout.getvalue().split('\n') + lines = six.ensure_str(proc.stdout.getvalue()).split('\n') count = len(filter(lambda line: '[WRN] OSD near full' in line, lines)) assert count == 2, 'Incorrect number of warning messages expected 2 got %d' % count @@ -92,7 +93,7 @@ def task(ctx, config): 'ceph', '-w' ], stdin=run.PIPE, - stdout=StringIO(), + stdout=BytesIO(), wait=False, ) @@ -102,7 +103,7 @@ def task(ctx, config): proc.stdin.close() # causes daemon-helper send SIGKILL to ceph -w proc.wait() - lines = proc.stdout.getvalue().split('\n') + lines = six.ensure_str(proc.stdout.getvalue()).split('\n') count = len(filter(lambda line: '[ERR] OSD full dropping all updates' in line, lines)) assert count == 2, 'Incorrect number of error messages expected 2 got %d' % count @@ -134,7 +135,7 @@ def task(ctx, config): 'ceph', '-w' ], stdin=run.PIPE, - stdout=StringIO(), + stdout=BytesIO(), wait=False, ) @@ -142,7 +143,7 @@ def task(ctx, config): proc.stdin.close() # causes daemon-helper send SIGKILL to ceph -w proc.wait() - lines = proc.stdout.getvalue().split('\n') + lines = six.ensure_str(proc.stdout.getvalue()).split('\n') count = len(filter(lambda line: '[WRN] OSD near full' in line, lines)) assert count == 1 or count == 2, 'Incorrect number of warning messages expected 1 or 2 got %d' % count @@ -163,7 +164,7 @@ def task(ctx, config): 'ceph', '-w' ], stdin=run.PIPE, - stdout=StringIO(), + stdout=BytesIO(), wait=False, ) @@ -173,7 +174,7 @@ def task(ctx, config): proc.stdin.close() # causes daemon-helper send SIGKILL to ceph -w proc.wait() - lines = proc.stdout.getvalue().split('\n') + lines = six.ensure_str(proc.stdout.getvalue()).split('\n') count = len(filter(lambda line: '[WRN] OSD near full' in line, lines)) assert count == 0, 'Incorrect number of warning messages expected 0 got %d' % count @@ -194,7 +195,7 @@ def task(ctx, config): 'ceph', '-w' ], stdin=run.PIPE, - stdout=StringIO(), + stdout=BytesIO(), wait=False, ) @@ -202,7 +203,7 @@ def task(ctx, config): proc.stdin.close() # causes daemon-helper send SIGKILL to ceph -w proc.wait() - lines = proc.stdout.getvalue().split('\n') + lines = six.ensure_str(proc.stdout.getvalue()).split('\n') count = len(filter(lambda line: '[WRN] OSD near full' in line, lines)) assert count == 0, 'Incorrect number of warning messages expected 0 got %d' % count -- 2.39.5