test_lxd.py 1017 B

123456789101112131415161718192021222324252627282930313233343536
  1. """
  2. Integration tests for the lxd states
  3. """
  4. import salt.utils.path
  5. from tests.support.case import ModuleCase
  6. from tests.support.helpers import destructiveTest, flaky
  7. from tests.support.mixins import SaltReturnAssertsMixin
  8. from tests.support.unit import skipIf
  9. try:
  10. import pylxd # pylint: disable=import-error,unused-import
  11. HAS_PYLXD = True
  12. except ImportError:
  13. HAS_PYLXD = False
  14. @destructiveTest
  15. @skipIf(not salt.utils.path.which("lxd"), "LXD not installed")
  16. @skipIf(not salt.utils.path.which("lxc"), "LXC not installed")
  17. @skipIf(not HAS_PYLXD, "pylxd not installed")
  18. class LxdTestCase(ModuleCase, SaltReturnAssertsMixin):
  19. run_once = False
  20. @flaky
  21. def test_01__init_lxd(self):
  22. if LxdTestCase.run_once:
  23. return
  24. ret = self.run_state("lxd.init", name="foobar")
  25. self.assertSaltTrueReturn(ret)
  26. LxdTestCase.run_once = True
  27. name = "lxd_|-foobar_|-foobar_|-init"
  28. assert name in ret
  29. assert ret[name]["storage_backend"] == "dir"