1
0

conftest.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. salt_sub_minion,
  49. ):
  50. yield
  51. @pytest.fixture(scope="package")
  52. def salt_cli(salt_factories, salt_minion, salt_master):
  53. return salt_factories.get_salt_cli(salt_master.config["id"])
  54. @pytest.fixture(scope="package")
  55. def salt_cp_cli(salt_factories, salt_minion, salt_master):
  56. return salt_factories.get_salt_cp_cli(salt_master.config["id"])
  57. @pytest.fixture(scope="package")
  58. def salt_key_cli(salt_factories, salt_minion, salt_master):
  59. return salt_factories.get_salt_key_cli(salt_master.config["id"])
  60. @pytest.fixture(scope="package")
  61. def salt_run_cli(salt_factories, salt_minion, salt_master):
  62. return salt_factories.get_salt_run_cli(salt_master.config["id"])
  63. @pytest.fixture(scope="package")
  64. def salt_call_cli(salt_factories, salt_minion, salt_master):
  65. return salt_factories.get_salt_call_cli(salt_minion.config["id"])