1
0

test_lxd.py 1.1 KB

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