def stderr(msg):
- return _Write(prefix=yellow(' stderr: ')).raw(msg)
+ return _Write(prefix=yellow(' stderr: '), _writer=sys.stderr).raw(msg)
def write(msg):
def error(msg):
- return _Write(prefix=red_arrow).raw(msg)
+ return _Write(prefix=red_arrow, _writer=sys.stderr).raw(msg)
def info(msg):
- return _Write(prefix=blue_arrow).raw(msg)
+ return _Write(prefix=blue_arrow, _writer=sys.stderr).raw(msg)
def debug(msg):
- return _Write(prefix=blue_arrow).raw(msg)
+ return _Write(prefix=blue_arrow, _writer=sys.stderr).raw(msg)
def warning(msg):
- return _Write(prefix=yellow_arrow).raw(msg)
+ return _Write(prefix=yellow_arrow, _writer=sys.stderr).raw(msg)
def success(msg):
activation = activate.Activate(args)
activation.main()
out, err = capsys.readouterr()
- assert 'Was unable to find any OSDs to activate' in out
- assert 'Verify OSDs are present with ' in out
+ assert 'Was unable to find any OSDs to activate' in err
+ assert 'Verify OSDs are present with ' in err
def test_detects_running_osds(self, capsys, is_root, capture, monkeypatch):
monkeypatch.setattr('ceph_volume.devices.lvm.activate.direct_report', lambda: direct_report)
activation = activate.Activate(args)
activation.main()
out, err = capsys.readouterr()
- assert 'a8789a96ce8b process is active. Skipping activation' in out
- assert 'b8218eaa1634 process is active. Skipping activation' in out
+ assert 'a8789a96ce8b process is active. Skipping activation' in err
+ assert 'b8218eaa1634 process is active. Skipping activation' in err
def test_detects_osds_to_activate(self, is_root, capture, monkeypatch):
monkeypatch.setattr('ceph_volume.devices.lvm.activate.direct_report', lambda: direct_report)
device_info()
with pytest.raises(SystemExit):
lvm.create.Create(argv=['--data', '/dev/sdfoo', '--filestore', '--bluestore']).main()
- stdout, sterr = capsys.readouterr()
+ stdout, stderr = capsys.readouterr()
expected = 'Cannot use --filestore (filestore) with --bluestore (bluestore)'
- assert expected in stdout
+ assert expected in stderr
def test_excludes_other_filestore_bluestore_flags(self, capsys, device_info):
device_info()
'--bluestore', '--data', '/dev/sdfoo',
'--journal', '/dev/sf14',
]).main()
- stdout, sterr = capsys.readouterr()
+ stdout, stderr = capsys.readouterr()
expected = 'Cannot use --bluestore (bluestore) with --journal (filestore)'
- assert expected in stdout
+ assert expected in stderr
def test_excludes_block_and_journal_flags(self, capsys, device_info):
device_info()
'--bluestore', '--data', '/dev/sdfoo', '--block.db', 'vg/ceph1',
'--journal', '/dev/sf14',
]).main()
- stdout, sterr = capsys.readouterr()
+ stdout, stderr = capsys.readouterr()
expected = 'Cannot use --block.db (bluestore) with --journal (filestore)'
- assert expected in stdout
+ assert expected in stderr
lvm.prepare.Prepare(argv=['--data', '/dev/sdfoo', '--filestore', '--bluestore']).main()
stdout, stderr = capsys.readouterr()
expected = 'Cannot use --filestore (filestore) with --bluestore (bluestore)'
- assert expected in stdout
+ assert expected in stderr
def test_excludes_other_filestore_bluestore_flags(self, capsys, device_info):
device_info()
]).main()
stdout, stderr = capsys.readouterr()
expected = 'Cannot use --bluestore (bluestore) with --journal (filestore)'
- assert expected in stdout
+ assert expected in stderr
def test_excludes_block_and_journal_flags(self, capsys, device_info):
device_info()
]).main()
stdout, stderr = capsys.readouterr()
expected = 'Cannot use --block.db (bluestore) with --journal (filestore)'
- assert expected in stdout
+ assert expected in stderr
def test_journal_is_required_with_filestore(self, is_root, monkeypatch, device_info):
monkeypatch.setattr("os.path.exists", lambda path: True)
activation.activate = lambda x: True
activation.main()
activation.enable_systemd_units('0', '1234')
- out, err = capsys.readouterr()
- assert 'Skipping enabling of `simple`' in out
- assert 'Skipping masking of ceph-disk' in out
- assert 'Skipping enabling and starting OSD simple' in out
+ stdout, stderr = capsys.readouterr()
+ assert 'Skipping enabling of `simple`' in stderr
+ assert 'Skipping masking of ceph-disk' in stderr
+ assert 'Skipping enabling and starting OSD simple' in stderr
def test_no_systemd_flag_is_true(self, tmpfile, is_root):
json_config = tmpfile(contents='{}')
with pytest.raises(RuntimeError):
activation.validate_devices({'type': 'filestore', 'journal': {}})
stdout, stderr = capsys.readouterr()
- assert "devices found: ['journal']" in stdout
+ assert "devices found: ['journal']" in stderr
def test_filestore_data_device_found(self, capsys):
activation = activate.Activate([])
with pytest.raises(RuntimeError):
activation.validate_devices({'type': 'filestore', 'data': {}})
stdout, stderr = capsys.readouterr()
- assert "devices found: ['data']" in stdout
+ assert "devices found: ['data']" in stderr
def test_filestore_with_all_devices(self):
activation = activate.Activate([])
with pytest.raises(RuntimeError):
activation.validate_devices({'data': {}})
stdout, stderr = capsys.readouterr()
- assert "devices found: ['data']" in stdout
+ assert "devices found: ['data']" in stderr
def test_bluestore_missing_data(self):
activation = activate.Activate([])
with pytest.raises(RuntimeError):
activation.validate_devices({'block': {}})
stdout, stderr = capsys.readouterr()
- assert "devices found: ['block']" in stdout
+ assert "devices found: ['block']" in stderr
with pytest.raises(SystemExit):
lvm.zap.Zap(argv=[device_name]).main()
stdout, stderr = capsys.readouterr()
- assert 'Refusing to zap' in stdout
+ assert 'Refusing to zap' in stderr
with pytest.raises(RuntimeError):
configuration.load(ceph_conf)
stdout, stderr = capsys.readouterr()
- assert 'File contains no section headers' in stdout
+ assert 'File contains no section headers' in stderr
@pytest.mark.parametrize('commented', ['colon','hash'])
def test_coment_as_a_value(self, tmpdir, commented):
assert 'Running command: ' in log_lines[0]
assert 'ls' in log_lines[0]
assert 'stderr some stderr message' in log_lines[-1]
- assert 'some stderr message' in out
+ assert 'some stderr message' in err
def test_stderr_terminal_and_logfile_off(self, mock_call, caplog, capsys):
mock_call(stdout='stdout\n', stderr='some stderr message\n')
self.parser, ['filestore', 'bluestore'], argv=argv
)
stdout, stderr = capsys.readouterr()
- assert 'Cannot use --filestore (filestore) with --bluestore (bluestore)' in stdout
+ assert 'Cannot use --filestore (filestore) with --bluestore (bluestore)' in stderr
class TestValidDevice(object):
monkeypatch.setattr(system.os.path, 'exists', lambda x: False)
system.which('exedir')
stdout, stderr = capsys.readouterr()
- assert 'Absolute path not found for executable: exedir' in stdout
- assert 'Ensure $PATH environment variable contains common executable locations' in stdout
+ assert 'Absolute path not found for executable: exedir' in stderr
+ assert 'Ensure $PATH environment variable contains common executable locations' in stderr
c_v_out = check_output(cmd.format(tmpdir='.'),shell=True)
for out in c_v_out.splitlines():
- if not out.startswith(b'-->') and not out.startswith(b' stderr'):
- self.log.error(out)
- devs = []
- for device in json.loads(out):
- dev = orchestrator.InventoryDevice.from_ceph_volume_inventory(device)
- devs.append(dev)
- return [orchestrator.InventoryNode('localhost', devs)]
+ self.log.error(out)
+ devs = []
+ for device in json.loads(out):
+ dev = orchestrator.InventoryDevice.from_ceph_volume_inventory(device)
+ devs.append(dev)
+ return [orchestrator.InventoryNode('localhost', devs)]
self.log.error('c-v failed: ' + str(c_v_out))
raise Exception('c-v failed')