Blame SOURCES/0002-Remove-ipaclustercheck.patch

e6a568
From ea9e00e47307b4ab81cc31c37796dd7b6a4c8785 Mon Sep 17 00:00:00 2001
e6a568
From: Rob Crittenden <rcritten@redhat.com>
e6a568
Date: Thu, 29 Oct 2020 11:49:22 -0400
e6a568
Subject: [PATCH] Remove ipaclustercheck
e6a568
e6a568
Not shipping it from upstream into Fedora just yet
e6a568
---
e6a568
 setup.py                              |  12 +-
e6a568
 src/ipaclustercheck/__init__.py       |   5 -
e6a568
 src/ipaclustercheck/core/__init__.py  |   0
e6a568
 src/ipaclustercheck/core/main.py      |  30 -----
e6a568
 src/ipaclustercheck/core/output.py    |  67 ------------
e6a568
 src/ipaclustercheck/ipa/__init__.py   |   0
e6a568
 src/ipaclustercheck/ipa/crlmanager.py |  36 ------
e6a568
 src/ipaclustercheck/ipa/plugin.py     | 114 -------------------
e6a568
 src/ipaclustercheck/ipa/ruv.py        | 151 --------------------------
e6a568
 tests/test_cluster_ruv.py             | 106 ------------------
e6a568
 10 files changed, 1 insertion(+), 520 deletions(-)
e6a568
 delete mode 100644 src/ipaclustercheck/__init__.py
e6a568
 delete mode 100644 src/ipaclustercheck/core/__init__.py
e6a568
 delete mode 100644 src/ipaclustercheck/core/main.py
e6a568
 delete mode 100644 src/ipaclustercheck/core/output.py
e6a568
 delete mode 100644 src/ipaclustercheck/ipa/__init__.py
e6a568
 delete mode 100644 src/ipaclustercheck/ipa/crlmanager.py
e6a568
 delete mode 100644 src/ipaclustercheck/ipa/plugin.py
e6a568
 delete mode 100644 src/ipaclustercheck/ipa/ruv.py
e6a568
 delete mode 100644 tests/test_cluster_ruv.py
