コード例 #1
0
def tmp_manager(monkeypatch):
    """
    Create fresh _ResourceManager instance for testing.
    """
    manager = rm._ResourceManager()
    manager.registerNamespace("storage", rm.SimpleResourceFactory())
    manager.registerNamespace("null", NullResourceFactory())
    manager.registerNamespace("string", StringResourceFactory())
    manager.registerNamespace("error", ErrorResourceFactory())
    manager.registerNamespace("switchfail", SwitchFailFactory())
    manager.registerNamespace("crashy", CrashOnCloseFactory())
    manager.registerNamespace("failAfterSwitch", FailAfterSwitchFactory())
    monkeypatch.setattr(rm, "_manager", manager)
コード例 #2
0
def manager():
    """
    Create fresh _ResourceManager instance for testing.
    """
    manager = rm._ResourceManager()
    manager.registerNamespace("storage", rm.SimpleResourceFactory())
    manager.registerNamespace("null", NullResourceFactory())
    manager.registerNamespace("string", StringResourceFactory())
    manager.registerNamespace("error", ErrorResourceFactory())
    manager.registerNamespace("switchfail", SwitchFailFactory())
    manager.registerNamespace("crashy", CrashOnCloseFactory())
    manager.registerNamespace("failAfterSwitch", FailAfterSwitchFactory())
    return manager
コード例 #3
0
def manager():
    """
    Create fresh _ResourceManager instance for testing.
    """
    manager = rm._ResourceManager()
    manager.registerNamespace("storage", rm.SimpleResourceFactory())
    manager.registerNamespace("null", NullResourceFactory())
    manager.registerNamespace("string", StringResourceFactory())
    manager.registerNamespace("error", ErrorResourceFactory())
    manager.registerNamespace("switchfail", SwitchFailFactory())
    manager.registerNamespace("crashy", CrashOnCloseFactory())
    manager.registerNamespace("failAfterSwitch", FailAfterSwitchFactory())
    return manager
コード例 #4
0
def tmp_repo(tmpdir, monkeypatch, tmp_fs):
    """
    Provide a temporary repo directory and patch vsdm to use it instead of
    /rhev/data-center.
    """
    repo = tmprepo.TemporaryRepo(tmpdir, tmp_fs)

    # Patch repo directory.
    monkeypatch.setattr(sc, "REPO_DATA_CENTER", repo.path)
    monkeypatch.setattr(sc, "REPO_MOUNT_DIR", repo.mnt_dir)

    # Patch multipath discovery and resize
    monkeypatch.setattr(multipath, "rescan", lambda: None)
    monkeypatch.setattr(multipath, "resize_devices", lambda: None)

    # Patch the resource manager.
    manager = rm._ResourceManager()
    manager.registerNamespace(sc.STORAGE, rm.SimpleResourceFactory())
    monkeypatch.setattr(rm, "_manager", manager)

    # Invalidate sdCache so stale data from previous test will affect
    # this test.
    sdCache.refresh()
    sdCache.knownSDs.clear()

    try:
        yield repo
    finally:
        # ioprocess is typically invoked from tests using tmp_repo. This
        # terminate ioprocess instances, avoiding thread and process leaks in
        # tests, and errors in __del__ during test shutdown.
        oop.stop()

        # Invalidate sdCache so stale data from this test will affect
        # the next test.
        sdCache.refresh()
        sdCache.knownSDs.clear()