conftest.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. """
  2. tests.pytests.integration.conftest
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. PyTest fixtures
  5. """
  6. import pytest
  7. @pytest.fixture(scope="package")
  8. def salt_master(salt_master_factory):
  9. """
  10. We override the fixture so that we have the daemon running
  11. """
  12. with salt_master_factory.started():
  13. yield salt_master_factory
  14. @pytest.fixture(scope="package")
  15. def salt_minion(salt_master, salt_minion_factory):
  16. """
  17. We override the fixture so that we have the daemon running
  18. """
  19. assert salt_master.is_running()
  20. with salt_minion_factory.started():
  21. # Sync All
  22. salt_call_cli = salt_minion_factory.get_salt_call_cli()
  23. ret = salt_call_cli.run("saltutil.sync_all", _timeout=120)
  24. assert ret.exitcode == 0, ret
  25. yield salt_minion_factory
  26. @pytest.fixture(scope="module")
  27. def salt_sub_minion(salt_master, salt_sub_minion_factory):
  28. """
  29. We override the fixture so that we have the daemon running
  30. """
  31. assert salt_master.is_running()
  32. with salt_sub_minion_factory.started():
  33. # Sync All
  34. salt_call_cli = salt_sub_minion_factory.get_salt_call_cli()
  35. ret = salt_call_cli.run("saltutil.sync_all", _timeout=120)
  36. assert ret.exitcode == 0, ret
  37. yield salt_sub_minion_factory
  38. @pytest.fixture(scope="package")
  39. def salt_proxy(salt_master, salt_proxy_factory):
  40. assert salt_master.is_running()
  41. with salt_proxy_factory.started():
  42. yield salt_proxy_factory
  43. @pytest.fixture(scope="package")
  44. def salt_cli(salt_master):
  45. assert salt_master.is_running()
  46. return salt_master.get_salt_cli()
  47. @pytest.fixture(scope="package")
  48. def salt_call_cli(salt_minion):
  49. assert salt_minion.is_running()
  50. return salt_minion.get_salt_call_cli()
  51. @pytest.fixture(scope="package")
  52. def salt_cp_cli(salt_master):
  53. assert salt_master.is_running()
  54. return salt_master.get_salt_cp_cli()
  55. @pytest.fixture(scope="package")
  56. def salt_key_cli(salt_master):
  57. assert salt_master.is_running()
  58. return salt_master.get_salt_key_cli()
  59. @pytest.fixture(scope="package")
  60. def salt_run_cli(salt_master):
  61. assert salt_master.is_running()
  62. return salt_master.get_salt_run_cli()
  63. @pytest.fixture(scope="package")
  64. def salt_ssh_cli(salt_master):
  65. assert salt_master.is_running()
  66. return salt_master.get_salt_ssh_cli()