"Fossies" - the Fresh Open Source Software Archive

Member "salt-3002.2/tests/pytests/integration/proxy/test_shell.py" (18 Nov 2020, 2453 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_shell.py": 3002.1_vs_3002.2.

    1 """
    2     tests.integration.proxy.test_shell
    3     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    4 
    5     Test salt-call --proxyid <proxyid> commands
    6 """
    7 
    8 import logging
    9 import os
   10 import random
   11 
   12 import pytest
   13 import salt.proxy.dummy
   14 import salt.utils.path
   15 import salt.utils.platform
   16 from tests.support.helpers import slowTest
   17 
   18 log = logging.getLogger(__name__)
   19 
   20 
   21 @pytest.fixture(scope="module")
   22 def salt_proxy(salt_proxy):
   23     cachefile = os.path.join(salt_proxy.config["cachedir"], "dummy-proxy.cache")
   24     if os.path.exists(cachefile):
   25         os.unlink(cachefile)
   26     return salt_proxy
   27 
   28 
   29 @pytest.fixture
   30 def salt_call_cli(salt_proxy):
   31     return salt_proxy.get_salt_call_cli(default_timeout=120)
   32 
   33 
   34 @slowTest
   35 def test_can_it_ping(salt_call_cli):
   36     """
   37     Ensure the proxy can ping
   38     """
   39     ret = salt_call_cli.run("test.ping")
   40     assert ret.exitcode == 0, ret
   41     assert ret.json is True
   42 
   43 
   44 @slowTest
   45 def test_list_pkgs(salt_call_cli):
   46     """
   47     Package test 1, really just tests that the virtual function capability
   48     is working OK.
   49     """
   50     ret = salt_call_cli.run("pkg.list_pkgs")
   51     assert ret.exitcode == 0, ret
   52     for package_name in salt.proxy.dummy._initial_state()["packages"]:
   53         assert package_name in ret.json
   54 
   55 
   56 @slowTest
   57 def test_upgrade(salt_call_cli):
   58     ret = salt_call_cli.run("pkg.upgrade")
   59     assert ret.exitcode == 0, ret
   60     # Assert that something got upgraded
   61     assert ret.json
   62     assert ret.json["coreutils"]["new"] == "2.0"
   63     assert ret.json["redbull"]["new"], "1000.99"
   64 
   65 
   66 @pytest.fixture
   67 def service_name():
   68     return random.choice(list(salt.proxy.dummy._initial_state()["services"]))
   69 
   70 
   71 @slowTest
   72 def test_service_list(salt_call_cli, service_name):
   73     ret = salt_call_cli.run("service.list")
   74     assert ret.exitcode == 0, ret
   75     assert service_name in ret.json
   76 
   77 
   78 @slowTest
   79 def test_service_start(salt_call_cli):
   80     ret = salt_call_cli.run("service.start", "samba")
   81     assert ret.exitcode == 0, ret
   82     ret = salt_call_cli.run("service.status", "samba")
   83     assert ret.exitcode == 0, ret
   84     assert ret.json is True
   85 
   86 
   87 @slowTest
   88 def test_service_get_all(salt_call_cli, service_name):
   89     ret = salt_call_cli.run("service.get_all")
   90     assert ret.exitcode == 0, ret
   91     assert service_name in ret.json
   92 
   93 
   94 @slowTest
   95 def test_grains_items(salt_call_cli):
   96     ret = salt_call_cli.run("grains.items")
   97     assert ret.exitcode == 0, ret
   98     assert ret.json["kernel"] == "proxy"
   99     assert ret.json["kernelrelease"] == "proxy"