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. from tests.support.pytest.fixtures import * # pylint: disable=unused-wildcard-import
  12. log = logging.getLogger(__name__)
  13. # @pytest.fixture(scope='package')
  14. # def salt_syndic_master(request, salt_factories):
  15. # return salt_factories.spawn_master(request, 'syndic_master', order_masters=True)
  16. # @pytest.fixture(scope='package')
  17. # def salt_syndic(request, salt_factories, salt_syndic_master):
  18. # return salt_factories.spawn_syndic(request, 'syndic', master_of_masters_id='syndic_master')
  19. # @pytest.fixture(scope='package')
  20. # def salt_master(request, salt_factories, salt_syndic_master):
  21. # return salt_factories.spawn_master(request, 'master', master_of_masters_id='syndic_master')
  22. @pytest.fixture(scope="package")
  23. def salt_master(request, salt_factories):
  24. return salt_factories.spawn_master(request, "master")
  25. @pytest.fixture(scope="package")
  26. def salt_minion(request, salt_factories, salt_master):
  27. proc = salt_factories.spawn_minion(request, "minion", master_id="master")
  28. # Sync All
  29. salt_call_cli = salt_factories.get_salt_call_cli("minion")
  30. ret = salt_call_cli.run("saltutil.sync_all", _timeout=120)
  31. assert ret.exitcode == 0, ret
  32. return proc
  33. @pytest.fixture(scope="package")
  34. def salt_sub_minion(request, salt_factories, salt_master):
  35. proc = salt_factories.spawn_minion(request, "sub_minion", master_id="master")
  36. # Sync All
  37. salt_call_cli = salt_factories.get_salt_call_cli("sub_minion")
  38. ret = salt_call_cli.run("saltutil.sync_all", _timeout=120)
  39. assert ret.exitcode == 0, ret
  40. return proc
  41. @pytest.fixture(scope="package", autouse=True)
  42. def bridge_pytest_and_runtests_integration(
  43. bridge_pytest_and_runtests,
  44. salt_factories,
  45. # salt_syndic_master,
  46. # salt_syndic,
  47. salt_master,
  48. salt_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"])