def main(self): options = ['--ignore'] config_ignores = ceph_medic.config.file.get_list('check', '--ignore') parser = Transport(self.argv, options=options, check_version=False) parser.catch_help = self._help() parser.parse_args() ignored_codes = as_list(parser.get('--ignore', '')) # fallback to the configuration if nothing is defined in the CLI if not ignored_codes: ignored_codes = config_ignores if len(self.argv) < 1: return parser.print_help() # populate the nodes metadata with the configured nodes for daemon in ceph_medic.config.nodes.keys(): ceph_medic.metadata['nodes'][daemon] = [] for daemon, nodes in ceph_medic.config.nodes.items(): for node in nodes: node_metadata = {'host': node['host']} if 'container' in node: node_metadata['container'] = node['container'] ceph_medic.metadata['nodes'][daemon].append(node_metadata) collector.collect() test = runner.Runner() test.ignore = ignored_codes results = test.run() runner.report(results) #XXX might want to make this configurable to not bark on warnings for # example, setting forcefully for now, but the results object doesn't # make a distinction between error and warning (!) if results.errors or results.warnings: sys.exit(1)
def main(self): options = ['--ignore'] parser = Transport(self.argv, options=options, check_version=False) parser.catch_help = self._help() parser.parse_args() if len(self.argv) < 1: return parser.print_help() # populate the nodes metadata with the configured nodes for daemon in ceph_medic.config.nodes.keys(): ceph_medic.metadata['nodes'][daemon] = [] for daemon, nodes in ceph_medic.config.nodes.items(): for node in nodes: ceph_medic.metadata['nodes'][daemon].append( {'host': node['host']}) collector.collect() test = runner.Runner() results = test.run() runner.report(results) #XXX might want to make this configurable to not bark on warnings for # example, setting forcefully for now, but the results object doesn't # make a distinction between error and warning (!) if results.errors or results.warnings: sys.exit(1)
def test_calculate_hosts_single_daemon_type(self): ceph_medic.metadata['nodes']['osds'] = [{ 'host': 'node1' }, { 'host': 'node2' }] runner.metadata = ceph_medic.metadata run = runner.Runner() assert run.total_hosts == 2
def setup(self): contents = dedent(""" [global] # """) conf = configuration.load_string(contents) ceph_medic.config.file = conf runner.metadata = base_metadata runner.metadata['cluster_name'] = 'ceph' runner.Runner().run()
def test_count_from_different_daemon_types(self): ceph_medic.metadata['nodes']['osds'] = [{ 'host': 'node1' }, { 'host': 'node2' }] ceph_medic.metadata['nodes']['mons'] = [{ 'host': 'node3' }, { 'host': 'node4' }] runner.metadata = ceph_medic.metadata run = runner.Runner() assert run.total_hosts == 4
def test_get_new_lines_in_errors(self, terminal, mon_keyring, data, monkeypatch): data_node1 = data() data_node2 = data() data_node1['paths']['/var/lib/ceph']['files'] = { '/var/lib/ceph/mon/ceph-0/keyring': { 'contents': mon_keyring() } } data_node1['paths']['/var/lib/ceph']['dirs'] = { '/var/lib/ceph/osd/ceph-10': {}, '/var/lib/ceph/osd/ceph-11': {}, '/var/lib/ceph/osd/ceph-12': {}, '/var/lib/ceph/osd/ceph-13': {}, '/var/lib/ceph/osd/ceph-0': {}, '/var/lib/ceph/osd/ceph-1': {}, '/var/lib/ceph/osd/ceph-2': {}, '/var/lib/ceph/osd/ceph-3': {}, } data_node2['paths']['/var/lib/ceph']['files'] = { '/var/lib/ceph/mon/ceph-1/keyring': { 'contents': mon_keyring() }, } data_node2['paths']['/var/lib/ceph']['dirs'] = { '/var/lib/ceph/osd/ceph-10': {}, '/var/lib/ceph/osd/ceph-11': {}, '/var/lib/ceph/osd/ceph-12': {}, '/var/lib/ceph/osd/ceph-13': {}, '/var/lib/ceph/osd/ceph-0': {}, '/var/lib/ceph/osd/ceph-1': {}, '/var/lib/ceph/osd/ceph-2': {}, '/var/lib/ceph/osd/ceph-3': {}, } # set the data everywhere we need it ceph_medic.metadata['mons'] = { 'node1': data_node1, 'node2': data_node2 } monkeypatch.setattr(ceph_medic.checks.mons, 'metadata', ceph_medic.metadata) runner.Runner().run() # Any line that is an error or a warning *must* end with a newline for line in terminal.calls: if line.lstrip().startswith(('E', 'W')): assert line.endswith('\n')
def main(self): options = ['--ignore'] parser = Transport(self.argv, options=options, check_version=False) parser.catch_help = self._help() parser.parse_args() if len(self.argv) < 1: return parser.print_help() # populate the nodes metadata with the configured nodes for daemon in ceph_medic.config['nodes'].keys(): ceph_medic.metadata['nodes'][daemon] = [] for daemon, nodes in ceph_medic.config['nodes'].items(): for node in nodes: ceph_medic.metadata['nodes'][daemon].append( {'host': node['host']}) collector.collect() test = runner.Runner() results = test.run() runner.report(results)
def setup(self): runner.Runner().run()
def setup(self): runner.metadata = base_metadata runner.metadata['nodes'] = {} self.results = runner.Runner()
def test_calculate_total_hosts_is_0(self): run = runner.Runner() assert run.total_hosts == 0
def setup(self): # clear metadata ceph_medic.metadata = base_metadata runner.metadata = base_metadata runner.metadata['nodes'] = {} self.results = runner.Runner()
def setup(self): # clear metadata ceph_medic.metadata = base_metadata runner.metadata = base_metadata runner.metadata['nodes'] = {} runner.Runner().run()