1
0

test_beacon.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. """
  3. Integration tests for the beacon states
  4. """
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. import pytest
  7. # Import Salt Testing Libs
  8. from tests.support.case import ModuleCase
  9. from tests.support.mixins import SaltReturnAssertsMixin
  10. class BeaconStateTestCase(ModuleCase, SaltReturnAssertsMixin):
  11. """
  12. Test beacon states
  13. """
  14. def setUp(self):
  15. """
  16. """
  17. self.run_function("beacons.reset", f_timeout=300)
  18. self.wait_for_all_jobs()
  19. def tearDown(self):
  20. self.run_function("beacons.reset", f_timeout=300)
  21. @pytest.mark.slow_test(seconds=30) # Test takes >10 and <=30 seconds
  22. def test_present_absent(self):
  23. kwargs = {"/": "38%", "interval": 5}
  24. ret = self.run_state(
  25. "beacon.present", name="diskusage", f_timeout=300, **kwargs
  26. )
  27. self.assertSaltTrueReturn(ret)
  28. ret = self.run_function("beacons.list", return_yaml=False, f_timeout=300)
  29. self.assertTrue("diskusage" in ret)
  30. self.assertTrue({"interval": 5} in ret["diskusage"])
  31. self.assertTrue({"/": "38%"} in ret["diskusage"])
  32. ret = self.run_state("beacon.absent", name="diskusage", f_timeout=300)
  33. self.assertSaltTrueReturn(ret)
  34. ret = self.run_function("beacons.list", return_yaml=False, f_timeout=300)
  35. self.assertEqual(ret, {"beacons": {}})