test_lxd.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 destructiveTest, flaky
  13. from tests.support.mixins import SaltReturnAssertsMixin
  14. try:
  15. import pylxd # pylint: disable=import-error,unused-import
  16. HAS_PYLXD = True
  17. except ImportError:
  18. HAS_PYLXD = False
  19. @destructiveTest
  20. @skipIf(not salt.utils.path.which('lxd'), 'LXD not installed')
  21. @skipIf(not salt.utils.path.which('lxc'), 'LXC not installed')
  22. @skipIf(not HAS_PYLXD, 'pylxd not installed')
  23. class LxdTestCase(ModuleCase, SaltReturnAssertsMixin):
  24. run_once = False
  25. @flaky
  26. def test_01__init_lxd(self):
  27. if LxdTestCase.run_once:
  28. return
  29. ret = self.run_state('lxd.init', name='foobar')
  30. self.assertSaltTrueReturn(ret)
  31. LxdTestCase.run_once = True
  32. name = 'lxd_|-foobar_|-foobar_|-init'
  33. assert name in ret
  34. assert ret[name]['storage_backend'] == 'dir'