Beispiel #1
0
    def test_no_cleanup_with_microcore(self, store, prev_serial, prev_prev_serial):
        assert config.monitoring_core == "cmc"
        assert not store.serial_path.exists()
        with store.create():
            pass

        assert config.make_helper_config_path(prev_prev_serial).exists()
        assert config.make_helper_config_path(prev_serial).exists()
        assert store.serial_path.exists()
        assert store.latest_path.resolve() == store.serial_path
Beispiel #2
0
    def test_cleanup_with_nagios(self, store, prev_helper_config, prev_serial, prev_prev_serial):
        assert config.monitoring_core == "nagios"
        prev_path = config.make_helper_config_path(prev_serial)

        assert not store.serial_path.exists()
        with store.create():
            assert not config.make_helper_config_path(prev_prev_serial).exists()
            assert prev_path.exists()
            assert store.serial_path.exists()
            assert store.latest_path.resolve() == prev_path

        assert store.latest_path.resolve() == store.serial_path
Beispiel #3
0
    def test_cleanup_with_broken_latest_link(self, store, prev_serial, prev_prev_serial):
        assert config.monitoring_core == "nagios"
        prev_path = config.make_helper_config_path(prev_serial)
        shutil.rmtree(prev_path)

        assert not prev_path.exists()
        assert store.latest_path.resolve() == prev_path

        assert not store.serial_path.exists()
        with store.create():
            assert not config.make_helper_config_path(prev_prev_serial).exists()
            assert not prev_path.exists()
            assert store.serial_path.exists()
            assert store.latest_path.resolve() == prev_path

        assert store.latest_path.resolve() == store.serial_path
Beispiel #4
0
    def prev_helper_config(self, store, prev_serial, prev_prev_serial):
        assert not store.latest_path.exists()

        def _create_helper_config_dir(serial):
            path = cmk.utils.paths.core_helper_config_dir / serial
            path.mkdir(parents=True, exist_ok=True)
            with suppress(FileNotFoundError):
                store.latest_path.unlink()
            store.latest_path.symlink_to(serial)

        _create_helper_config_dir(prev_prev_serial)
        _create_helper_config_dir(prev_serial)

        assert config.make_helper_config_path(prev_prev_serial).exists()
        assert config.make_helper_config_path(prev_serial).exists()
        assert store.latest_path.exists()
Beispiel #5
0
 def __init__(self, serial: ConfigSerial) -> None:
     self.serial: Final[ConfigSerial] = serial
     self.serial_path: Final[Path] = config.make_helper_config_path(serial)
     self.latest_path: Final[Path] = config.make_helper_config_path(LATEST_SERIAL)
 def test_host_check_source_file_path(self, serial):
     assert core_nagios.HostCheckStore.host_check_source_file_path(
         serial, "abc") == Path(config.make_helper_config_path(serial),
                                "host_checks", "abc.py")