def test_overlay_usage(ansible_mounts, threshold, expect_fail, expect_msg): task_vars = non_atomic_task_vars() task_vars["ansible_mounts"] = ansible_mounts if threshold is not None: task_vars["max_overlay_usage_percent"] = threshold check = DockerStorage(None, task_vars) docker_info = dict(DockerRootDir="/var/lib/docker", Driver="overlay") result = check.check_overlay_usage(docker_info) assert expect_fail == bool(result.get("failed")) for msg in expect_msg: assert msg in result["msg"]
def test_overlay_usage(ansible_mounts, threshold, expect_fail, expect_msg): task_vars = non_atomic_task_vars() task_vars["ansible_mounts"] = ansible_mounts if threshold is not None: task_vars["max_overlay_usage_percent"] = threshold check = DockerStorage(None, task_vars) docker_info = dict(DockerRootDir="/var/lib/docker", Driver="overlay") result = check.check_overlay_usage(docker_info) assert expect_fail == bool(result.get("failed")) for msg in expect_msg: assert msg in result["msg"]
def test_check_storage_driver(docker_info, failed, expect_msg): def execute_module(module_name, *_): if module_name == "yum": return {} if module_name != "docker_info": raise ValueError("not expecting module " + module_name) return docker_info check = DockerStorage(execute_module, non_atomic_task_vars()) check.check_dm_usage = lambda status: dict() # stub out for this test check.check_overlay_usage = lambda info: dict() # stub out for this test result = check.run() if failed: assert result["failed"] else: assert not result.get("failed", False) for word in expect_msg: assert word in result["msg"]
def test_check_storage_driver(docker_info, failed, expect_msg): def execute_module(module_name, *_): if module_name == "yum": return {} if module_name != "docker_info": raise ValueError("not expecting module " + module_name) return docker_info check = DockerStorage(execute_module, non_atomic_task_vars()) check.check_dm_usage = lambda status: dict() # stub out for this test check.check_overlay_usage = lambda info: dict() # stub out for this test result = check.run() if failed: assert result["failed"] else: assert not result.get("failed", False) for word in expect_msg: assert word in result["msg"]