salt.modules.test

Module for running arbitrary tests

salt.modules.test.arg(*args, **kwargs)

Print out the data passed into the function *args and `kwargs, this is used to both test the publication data and cli argument passing, but also to display the information available within the publication data. Returns {"args": args, "kwargs": kwargs}.

CLI 范例:

salt '*' test.arg 1 "two" 3.1 txt="hello" wow='{a: 1, b: "hello"}'
salt.modules.test.arg_repr(*args, **kwargs)

Print out the data passed into the function *args and `kwargs, this is used to both test the publication data and cli argument passing, but also to display the information available within the publication data. Returns {"args": repr(args), "kwargs": repr(kwargs)}.

CLI 范例:

salt '*' test.arg_repr 1 "two" 3.1 txt="hello" wow='{a: 1, b: "hello"}'
salt.modules.test.arg_type(*args, **kwargs)

Print out the types of the args and kwargs. This is used to test the types of the args and kwargs passed down to the minion

CLI 范例:

salt '*' test.arg_type 1 'int'
salt.modules.test.assertion(assertion)

Assert the given argument

CLI 范例:

salt '*' test.assert False
salt.modules.test.attr_call()

Call grains.items via the attribute

CLI Example:

.. code-block:: bash
salt '*' test.attr_call
salt.modules.test.collatz(start)

Execute the collatz conjecture from the passed starting number, returns the sequence and the time it took to compute. Used for performance tests.

CLI 范例:

salt '*' test.collatz 3
salt.modules.test.conf_test()

Return the value for test.foo in the minion configuration file, or return the default value

CLI 范例:

salt '*' test.conf_test
salt.modules.test.cross_test(func, args=None)

Execute a minion function via the __salt__ object in the test module, used to verify that the minion functions can be called via the __salt__ module.

CLI 范例:

salt '*' test.cross_test file.gid_to_group 0
salt.modules.test.echo(text)

Return a string - used for testing the connection

CLI 范例:

salt '*' test.echo 'foo bar baz quo qux'
salt.modules.test.exception(message='Test Exception')

Raise an exception

Optionally provide an error message or output the full stack.

CLI 范例:

salt '*' test.exception 'Oh noes!'
salt.modules.test.false()

Always return False

CLI 范例:

salt '*' test.false
salt.modules.test.fib(num)

Return the num-th Fibonacci number, and the time it took to compute in seconds. Used for performance tests.

This function is designed to have terrible performance.

CLI 范例:

salt '*' test.fib 3
salt.modules.test.get_opts()

Return the configuration options passed to this minion

CLI 范例:

salt '*' test.get_opts
salt.modules.test.kwarg(**kwargs)

Print out the data passed into the function **kwargs, this is used to both test the publication data and cli kwarg passing, but also to display the information available within the publication data.

CLI 范例:

salt '*' test.kwarg num=1 txt="two" env='{a: 1, b: "hello"}'
salt.modules.test.missing_func()
salt.modules.test.module_report()

Return a dict containing all of the execution modules with a report on the overall availability via different references

CLI Example:

.. code-block:: bash
salt '*' test.module_report
salt.modules.test.not_loaded()

List the modules that were not loaded by the salt loader system

CLI 范例:

salt '*' test.not_loaded
salt.modules.test.opts_pkg()

Return an opts package with the grains and opts for this minion. This is primarily used to create the options used for master side state compiling routines

CLI 范例:

salt '*' test.opts_pkg
salt.modules.test.outputter(data)

Test the outputter, pass in data to return

CLI 范例:

salt '*' test.outputter foobar
salt.modules.test.ping()

Used to make sure the minion is up and responding. Not an ICMP ping.

Returns True.

CLI 范例:

salt '*' test.ping
salt.modules.test.provider(module)

Pass in a function name to discover what provider is being used

CLI 范例:

salt '*' test.provider service
salt.modules.test.providers()

Return a dict of the provider names and the files that provided them

CLI 范例:

salt '*' test.providers
salt.modules.test.rand_sleep(max=60)

Sleep for a random number of seconds, used to test long-running commands and minions returning at differing intervals

CLI 范例:

salt '*' test.rand_sleep 60
salt.modules.test.rand_str(size=9999999999, hash_type=None)

Return a random string

size
size of the string to generate
hash_type

hash type to use

2015.5.2 新版功能.

CLI 范例:

salt '*' test.rand_str
salt.modules.test.retcode(code=42)

Test that the returncode system is functioning correctly

CLI 范例:

salt '*' test.retcode 42
salt.modules.test.sleep(length)

Instruct the minion to initiate a process that will sleep for a given period of time.

CLI 范例:

salt '*' test.sleep 20
salt.modules.test.stack()

Return the current stack trace

CLI 范例:

salt '*' test.stack
salt.modules.test.true()

Always return True

CLI 范例:

salt '*' test.true
salt.modules.test.try_(module, return_try_exception=False, **kwargs)

Try to run a module command. On an exception return None. If return_try_exception is set True return the exception. This can be helpful in templates where running a module might fail as expected.

CLI 范例:

<pre>
{% for i in range(0,230) %}
    {{ salt['test.try'](module='ipmi.get_users', bmc_host='172.2.2.'+i)|yaml(False) }}
{% endfor %}
</pre>
salt.modules.test.tty(*args, **kwargs)

Deprecated! Moved to cmdmod.

CLI 范例:

salt '*' test.tty tty0 'This is a test'
salt '*' test.tty pts3 'This is a test'
salt.modules.test.version()

Return the version of salt on the minion

CLI 范例:

salt '*' test.version
salt.modules.test.versions()

This function is an alias of versions_report.

Returns versions of components used by salt

CLI 范例:

salt '*' test.versions_report
salt.modules.test.versions_information()

Report the versions of dependent and system software

CLI 范例:

salt '*' test.versions_information
salt.modules.test.versions_report()

Returns versions of components used by salt

CLI 范例:

salt '*' test.versions_report