1
0

test_test.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import salt.config
  2. import salt.version
  3. def test_ping(
  4. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  5. ):
  6. """
  7. test.ping
  8. """
  9. ret = mm_master_1_salt_cli.run("test.ping", minion_tgt=salt_mm_minion_1.id)
  10. assert ret.exitcode == 0
  11. assert ret.json is True
  12. ret = mm_master_2_salt_cli.run("test.ping", minion_tgt=salt_mm_minion_1.id)
  13. assert ret.exitcode == 0
  14. assert ret.json is True
  15. ret = mm_master_1_salt_cli.run("test.ping", minion_tgt=salt_mm_minion_2.id)
  16. assert ret.exitcode == 0
  17. assert ret.json is True
  18. ret = mm_master_2_salt_cli.run("test.ping", minion_tgt=salt_mm_minion_2.id)
  19. assert ret.exitcode == 0
  20. assert ret.json is True
  21. def test_echo(
  22. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  23. ):
  24. """
  25. test.echo
  26. """
  27. ret = mm_master_1_salt_cli.run("test.echo", "text", minion_tgt=salt_mm_minion_1.id)
  28. assert ret.exitcode == 0
  29. assert ret.json == "text"
  30. ret = mm_master_2_salt_cli.run("test.echo", "text", minion_tgt=salt_mm_minion_1.id)
  31. assert ret.exitcode == 0
  32. assert ret.json == "text"
  33. ret = mm_master_1_salt_cli.run("test.echo", "text", minion_tgt=salt_mm_minion_2.id)
  34. assert ret.exitcode == 0
  35. assert ret.json == "text"
  36. ret = mm_master_2_salt_cli.run("test.echo", "text", minion_tgt=salt_mm_minion_2.id)
  37. assert ret.exitcode == 0
  38. assert ret.json == "text"
  39. def test_version(
  40. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  41. ):
  42. """
  43. test.version
  44. """
  45. ret = mm_master_1_salt_cli.run("test.version", minion_tgt=salt_mm_minion_1.id)
  46. assert ret.exitcode == 0
  47. assert ret.json == salt.version.__saltstack_version__.string
  48. ret = mm_master_2_salt_cli.run("test.version", minion_tgt=salt_mm_minion_1.id)
  49. assert ret.exitcode == 0
  50. assert ret.json == salt.version.__saltstack_version__.string
  51. ret = mm_master_1_salt_cli.run("test.version", minion_tgt=salt_mm_minion_2.id)
  52. assert ret.exitcode == 0
  53. assert ret.json == salt.version.__saltstack_version__.string
  54. ret = mm_master_2_salt_cli.run("test.version", minion_tgt=salt_mm_minion_2.id)
  55. assert ret.exitcode == 0
  56. assert ret.json == salt.version.__saltstack_version__.string
  57. def test_conf_test(
  58. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  59. ):
  60. """
  61. test.conf_text
  62. """
  63. ret = mm_master_1_salt_cli.run("test.conf_test", minion_tgt=salt_mm_minion_1.id)
  64. assert ret.exitcode == 0
  65. assert ret.json == "baz"
  66. ret = mm_master_2_salt_cli.run("test.conf_test", minion_tgt=salt_mm_minion_1.id)
  67. assert ret.exitcode == 0
  68. assert ret.json == "baz"
  69. ret = mm_master_1_salt_cli.run("test.conf_test", minion_tgt=salt_mm_minion_2.id)
  70. assert ret.exitcode == 0
  71. assert ret.json == "baz"
  72. ret = mm_master_2_salt_cli.run("test.conf_test", minion_tgt=salt_mm_minion_2.id)
  73. assert ret.exitcode == 0
  74. assert ret.json == "baz"
  75. def test_cross_test(
  76. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  77. ):
  78. """
  79. test.cross_text
  80. """
  81. ret = mm_master_1_salt_cli.run(
  82. "test.cross_test", "test.ping", minion_tgt=salt_mm_minion_1.id
  83. )
  84. assert ret.exitcode == 0
  85. assert ret.json is True
  86. ret = mm_master_2_salt_cli.run(
  87. "test.cross_test", "test.ping", minion_tgt=salt_mm_minion_1.id
  88. )
  89. assert ret.exitcode == 0
  90. assert ret.json is True
  91. ret = mm_master_1_salt_cli.run(
  92. "test.cross_test", "test.ping", minion_tgt=salt_mm_minion_2.id
  93. )
  94. assert ret.exitcode == 0
  95. assert ret.json is True
  96. ret = mm_master_2_salt_cli.run(
  97. "test.cross_test", "test.ping", minion_tgt=salt_mm_minion_2.id
  98. )
  99. assert ret.exitcode == 0
  100. assert ret.json is True
  101. def test_outputter(
  102. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  103. ):
  104. """
  105. test.outputter
  106. """
  107. ret = mm_master_1_salt_cli.run(
  108. "test.outputter", "text", minion_tgt=salt_mm_minion_1.id
  109. )
  110. assert ret.exitcode == 0
  111. assert ret.json == "text"
  112. ret = mm_master_2_salt_cli.run(
  113. "test.outputter", "text", minion_tgt=salt_mm_minion_1.id
  114. )
  115. assert ret.exitcode == 0
  116. assert ret.json == "text"
  117. ret = mm_master_1_salt_cli.run(
  118. "test.outputter", "text", minion_tgt=salt_mm_minion_2.id
  119. )
  120. assert ret.exitcode == 0
  121. assert ret.json == "text"
  122. ret = mm_master_2_salt_cli.run(
  123. "test.outputter", "text", minion_tgt=salt_mm_minion_2.id
  124. )
  125. assert ret.exitcode == 0
  126. assert ret.json == "text"
  127. def test_fib(
  128. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  129. ):
  130. """
  131. test.fib
  132. """
  133. ret = mm_master_1_salt_cli.run("test.fib", "20", minion_tgt=salt_mm_minion_1.id)
  134. assert ret.exitcode == 0
  135. assert ret.json[0] == 6765
  136. ret = mm_master_2_salt_cli.run("test.fib", "20", minion_tgt=salt_mm_minion_1.id)
  137. assert ret.exitcode == 0
  138. assert ret.json[0] == 6765
  139. ret = mm_master_1_salt_cli.run("test.fib", "20", minion_tgt=salt_mm_minion_2.id)
  140. assert ret.exitcode == 0
  141. assert ret.json[0] == 6765
  142. ret = mm_master_2_salt_cli.run("test.fib", "20", minion_tgt=salt_mm_minion_2.id)
  143. assert ret.exitcode == 0
  144. assert ret.json[0] == 6765
  145. def test_collatz(
  146. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  147. ):
  148. """
  149. test.fib
  150. """
  151. ret = mm_master_1_salt_cli.run("test.collatz", "40", minion_tgt=salt_mm_minion_1.id)
  152. assert ret.exitcode == 0
  153. assert ret.json[0][-1] == 2
  154. ret = mm_master_2_salt_cli.run("test.collatz", "40", minion_tgt=salt_mm_minion_1.id)
  155. assert ret.exitcode == 0
  156. assert ret.json[0][-1] == 2
  157. ret = mm_master_1_salt_cli.run("test.collatz", "40", minion_tgt=salt_mm_minion_2.id)
  158. assert ret.exitcode == 0
  159. assert ret.json[0][-1] == 2
  160. ret = mm_master_2_salt_cli.run("test.collatz", "40", minion_tgt=salt_mm_minion_2.id)
  161. assert ret.exitcode == 0
  162. assert ret.json[0][-1] == 2
  163. def test_get_opts(
  164. mm_master_1_salt_cli, salt_mm_minion_1, mm_master_2_salt_cli, salt_mm_minion_2
  165. ):
  166. """
  167. test.conf_text
  168. """
  169. ret = mm_master_1_salt_cli.run("test.get_opts", minion_tgt=salt_mm_minion_1.id)
  170. assert ret.exitcode == 0
  171. assert ret.json["cachedir"] == salt_mm_minion_1.config["cachedir"]
  172. ret = mm_master_2_salt_cli.run("test.get_opts", minion_tgt=salt_mm_minion_1.id)
  173. assert ret.exitcode == 0
  174. assert ret.json["cachedir"] == salt_mm_minion_1.config["cachedir"]
  175. ret = mm_master_1_salt_cli.run("test.get_opts", minion_tgt=salt_mm_minion_2.id)
  176. assert ret.exitcode == 0
  177. assert ret.json["cachedir"] == salt_mm_minion_2.config["cachedir"]
  178. ret = mm_master_2_salt_cli.run("test.get_opts", minion_tgt=salt_mm_minion_2.id)
  179. assert ret.exitcode == 0
  180. assert ret.json["cachedir"] == salt_mm_minion_2.config["cachedir"]