test_beacon.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """
  2. Integration tests for the beacon states
  3. """
  4. import pytest
  5. from tests.support.case import ModuleCase
  6. from tests.support.helpers import slowTest
  7. from tests.support.mixins import SaltReturnAssertsMixin
  8. @pytest.mark.usefixtures("salt_sub_minion")
  9. class BeaconStateTestCase(ModuleCase, SaltReturnAssertsMixin):
  10. """
  11. Test beacon states
  12. """
  13. def setUp(self):
  14. """
  15. """
  16. self.run_function("beacons.reset", f_timeout=300)
  17. self.wait_for_all_jobs()
  18. def tearDown(self):
  19. self.run_function("beacons.reset", f_timeout=300)
  20. @slowTest
  21. def test_present_absent(self):
  22. kwargs = {"/": "38%", "interval": 5}
  23. ret = self.run_state(
  24. "beacon.present", name="diskusage", f_timeout=300, **kwargs
  25. )
  26. self.assertSaltTrueReturn(ret)
  27. ret = self.run_function("beacons.list", return_yaml=False, f_timeout=300)
  28. self.assertTrue("diskusage" in ret)
  29. self.assertTrue({"interval": 5} in ret["diskusage"])
  30. self.assertTrue({"/": "38%"} in ret["diskusage"])
  31. ret = self.run_state("beacon.absent", name="diskusage", f_timeout=300)
  32. self.assertSaltTrueReturn(ret)
  33. ret = self.run_function("beacons.list", return_yaml=False, f_timeout=300)
  34. self.assertEqual(ret, {"beacons": {}})