test_swarm.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. """
  2. Integration tests for the docker swarm modules
  3. """
  4. import salt.utils.path
  5. from tests.support.case import ModuleCase
  6. from tests.support.helpers import destructiveTest, slowTest
  7. from tests.support.mixins import SaltReturnAssertsMixin
  8. from tests.support.unit import skipIf
  9. @destructiveTest
  10. @skipIf(
  11. not any(salt.utils.path.which(exe) for exe in ("dockerd", "docker")),
  12. "Docker not installed",
  13. )
  14. class SwarmCallTestCase(ModuleCase, SaltReturnAssertsMixin):
  15. """
  16. Test docker swarm states
  17. """
  18. @slowTest
  19. def test_swarm_init(self):
  20. """
  21. check that swarm.swarm_init works when a swarm exists
  22. """
  23. self.run_function("swarm.swarm_init", ["127.0.0.1", "0.0.0.0", False])
  24. ret = self.run_function("swarm.swarm_init", ["127.0.0.1", "0.0.0.0", False])
  25. expected = {
  26. "Comment": 'This node is already part of a swarm. Use "docker swarm leave" to leave this swarm and join another one.',
  27. "result": False,
  28. }
  29. self.assertEqual(expected, ret)