test_simple.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. """
  2. Simple Smoke Tests for Connected Proxy Minion
  3. """
  4. from tests.support.helpers import slowTest
  5. def test_can_it_ping(salt_cli, salt_proxy):
  6. """
  7. Ensure the proxy can ping
  8. """
  9. ret = salt_cli.run("test.ping", minion_tgt=salt_proxy.id)
  10. assert ret.json is True
  11. def test_list_pkgs(salt_cli, salt_proxy):
  12. """
  13. Package test 1, really just tests that the virtual function capability
  14. is working OK.
  15. """
  16. ret = salt_cli.run("pkg.list_pkgs", minion_tgt=salt_proxy.id)
  17. assert "coreutils" in ret.json
  18. assert "apache" in ret.json
  19. assert "redbull" in ret.json
  20. def test_install_pkgs(salt_cli, salt_proxy):
  21. """
  22. Package test 2, really just tests that the virtual function capability
  23. is working OK.
  24. """
  25. ret = salt_cli.run("pkg.install", "thispkg", minion_tgt=salt_proxy.id)
  26. assert ret.json["thispkg"] == "1.0"
  27. ret = salt_cli.run("pkg.list_pkgs", minion_tgt=salt_proxy.id)
  28. assert ret.json["apache"] == "2.4"
  29. assert ret.json["redbull"] == "999.99"
  30. assert ret.json["thispkg"] == "1.0"
  31. def test_remove_pkgs(salt_cli, salt_proxy):
  32. ret = salt_cli.run("pkg.remove", "apache", minion_tgt=salt_proxy.id)
  33. assert "apache" not in ret.json
  34. def test_upgrade(salt_cli, salt_proxy):
  35. ret = salt_cli.run("pkg.upgrade", minion_tgt=salt_proxy.id)
  36. assert ret.json["coreutils"]["new"] == "2.0"
  37. assert ret.json["redbull"]["new"] == "1000.99"
  38. def test_service_list(salt_cli, salt_proxy):
  39. ret = salt_cli.run("service.list", minion_tgt=salt_proxy.id)
  40. assert "ntp" in ret.json
  41. def test_service_stop(salt_cli, salt_proxy):
  42. ret = salt_cli.run("service.stop", "ntp", minion_tgt=salt_proxy.id)
  43. ret = salt_cli.run("service.status", "ntp", minion_tgt=salt_proxy.id)
  44. assert ret.json is False
  45. def test_service_start(salt_cli, salt_proxy):
  46. ret = salt_cli.run("service.start", "samba", minion_tgt=salt_proxy.id)
  47. ret = salt_cli.run("service.status", "samba", minion_tgt=salt_proxy.id)
  48. assert ret.json is True
  49. def test_service_get_all(salt_cli, salt_proxy):
  50. ret = salt_cli.run("service.get_all", minion_tgt=salt_proxy.id)
  51. assert ret.json
  52. assert "samba" in ret.json
  53. def test_grains_items(salt_cli, salt_proxy):
  54. ret = salt_cli.run("grains.items", minion_tgt=salt_proxy.id)
  55. assert ret.json["kernel"] == "proxy"
  56. assert ret.json["kernelrelease"] == "proxy"
  57. def test_state_apply(salt_cli, salt_proxy):
  58. ret = salt_cli.run("state.apply", "core", minion_tgt=salt_proxy.id)
  59. for value in ret.json.values():
  60. assert value["result"] is True
  61. @slowTest
  62. def test_state_highstate(salt_cli, salt_proxy):
  63. ret = salt_cli.run("state.highstate", minion_tgt=salt_proxy.id)
  64. for value in ret.json.values():
  65. assert value["result"] is True