Skip to content

Commit

Permalink
test: add no_thinpool unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealFalcon committed Oct 11, 2024
1 parent a9841a0 commit d64ecfc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/unittests/config/test_cc_lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

from cloudinit import subp
from cloudinit.config import cc_lxd
from cloudinit.config.schema import (
SchemaValidationError,
Expand Down Expand Up @@ -259,6 +260,36 @@ def test_lxd_cmd_none(self):
data = {"mode": "none"}
assert cc_lxd.bridge_to_cmd(data) == (None, None)

def test_no_thinpool(self, mocker, caplog):
def my_subp(*args, **kwargs):
if args[0] == ["lxd", "init", "--auto", "--storage-backend=lvm"]:
raise subp.ProcessExecutionError(
stderr='Error: Failed to create storage pool "default"',
exit_code=1,
)
return ("", "")

m_subp = mocker.patch(
"cloudinit.config.cc_lxd.subp.subp",
side_effect=my_subp,
)
cc_lxd.handle_init_cfg({"storage_backend": "lvm"})
assert "Cloud-init doesn't use thinpool" in caplog.text
assert (
mock.call(
[
"lxc",
"storage",
"create",
"default",
"lvm",
"lvm.use_thinpool=false",
]
)
in m_subp.call_args_list
)
assert mock.call(["lxd", "init", "--auto"]) in m_subp.call_args_list


class TestLxdMaybeCleanupDefault:
"""Test the implementation of maybe_cleanup_default."""
Expand Down

0 comments on commit d64ecfc

Please sign in to comment.