conftest.py 2.7 KB

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