"Fossies" - the Fresh Open Source Software Archive

Member "salt-3002.2/tests/pytests/integration/proxy/test_simple.py" (18 Nov 2020, 3031 Bytes) of package /linux/misc/salt-3002.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test_simple.py": 3002.1_vs_3002.2.

    1 """
    2 Simple Smoke Tests for Connected Proxy Minion
    3 """
    4 import os
    5 
    6 import pytest
    7 from tests.support.helpers import slowTest
    8 
    9 
   10 @pytest.fixture(scope="module")
   11 def salt_proxy(salt_proxy):
   12     cachefile = os.path.join(salt_proxy.config["cachedir"], "dummy-proxy.cache")
   13     if os.path.exists(cachefile):
   14         os.unlink(cachefile)
   15     return salt_proxy
   16 
   17 
   18 def test_can_it_ping(salt_cli, salt_proxy):
   19     """
   20     Ensure the proxy can ping
   21     """
   22     ret = salt_cli.run("test.ping", minion_tgt=salt_proxy.id)
   23     assert ret.json is True
   24 
   25 
   26 def test_list_pkgs(salt_cli, salt_proxy):
   27     """
   28     Package test 1, really just tests that the virtual function capability
   29     is working OK.
   30     """
   31     ret = salt_cli.run("pkg.list_pkgs", minion_tgt=salt_proxy.id)
   32     assert "coreutils" in ret.json
   33     assert "apache" in ret.json
   34     assert "redbull" in ret.json
   35 
   36 
   37 def test_install_pkgs(salt_cli, salt_proxy):
   38     """
   39     Package test 2, really just tests that the virtual function capability
   40     is working OK.
   41     """
   42     ret = salt_cli.run("pkg.install", "thispkg", minion_tgt=salt_proxy.id)
   43     assert ret.json["thispkg"] == "1.0"
   44 
   45     ret = salt_cli.run("pkg.list_pkgs", minion_tgt=salt_proxy.id)
   46 
   47     assert ret.json["apache"] == "2.4"
   48     assert ret.json["redbull"] == "999.99"
   49     assert ret.json["thispkg"] == "1.0"
   50 
   51 
   52 def test_remove_pkgs(salt_cli, salt_proxy):
   53     ret = salt_cli.run("pkg.remove", "apache", minion_tgt=salt_proxy.id)
   54     assert "apache" not in ret.json
   55 
   56 
   57 def test_upgrade(salt_cli, salt_proxy):
   58     ret = salt_cli.run("pkg.upgrade", minion_tgt=salt_proxy.id)
   59     assert ret.json["coreutils"]["new"] == "2.0"
   60     assert ret.json["redbull"]["new"] == "1000.99"
   61 
   62 
   63 def test_service_list(salt_cli, salt_proxy):
   64     ret = salt_cli.run("service.list", minion_tgt=salt_proxy.id)
   65     assert "ntp" in ret.json
   66 
   67 
   68 def test_service_stop(salt_cli, salt_proxy):
   69     ret = salt_cli.run("service.stop", "ntp", minion_tgt=salt_proxy.id)
   70     ret = salt_cli.run("service.status", "ntp", minion_tgt=salt_proxy.id)
   71     assert ret.json is False
   72 
   73 
   74 def test_service_start(salt_cli, salt_proxy):
   75     ret = salt_cli.run("service.start", "samba", minion_tgt=salt_proxy.id)
   76     ret = salt_cli.run("service.status", "samba", minion_tgt=salt_proxy.id)
   77     assert ret.json is True
   78 
   79 
   80 def test_service_get_all(salt_cli, salt_proxy):
   81     ret = salt_cli.run("service.get_all", minion_tgt=salt_proxy.id)
   82     assert ret.json
   83     assert "samba" in ret.json
   84 
   85 
   86 def test_grains_items(salt_cli, salt_proxy):
   87     ret = salt_cli.run("grains.items", minion_tgt=salt_proxy.id)
   88     assert ret.json["kernel"] == "proxy"
   89     assert ret.json["kernelrelease"] == "proxy"
   90 
   91 
   92 def test_state_apply(salt_cli, salt_proxy):
   93     ret = salt_cli.run("state.apply", "core", minion_tgt=salt_proxy.id)
   94     for value in ret.json.values():
   95         assert value["result"] is True
   96 
   97 
   98 @slowTest
   99 def test_state_highstate(salt_cli, salt_proxy):
  100     ret = salt_cli.run("state.highstate", minion_tgt=salt_proxy.id)
  101     for value in ret.json.values():
  102         assert value["result"] is True