Exemplo n.º 1
0
def _expected_replication_paths():
    expected = [
        ReplicationPath(
            'dir', 'check_mk',
            '%s/etc/check_mk/conf.d/wato/' % cmk.utils.paths.omd_root,
            ['sitespecific.mk']),
        ReplicationPath(
            'dir', 'multisite',
            '%s/etc/check_mk/multisite.d/wato/' % cmk.utils.paths.omd_root,
            ['sitespecific.mk']),
        ReplicationPath('file', 'htpasswd',
                        '%s/etc/htpasswd' % cmk.utils.paths.omd_root, []),
        ReplicationPath('file', 'auth.secret',
                        '%s/etc/auth.secret' % cmk.utils.paths.omd_root, []),
        ReplicationPath('file', 'auth.serials',
                        '%s/etc/auth.serials' % cmk.utils.paths.omd_root, []),
        ReplicationPath('dir', 'usersettings',
                        '%s/var/check_mk/web' % cmk.utils.paths.omd_root,
                        ['*/report-thumbnails']),
        ReplicationPath('dir', 'mkps',
                        '%s/var/check_mk/packages' % cmk.utils.paths.omd_root,
                        []),
        ReplicationPath('dir', 'local', '%s/local' % cmk.utils.paths.omd_root,
                        []),
    ]

    if not cmk_version.is_raw_edition():
        expected += [
            ReplicationPath(
                'dir', 'liveproxyd', '%s/etc/check_mk/liveproxyd.d/wato/' %
                cmk.utils.paths.omd_root, ['sitespecific.mk']),
        ]

    if testlib.is_enterprise_repo():
        expected += [
            ReplicationPath(
                'dir', 'dcd',
                '%s/etc/check_mk/dcd.d/wato/' % cmk.utils.paths.omd_root,
                ['sitespecific.mk', 'distributed.mk']),
            ReplicationPath(
                'dir', 'mknotify',
                '%s/etc/check_mk/mknotifyd.d/wato/' % cmk.utils.paths.omd_root,
                ['sitespecific.mk']),
        ]

    expected += [
        ReplicationPath(
            'dir', 'mkeventd',
            '%s/etc/check_mk/mkeventd.d/wato' % cmk.utils.paths.omd_root,
            ['sitespecific.mk']),
        ReplicationPath(
            'dir', 'mkeventd_mkp',
            '%s/etc/check_mk/mkeventd.d/mkp/rule_packs' %
            cmk.utils.paths.omd_root, []),
        ReplicationPath('file', 'diskspace',
                        '%s/etc/diskspace.conf' % cmk.utils.paths.omd_root,
                        []),
    ]

    return expected
Exemplo n.º 2
0
def _get_files_to_check(pylint_test_dir):
    p = subprocess.Popen(
        [
            "%s/scripts/find-python-files" % repo_path(),
            str(sys.version_info[0])
        ],
        stdout=subprocess.PIPE,
        encoding="utf-8",
        shell=False,
        close_fds=True,
    )

    stdout = p.communicate()[0]

    files = []
    for fname in stdout.splitlines():
        # Thin out these excludes some day...
        rel_path = fname[len(repo_path()) + 1:]

        # Can currently not be checked alone. Are compiled together below
        if rel_path.startswith("checks/") or \
           rel_path.startswith("inventory/") or \
           rel_path.startswith("agents/bakery/") or \
           rel_path.startswith("enterprise/agents/bakery/"):
            continue

        # TODO: We should also test them...
        if rel_path == "werk" \
            or rel_path.startswith("tests/") \
            or rel_path.startswith("scripts/") \
            or rel_path.startswith("agents/wnx/integration/"):
            continue

        # TODO: disable random, not that important stuff
        if rel_path.startswith("agents/windows/it/") \
            or rel_path.startswith("agents/windows/msibuild/") \
            or rel_path.startswith("doc/") \
            or rel_path.startswith("livestatus/api/python/example") \
            or rel_path.startswith("livestatus/api/python/make_"):
            continue

        files.append(fname)

    # Add the compiled files for things that are no modules yet
    open(pylint_test_dir + "/__init__.py", "w")
    _compile_check_and_inventory_plugins(pylint_test_dir)

    if is_enterprise_repo():
        _compile_bakery_plugins(pylint_test_dir)

    # Not checking compiled check, inventory, bakery plugins with Python 3
    if sys.version_info[0] == 2:
        files += [
            pylint_test_dir,
        ]

    return files
Exemplo n.º 3
0
def fixture_edition_short(monkeypatch, request):
    edition_short = request.param
    if edition_short == "cme" and not is_managed_repo():
        pytest.skip("Needed files are not available")

    if edition_short == "cee" and not is_enterprise_repo():
        pytest.skip("Needed files are not available")

    monkeypatch.setattr(cmk_version, "edition_short", lambda: edition_short)
    yield edition_short
Exemplo n.º 4
0
def register(linter):
    verify_pylint_version()

    # Disable some CEE/CME specific things when linting CRE repos
    if not is_enterprise_repo():
        # Is used to disable import-error. Would be nice if no-name-in-module could be
        # disabled using this, but this does not seem to be possible :(
        linter.global_set_option("ignored-modules",
                                 "cmk.base.cee,cmk.gui.cee,cmk.gui.cme,cmk.gui.cme.managed")
        # This disables no-member errors
        linter.global_set_option("generated-members",
                                 r"(cmk\.base\.cee|cmk\.gui\.cee|cmk\.gui\.cme)(\..*)?")

    linter.register_reporter(CMKColorizedTextReporter)
    linter.register_reporter(CMKParseableTextReporter)
