conftest.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # -*- coding: utf-8 -*-
  2. """
  3. tests.integration.conftest
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. Integration tests PyTest configuration/fixtures
  6. """
  7. # pylint: disable=unused-argument,redefined-outer-name
  8. from __future__ import absolute_import, unicode_literals
  9. import logging
  10. import pytest
  11. log = logging.getLogger(__name__)
  12. # @pytest.fixture(scope='package')
  13. # def salt_syndic_master(request, salt_factories):
  14. # return salt_factories.spawn_master(request, 'syndic_master', order_masters=True)
  15. # @pytest.fixture(scope='package')
  16. # def salt_syndic(request, salt_factories, salt_syndic_master):
  17. # return salt_factories.spawn_syndic(request, 'syndic', master_of_masters_id='syndic_master')
  18. # @pytest.fixture(scope='package')
  19. # def salt_master(request, salt_factories, salt_syndic_master):
  20. # return salt_factories.spawn_master(request, 'master', master_of_masters_id='syndic_master')
  21. @pytest.fixture(scope="package")
  22. def salt_master(request, salt_factories):
  23. return salt_factories.spawn_master(request, "master")
  24. @pytest.fixture(scope="package")
  25. def salt_minion(request, salt_factories, salt_master):
  26. proc = salt_factories.spawn_minion(request, "minion", master_id="master")
  27. # Sync All
  28. salt_call_cli = salt_factories.get_salt_call_cli("minion")
  29. ret = salt_call_cli.run("saltutil.sync_all", _timeout=120)
  30. assert ret.exitcode == 0, ret
  31. return proc
  32. @pytest.fixture(scope="package")
  33. def salt_sub_minion(request, salt_factories, salt_master):
  34. proc = salt_factories.spawn_minion(request, "sub_minion", master_id="master")
  35. # Sync All
  36. salt_call_cli = salt_factories.get_salt_call_cli("sub_minion")
  37. ret = salt_call_cli.run("saltutil.sync_all", _timeout=120)
  38. assert ret.exitcode == 0, ret
  39. return proc
  40. @pytest.fixture(scope="package", autouse=True)
  41. def bridge_pytest_and_runtests(
  42. bridge_pytest_and_runtests,
  43. salt_factories,
  44. # salt_syndic_master,
  45. # salt_syndic,
  46. salt_master,
  47. salt_minion,
  48. ):
  49. yield
  50. @pytest.fixture(scope="package")
  51. def salt_cli(salt_factories, salt_minion, salt_master):
  52. return salt_factories.get_salt_cli(salt_master.config["id"])
  53. @pytest.fixture(scope="package")
  54. def salt_cp_cli(salt_factories, salt_minion, salt_master):
  55. return salt_factories.get_salt_cp_cli(salt_master.config["id"])
  56. @pytest.fixture(scope="package")
  57. def salt_key_cli(salt_factories, salt_minion, salt_master):
  58. return salt_factories.get_salt_key_cli(salt_master.config["id"])
  59. @pytest.fixture(scope="package")
  60. def salt_run_cli(salt_factories, salt_minion, salt_master):
  61. return salt_factories.get_salt_run_cli(salt_master.config["id"])
  62. @pytest.fixture(scope="package")
  63. def salt_call_cli(salt_factories, salt_minion, salt_master):
  64. return salt_factories.get_salt_call_cli(salt_minion.config["id"])