test_lxd.py 1.2 KB

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