Exemplo n.º 5
0
def _expected_replication_paths():
    expected = [
        ReplicationPath('dir', 'check_mk', 'etc/check_mk/conf.d/wato/', []),
        ReplicationPath('dir', 'multisite', 'etc/check_mk/multisite.d/wato/', []),
        ReplicationPath('file', 'htpasswd', 'etc/htpasswd', []),
        ReplicationPath('file', 'auth.secret', 'etc/auth.secret', []),
        ReplicationPath('file', 'auth.serials', 'etc/auth.serials', []),
        ReplicationPath('dir', 'usersettings', 'var/check_mk/web', ['*/report-thumbnails']),
        ReplicationPath('dir', 'mkps', 'var/check_mk/packages', []),
        ReplicationPath('dir', 'local', 'local', []),
    ]

    if not cmk_version.is_raw_edition():
        expected += [
            ReplicationPath('dir', 'liveproxyd', 'etc/check_mk/liveproxyd.d/wato/', []),
        ]

    if testlib.is_enterprise_repo():
        expected += [
            ReplicationPath('dir', 'dcd', 'etc/check_mk/dcd.d/wato/', []),
            ReplicationPath('dir', 'mknotify', 'etc/check_mk/mknotifyd.d/wato', []),
        ]

    expected += [
        ReplicationPath('dir', 'mkeventd', 'etc/check_mk/mkeventd.d/wato', []),
        ReplicationPath('dir', 'mkeventd_mkp', 'etc/check_mk/mkeventd.d/mkp/rule_packs', []),
        ReplicationPath('file', 'diskspace', 'etc/diskspace.conf', []),
    ]

    if cmk_version.is_managed_edition():
        expected += [
            ReplicationPath(ty='file',
                            ident='customer_check_mk',
                            site_path='etc/check_mk/conf.d/customer.mk',
                            excludes=[]),
            ReplicationPath(ty='file',
                            ident='customer_gui_design',
                            site_path='etc/check_mk/multisite.d/zzz_customer_gui_design.mk',
                            excludes=[]),
            ReplicationPath(ty='file',
                            ident='customer_multisite',
                            site_path='etc/check_mk/multisite.d/customer.mk',
                            excludes=[]),
            ReplicationPath(
                ty='file',
                ident='gui_logo',
                site_path='local/share/check_mk/web/htdocs/themes/classic/images/sidebar_top.png',
                excludes=[]),
            ReplicationPath(
                ty='file',
                ident='gui_logo_dark',
                site_path='local/share/check_mk/web/htdocs/themes/modern-dark/images/mk-logo.png',
                excludes=[]),
            ReplicationPath(
                ty='file',
                ident='gui_logo_facelift',
                site_path='local/share/check_mk/web/htdocs/themes/facelift/images/mk-logo.png',
                excludes=[]),
        ]

    return expected
Exemplo n.º 6
0
def test_pylint(pylint_test_dir):
    # Only specify the path to python packages or modules here
    if sys.version_info[0] >= 3:
        modules_or_packages = []
    else:
        modules_or_packages = [
            "omd/packages/omd/omdlib",
            "livestatus/api/python/livestatus.py",
            "cmk_base",
            "cmk",
            "web/app/index.wsgi",
        ]

        if is_enterprise_repo():
            modules_or_packages += [
                # TODO: Check if this kind of "overlay" really works.
                # TODO: Why do we have e.g. a symlink cmk_base/cee -> enterprise/cmk_base/cee?
                "enterprise/cmk_base/automations/cee.py",
                "enterprise/cmk_base/cee",
                "enterprise/cmk_base/default_config/cee.py",
                "enterprise/cmk_base/modes/cee.py",
                # TODO: Funny links there, see above.
                "enterprise/cmk/cee",
                "enterprise/cmk/gui/cee",
            ]

        if is_managed_repo():
            modules_or_packages += [
                "managed/cmk_base/default_config/cme.py",
                "managed/cmk/gui/cme",
            ]

    # Add the compiled files for things that are no modules yet
    open(pylint_test_dir + "/__init__.py", "w")
    _compile_check_and_inventory_plugins(pylint_test_dir)

    if is_enterprise_repo():
        _compile_bakery_plugins(pylint_test_dir)

    # Not checking compiled check, inventory, bakery plugins with Python 3
    if sys.version_info[0] == 2:
        modules_or_packages += [
            pylint_test_dir,
        ]

    # We use our own search logic to find scripts without python extension
    search_paths = [
        "omd/packages/omd.bin",
        "bin",
        "notifications",
        "agents/plugins",
        "agents/special",
        "active_checks",
    ]

    if is_enterprise_repo():
        search_paths += [
            "enterprise/agents/plugins",
            "enterprise/bin",
            "enterprise/misc",
        ]

    for path in search_paths:
        abs_path = cmk_path() + "/" + path
        for fname in pylint_cmk.get_pylint_files(abs_path, "*"):
            modules_or_packages.append(path + "/" + fname)

    exit_code = pylint_cmk.run_pylint(cmk_path(), modules_or_packages)
    assert exit_code == 0, "PyLint found an error"