e6a568
e6a568
diff --git a/setup.py b/setup.py
e6a568
index 2b519fc..c25b2d7 100644
e6a568
--- a/setup.py
e6a568
+++ b/setup.py
e6a568
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
e6a568
 setup(
e6a568
     name='ipahealthcheck',
e6a568
     version='0.7',
e6a568
-    namespace_packages=['ipahealthcheck', 'ipaclustercheck'],
e6a568
+    namespace_packages=['ipahealthcheck'],
e6a568
     package_dir={'': 'src'},
e6a568
     # packages=find_packages(where='src'),
e6a568
     packages=[
e6a568
@@ -14,14 +14,11 @@ setup(
e6a568
         'ipahealthcheck.ipa',
e6a568
         'ipahealthcheck.meta',
e6a568
         'ipahealthcheck.system',
e6a568
-        'ipaclustercheck.core',
e6a568
-        'ipaclustercheck.ipa',
e6a568
     ],
e6a568
     entry_points={
e6a568
         # creates bin/ipahealthcheck
e6a568
         'console_scripts': [
e6a568
             'ipa-healthcheck = ipahealthcheck.core.main:main',
e6a568
-            'ipa-clustercheck = ipaclustercheck.core.main:main',
e6a568
         ],
e6a568
         # subsystem registries
e6a568
         'ipahealthcheck.registry': [
e6a568
@@ -69,13 +66,6 @@ setup(
e6a568
         'ipahealthcheck.system': [
e6a568
             'filesystemspace = ipahealthcheck.system.filesystemspace',
e6a568
         ],
e6a568
-        'ipaclustercheck.registry': [
e6a568
-            'ipaclustercheck.ipa = ipaclustercheck.ipa.plugin:registry',
e6a568
-        ],
e6a568
-        'ipaclustercheck.ipa': [
e6a568
-            'crl = ipaclustercheck.ipa.crlmanager',
e6a568
-            'ruv = ipaclustercheck.ipa.ruv',
e6a568
-        ],
e6a568
     },
e6a568
     classifiers=[
e6a568
         'Programming Language :: Python :: 3.6',
e6a568
diff --git a/src/ipaclustercheck/__init__.py b/src/ipaclustercheck/__init__.py
e6a568
deleted file mode 100644
e6a568
index 6c91ef7..0000000
e6a568
--- a/src/ipaclustercheck/__init__.py
e6a568
+++ /dev/null
e6a568
@@ -1,5 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-__import__('pkg_resources').declare_namespace(__name__)
e6a568
diff --git a/src/ipaclustercheck/core/__init__.py b/src/ipaclustercheck/core/__init__.py
e6a568
deleted file mode 100644
e6a568
index e69de29..0000000
e6a568
diff --git a/src/ipaclustercheck/core/main.py b/src/ipaclustercheck/core/main.py
e6a568
deleted file mode 100644
e6a568
index 45fda9f..0000000
e6a568
--- a/src/ipaclustercheck/core/main.py
e6a568
+++ /dev/null
e6a568
@@ -1,30 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2020 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-import sys
e6a568
-
e6a568
-from ipaclustercheck.core.output import output_registry
e6a568
-from ipahealthcheck.core.core import RunChecks
e6a568
-
e6a568
-
e6a568
-class ClusterChecks(RunChecks):
e6a568
-
e6a568
-    def add_options(self):
e6a568
-        parser = self.parser
e6a568
-        parser.add_argument('--directory', dest='dir',
e6a568
-                            help='Directory holding healthcheck logs')
e6a568
-
e6a568
-    def validate_options(self):
e6a568
-        super(ClusterChecks, self).validate_options()
e6a568
-
e6a568
-        if self.options.dir is None:
e6a568
-            print("--directory containing logs to check is required")
e6a568
-            return 1
e6a568
-
e6a568
-
e6a568
-def main():
e6a568
-    clusterchecks = ClusterChecks(['ipaclustercheck.registry'],
e6a568
-                                   '/etc/ipa/clustercheck.conf',
e6a568
-                                   output_registry, 'ansible')
e6a568
-    sys.exit(clusterchecks.run_healthcheck())
e6a568
diff --git a/src/ipaclustercheck/core/output.py b/src/ipaclustercheck/core/output.py
e6a568
deleted file mode 100644
e6a568
index 2f02b52..0000000
e6a568
--- a/src/ipaclustercheck/core/output.py
e6a568
+++ /dev/null
e6a568
@@ -1,67 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-import json
e6a568
-import sys
e6a568
-from ipahealthcheck.core.output import OutputRegistry, Output
e6a568
-
e6a568
-
e6a568
-output_registry = OutputRegistry()
e6a568
-
e6a568
-class ClusterOutput(Output):
e6a568
-    """Base class for writing/display output of cluster results
e6a568
-
e6a568
-       severity doesn't apply in this case so exclude those.
e6a568
-    """
e6a568
-    def __init__(self, options):
e6a568
-        self.filename = options.outfile
e6a568
-
e6a568
-    def strip_output(self, results):
e6a568
-        """Nothing to strip out"""
e6a568
-        return [result for result in results.output()]
e6a568
-
e6a568
-
e6a568
-@output_registry
e6a568
-class Ansible(ClusterOutput):
e6a568
-    """Output information JSON format for consumption by Ansible
e6a568
-
e6a568
-       Required keywords in a Result:
e6a568
-       name - unique identifier for the return value
e6a568
-
e6a568
-       One of these is required:
e6a568
-       value - the return value. Type? I dunno yet
e6a568
-       error - if an error was returned
e6a568
-    """
e6a568
-
e6a568
-    options = (
e6a568
-        ('--indent', dict(dest='indent', type=int, default=2,
e6a568
-         help='Indention level of JSON output')),
e6a568
-    )
e6a568
-
e6a568
-    def __init__(self, options):
e6a568
-        super(Ansible, self).__init__(options)
e6a568
-        self.indent = options.indent
e6a568
-
e6a568
-    def generate(self, data):
e6a568
-        output = []
e6a568
-        for line in data:
e6a568
-            kw = line.get('kw')
e6a568
-            result = line.get('result')
e6a568
-            name = kw.get('name')
e6a568
-            value = kw.get('value')
e6a568
-            error = kw.get('error')
e6a568
-
e6a568
-            if value and error:
e6a568
-                value = '%s: %s' % (error, value)
e6a568
-            elif error:
e6a568
-                value = error
e6a568
-
e6a568
-            rval = {'%s' % name: value}
e6a568
-            output.append(rval)
e6a568
-            
e6a568
-        output = json.dumps(output, indent=self.indent)
e6a568
-        if self.filename is None:
e6a568
-            output += '\n'
e6a568
-
e6a568
-        return output
e6a568
diff --git a/src/ipaclustercheck/ipa/__init__.py b/src/ipaclustercheck/ipa/__init__.py
e6a568
deleted file mode 100644
e6a568
index e69de29..0000000
e6a568
diff --git a/src/ipaclustercheck/ipa/crlmanager.py b/src/ipaclustercheck/ipa/crlmanager.py
e6a568
deleted file mode 100644
e6a568
index 6806d74..0000000
e6a568
--- a/src/ipaclustercheck/ipa/crlmanager.py
e6a568
+++ /dev/null
e6a568
@@ -1,36 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-from ipaclustercheck.ipa.plugin import ClusterPlugin, registry, find_checks
e6a568
-from ipahealthcheck.core.plugin import Result, duration
e6a568
-from ipahealthcheck.core import constants
e6a568
-
e6a568
-
e6a568
-@registry
e6a568
-class ClusterCRLManagerCheck(ClusterPlugin):
e6a568
-
e6a568
-    @duration
e6a568
-    def check(self):
e6a568
-        data = self.registry.json
e6a568
-        crlmanagers = []
e6a568
-
e6a568
-        for fqdn in data.keys():
e6a568
-             output = find_checks(data[fqdn], 'ipahealthcheck.ipa.roles',
e6a568
-                                 'IPACRLManagerCheck')
e6a568
-             enabled = output[0].get('kw').get('crlgen_enabled')
e6a568
-             if enabled:
e6a568
-                 crlmanagers.append(fqdn)
e6a568
-        if len(crlmanagers) == 0:
e6a568
-            yield Result(self, constants.ERROR,
e6a568
-                         name='crlmanager',
e6a568
-                         error='No CRL Manager defined')
e6a568
-        elif len(crlmanagers) == 1:
e6a568
-            yield Result(self, constants.SUCCESS,
e6a568
-                         name='crlmanager',
e6a568
-                         value=crlmanagers[0])
e6a568
-        else:
e6a568
-            yield Result(self, constants.ERROR,
e6a568
-                         name='crlmanager',
e6a568
-                         value=','.join(crlmanagers),
e6a568
-                         error='Multiple CRL Managers defined')
e6a568
diff --git a/src/ipaclustercheck/ipa/plugin.py b/src/ipaclustercheck/ipa/plugin.py
e6a568
deleted file mode 100644
e6a568
index d9b6063..0000000
e6a568
--- a/src/ipaclustercheck/ipa/plugin.py
e6a568
+++ /dev/null
e6a568
@@ -1,114 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2020 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-from copy import deepcopy
e6a568
-import json
e6a568
-import logging
e6a568
-from os import listdir
e6a568
-from os.path import isfile, join
e6a568
-
e6a568
-from ipahealthcheck.core.plugin import Plugin, Registry
e6a568
-from ipalib import api
e6a568
-
e6a568
-
e6a568
-logger = logging.getLogger()
e6a568
-
e6a568
-def find_checks(data, source, check):
e6a568
-    """Look through the dict for a matching source and check.
e6a568
-
e6a568
-       data: dict of source and check output
e6a568
-       source: name of source to find
e6a568
-       check: name of check to find
e6a568
-
e6a568
-       Returns list of contents of source + check or empty list
e6a568
-    """
e6a568
-    rval = []
e6a568
-    for d in data:
e6a568
-        if d.get('source') == source and d.get('check') == check:
e6a568
-            rval.append(d)
e6a568
-
e6a568
-    return rval
e6a568
-
e6a568
-
e6a568
-def get_masters(data):
e6a568
-    """
e6a568
-    Return the list of known masters
e6a568
-
e6a568
-    This is determined from the list of loaded healthcheck logs. It
e6a568
-    is possible that mixed versions are used so some may not be
e6a568
-    reporting the full list of masters, so check them all, and raise
e6a568
-    an exception if the list cannot be determined.
e6a568
-    """
e6a568
-    test_masters = list(data)
e6a568
-    masters = None
e6a568
-    for master in test_masters:
e6a568
-        output = find_checks(data[master], 'ipahealthcheck.ipa.meta',
e6a568
-                             'IPAMetaCheck')
e6a568
-        if len(output) == 0:
e6a568
-            raise ValueError('Unable to determine full list of masters. '
e6a568
-                             'ipahealthcheck.ipa.meta:IPAMetaCheck not '
e6a568
-                             'found.')
e6a568
-
e6a568
-        masters = output[0].get('kw').get('masters')
e6a568
-        if masters:
e6a568
-            return masters          
e6a568
-
e6a568
-    raise ValueError('Unable to determine full list of masters. '
e6a568
-                     'None of ipahealthcheck.ipa.meta:IPAMetaCheck '
e6a568
-                     'contain masters.')
e6a568
-
e6a568
-
e6a568
-class ClusterPlugin(Plugin):
e6a568
-    def __init__(self, registry):
e6a568
-        super(ClusterPlugin, self).__init__(registry)
e6a568
-
e6a568
-
e6a568
-class ClusterRegistry(Registry):
e6a568
-    def initialize(self, framework, config, options):
e6a568
-        super(ClusterRegistry, self).initialize(framework, config, options)
e6a568
-
e6a568
-        self.json = {}
e6a568
-
e6a568
-        self.load_files(options.dir)
e6a568
-
e6a568
-        if not api.isdone('finalize'):
e6a568
-            if not api.isdone('bootstrap'):
e6a568
-                api.bootstrap(in_server=True,
e6a568
-                              context='ipahealthcheck',
e6a568
-                              log=None)
e6a568
-            if not api.isdone('finalize'):
e6a568
-                api.finalize()
e6a568
-
e6a568
-    def load_files(self, dir):
e6a568
-        if self.json:
e6a568
-            return
e6a568
-
e6a568
-        files = [f for f in listdir(dir) if isfile(join(dir, f))]
e6a568
-        for file in files:
e6a568
-            fname = join(dir, file)
e6a568
-            logger.debug("Reading %s", fname)
e6a568
-            try:
e6a568
-                with open(fname, 'r') as fd:
e6a568
-                    data = fd.read()
e6a568
-            except Exception as e:
e6a568
-                logger.error("Unable to read %s: %s", fname, e)
e6a568
-                continue
e6a568
-        
e6a568
-            try:
e6a568
-                data = json.loads(data)
e6a568
-            except Exception as e:
e6a568
-                logger.error("Unable to parse JSON in %s: %s", fname, e)
e6a568
-                continue
e6a568
-
e6a568
-            meta = find_checks(data, 'ipahealthcheck.meta.core',
e6a568
-                                   'MetaCheck')
e6a568
-            if meta:
e6a568
-                fqdn = meta[0].get('kw').get('fqdn')
e6a568
-                self.json[fqdn] = deepcopy(data)
e6a568
-            else:
e6a568
-                logger.error("No fqdn defined in JSON in %s", fname)
e6a568
-                continue
e6a568
-        
e6a568
-        
e6a568
-registry = ClusterRegistry()
e6a568
diff --git a/src/ipaclustercheck/ipa/ruv.py b/src/ipaclustercheck/ipa/ruv.py
e6a568
deleted file mode 100644
e6a568
index 0e51da9..0000000
e6a568
--- a/src/ipaclustercheck/ipa/ruv.py
e6a568
+++ /dev/null
e6a568
@@ -1,151 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-import logging
e6a568
-
e6a568
-from ipaclustercheck.ipa.plugin import (
e6a568
-    ClusterPlugin,
e6a568
-    registry,
e6a568
-    find_checks,
e6a568
-    get_masters
e6a568
-)
e6a568
-from ipahealthcheck.core.plugin import Result, duration
e6a568
-from ipahealthcheck.core import constants
e6a568
-from ipalib import api
e6a568
-from ipapython.dn import DN
e6a568
-
e6a568
-
e6a568
-logger = logging.getLogger()
e6a568
-
e6a568
-
e6a568
-@registry
e6a568
-class ClusterRUVCheck(ClusterPlugin):
e6a568
-
e6a568
-    # TODO: confirm that all masters are represented, otherwise the
e6a568
-    #       trustworthiness of dangling RUV is mixed.
e6a568
-    #
e6a568
-    #       gah, need to provide full list of all masters in a check.
e6a568
-
e6a568
-    @duration
e6a568
-    def check(self):
e6a568
-        data = self.registry.json
e6a568
-
e6a568
-        # Start with the list of masters from the file(s) collected
e6a568
-        # and find a MetaCheck with a full list of masters. For
e6a568
-        # backwards compatibility.
e6a568
-        try:
e6a568
-            masters = get_masters(data)
e6a568
-        except ValueError as e:
e6a568
-            yield Result(self, constants.ERROR,
e6a568
-                         name='dangling_ruv',
e6a568
-                         error=str(e))
e6a568
-            return
e6a568
-
e6a568
-        if len(data.keys()) < len(masters):
e6a568
-            yield Result(self, constants.ERROR,
e6a568
-                         name='dangling_ruv',
e6a568
-                         error='Unable to determine list of RUVs, missing '
e6a568
-                               'some masters: %s' %
e6a568
-                               ''.join(set(masters) - set(data.keys())))
e6a568
-            return
e6a568
-
e6a568
-        # collect the full set of known RUVs for each master
e6a568
-        info = {}
e6a568
-        for master in masters:
e6a568
-            info[master] = {
e6a568
-                'ca': False,           # does the host have ca configured?
e6a568
-                'ruvs': set(),         # ruvs on the host
e6a568
-                'csruvs': set(),       # csruvs on the host
e6a568
-                'clean_ruv': set(),    # ruvs to be cleaned from the host
e6a568
-                'clean_csruv': set()   # csruvs to be cleaned from the host
e6a568
-                }
e6a568
-
e6a568
-        for fqdn in data.keys():
e6a568
-            outputs = find_checks(data[fqdn], 'ipahealthcheck.ds.ruv',
e6a568
-                                  'KnownRUVCheck')
e6a568
-            for output in outputs:
e6a568
-                if not 'suffix' in output.get('kw'):
e6a568
-                    continue
e6a568
-                basedn = DN(output.get('kw').get('suffix'))
e6a568
-
e6a568
-                ruvset = set()
e6a568
-                ruvtmp = output.get('kw').get('ruvs')
e6a568
-                for ruv in ruvtmp:
e6a568
-                    ruvset.add(tuple(ruv))
e6a568
-
e6a568
-                if basedn == DN('o=ipaca'):
e6a568
-                    info[fqdn]['ca'] = True
e6a568
-                    info[fqdn]['csruvs'] = ruvset
e6a568
-                elif basedn == api.env.basedn:
e6a568
-                    info[fqdn]['ruvs'] = ruvset
e6a568
-                else:
e6a568
-                    yield Result(self, constants.WARNING,
e6a568
-                                 name='dangling_ruv',
e6a568
-                                 error='Unknown suffix found %s expected %s'
e6a568
-                                       % (basedn, api.env.basedn))
e6a568
-
e6a568
-        # Collect the nsDS5ReplicaID for each master
e6a568
-        ruvs = set()
e6a568
-        csruvs = set()
e6a568
-        for fqdn in data.keys():
e6a568
-            outputs = find_checks(data[fqdn], 'ipahealthcheck.ds.ruv',
e6a568
-                                  'RUVCheck')
e6a568
-            for output in outputs:
e6a568
-                if not 'key' in output.get('kw'):
e6a568
-                    continue
e6a568
-                basedn = DN(output.get('kw').get('key'))
e6a568
-                ruv = (fqdn, (output.get('kw').get('ruv')))
e6a568
-                if basedn == DN('o=ipaca'):
e6a568
-                    csruvs.add(ruv)
e6a568
-                elif basedn == api.env.basedn:
e6a568
-                    ruvs.add(ruv)
e6a568
-                else:
e6a568
-                    yield Result(self, constants.WARNING,
e6a568
-                                 name='dangling_ruv',
e6a568
-                                 error='Unknown suffix found %s expected %s'
e6a568
-                                       % (basedn, api.env.basedn))
e6a568
-
e6a568
-        dangles = False
e6a568
-        # get the dangling RUVs
e6a568
-        for master_info in info.values():
e6a568
-            for ruv in master_info['ruvs']:
e6a568
-                if ruv not in ruvs:
e6a568
-                    master_info['clean_ruv'].add(ruv)
e6a568
-                    dangles = True
e6a568
-
e6a568
-            # if ca is not configured, there will be no csruvs in master_info
e6a568
-            for csruv in master_info['csruvs']:
e6a568
-                if csruv not in csruvs:
e6a568
-                    master_info['clean_csruv'].add(csruv)
e6a568
-                    dangles = True
e6a568
-
e6a568
-        clean_csruvs = set()
e6a568
-        clean_ruvs = set()
e6a568
-        if dangles:
e6a568
-            for master_cn, master_info in info.items():
e6a568
-                for ruv in master_info['clean_ruv']:
e6a568
-                    logger.debug('Dangling RUV id: {id}, hostname: {host}'
e6a568
-                                 .format(id=ruv[1], host=ruv[0]))
e6a568
-                    clean_ruvs.add(ruv[1])
e6a568
-                for csruv in master_info['clean_csruv']:
e6a568
-                    logger.debug('Dangling CS RUV id: {id}, hostname: {host}'
e6a568
-                                 .format(id=csruv[1], host=csruv[0]))
e6a568
-                    clean_csruvs.add(csruv[1])
e6a568
-
e6a568
-        if clean_ruvs:
e6a568
-            yield Result(self, constants.ERROR,
e6a568
-                         name='dangling_ruv',
e6a568
-                         value=', '.join(clean_ruvs))
e6a568
-        else:
e6a568
-            yield Result(self, constants.SUCCESS,
e6a568
-                         name='dangling_ruv',
e6a568
-                         value='No dangling RUVs found')
e6a568
-        if clean_csruvs:
e6a568
-            yield Result(self, constants.ERROR,
e6a568
-                         name='dangling_csruv',
e6a568
-                         value=', '.join(clean_csruvs))
e6a568
-        else:
e6a568
-            yield Result(self, constants.SUCCESS,
e6a568
-                         name='dangling_csruv',
e6a568
-                         value='No dangling CS RUVs found')
e6a568
diff --git a/tests/test_cluster_ruv.py b/tests/test_cluster_ruv.py
e6a568
deleted file mode 100644
e6a568
index 7583c84..0000000
e6a568
--- a/tests/test_cluster_ruv.py
e6a568
+++ /dev/null
e6a568
@@ -1,106 +0,0 @@
e6a568
-#
e6a568
-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
e6a568
-#
e6a568
-
e6a568
-from base import BaseTest
e6a568
-from util import capture_results
e6a568
-
e6a568
-from ipahealthcheck.core import config
e6a568
-from ipaclustercheck.ipa.plugin import ClusterRegistry
e6a568
-from ipaclustercheck.ipa.ruv import ClusterRUVCheck
e6a568
-
e6a568
-import clusterdata
e6a568
-
e6a568
-
e6a568
-class RUVRegistry(ClusterRegistry):
e6a568
-    def load_files(self, dir):
e6a568
-        self.json = dir
e6a568
-
e6a568
-
e6a568
-class Options:
e6a568
-    def __init__(self, data):
e6a568
-        self.data = data
e6a568
-
e6a568
-    @property
e6a568
-    def dir(self):
e6a568
-        return self.data
e6a568
-
e6a568
-
e6a568
-registry = RUVRegistry()
e6a568
-
e6a568
-
e6a568
-class TestClusterRUV(BaseTest):
e6a568
-
e6a568
-    def test_no_ruvs(self):
e6a568
-        """Single master test that has never created a replica
e6a568
-
e6a568
-           This type of master will have no RUVs created at all.
e6a568
-        """
e6a568
-        framework = object()
e6a568
-        registry.initialize(framework, config.Config,
e6a568
-                            Options(clusterdata.ONE_MASTER))
e6a568
-        f = ClusterRUVCheck(registry)
e6a568
-
e6a568
-        self.results = capture_results(f)
e6a568
-
e6a568
-        assert len(self.results) == 2
e6a568
-        result = self.results.results[0]
e6a568
-        assert result.kw.get('name') == 'dangling_ruv'
e6a568
-        assert result.kw.get('value') == 'No dangling RUVs found'
e6a568
-        result = self.results.results[1]
e6a568
-        assert result.kw.get('name') == 'dangling_csruv'
e6a568
-        assert result.kw.get('value') == 'No dangling CS RUVs found'
e6a568
-
e6a568
-    def test_six_ruvs_ok(self):
e6a568
-        """Three master test with each having a CA, no dangling
e6a568
-        """
e6a568
-        framework = object()
e6a568
-        registry.initialize(framework, config.Config,
e6a568
-                            Options(clusterdata.THREE_MASTERS_OK))
e6a568
-        f = ClusterRUVCheck(registry)
e6a568
-
e6a568
-        self.results = capture_results(f)
e6a568
-
e6a568
-        assert len(self.results) == 2
e6a568
-        result = self.results.results[0]
e6a568
-        assert result.kw.get('name') == 'dangling_ruv'
e6a568
-        assert result.kw.get('value') == 'No dangling RUVs found'
e6a568
-        result = self.results.results[1]
e6a568
-        assert result.kw.get('name') == 'dangling_csruv'
e6a568
-        assert result.kw.get('value') == 'No dangling CS RUVs found'
e6a568
-
e6a568
-    def test_six_ruvs_ipa_bad(self):
e6a568
-        """Three master test with each having a CA, dangling IPA RUV
e6a568
-        """
e6a568
-        framework = object()
e6a568
-        registry.initialize(framework, config.Config,
e6a568
-                            Options(clusterdata.THREE_MASTERS_BAD_IPA_RUV))
e6a568
-        f = ClusterRUVCheck(registry)
e6a568
-
e6a568
-        self.results = capture_results(f)
e6a568
-
e6a568
-        assert len(self.results) == 2
e6a568
-        result = self.results.results[0]
e6a568
-        assert result.kw.get('name') == 'dangling_ruv'
e6a568
-        assert result.kw.get('value') == '9'
e6a568
-        result = self.results.results[1]
e6a568
-        assert result.kw.get('name') == 'dangling_csruv'
e6a568
-        assert result.kw.get('value') == 'No dangling CS RUVs found'
e6a568
-
e6a568
-    def test_six_ruvs_cs_bad(self):
e6a568
-        """Three master test with each having a CA, dangling CA RUV
e6a568
-        """
e6a568
-        framework = object()
e6a568
-        registry.initialize(framework, config.Config,
e6a568
-                            Options(clusterdata.THREE_MASTERS_BAD_CS_RUV))
e6a568
-        f = ClusterRUVCheck(registry)
e6a568
-
e6a568
-        self.results = capture_results(f)
e6a568
-
e6a568
-        assert len(self.results) == 2
e6a568
-        result = self.results.results[0]
e6a568
-        assert result.kw.get('name') == 'dangling_ruv'
e6a568
-        assert result.kw.get('value') == 'No dangling RUVs found'
e6a568
-        result = self.results.results[1]
e6a568
-        assert result.kw.get('name') == 'dangling_csruv'
e6a568
-        assert result.kw.get('value') == '9'
e6a568
-- 
e6a568
2.25.4
e6a568