Local docker test runner

Hi!

Is there an easy way to run ansible unittests and integration tests locally before push? Some kind of preconfigured docker container with all deps installed?

Yes, please see https://docs.ansible.com/ansible/latest/dev_guide/testing.html for more detail.

In short:

ansible-test units --docker default /path/to/unit/test_something.py

Hello, I can send you a short manual later.
Please, ping me to aaklychkov@mail.ru

пн, 29 апр. 2019 г. в 16:45, Андрей Тужилин <andrei.tuzhilin@gmail.com>:

I’ve tried it with different shells (bash and fish), different python envs (MacOS built-in and virtual env with python 2.7 and 3.6) with no luck. All comes down to this:

`

bash-3.2$ ./bin/ansible-test sanity --test pep8
Sanity check using pep8
Traceback (most recent call last):
File “./bin/ansible-test”, line 15, in
lib.cli.main()
File “/Users/andy/workspace/contrib/ansible/test/runner/lib/cli.py”, line 108, in main
args.func(config)
File “/Users/andy/workspace/contrib/ansible/test/runner/lib/sanity/init.py”, line 113, in command_sanity
result = test.test(args, targets)
File “/Users/andy/workspace/contrib/ansible/test/runner/lib/sanity/pep8.py”, line 66, in test
stdout, stderr = run_command(args, cmd, capture=True)
File “/Users/andy/workspace/contrib/ansible/test/runner/lib/util.py”, line 366, in run_command
cmd_verbosity=cmd_verbosity, str_errors=str_errors)
File “/Users/andy/workspace/contrib/ansible/test/runner/lib/util.py”, line 432, in raw_command
process = subprocess.Popen(cmd, env=env, stdin=stdin, stdout=stdout, stderr=stderr, cwd=cwd)
File “/Users/andy/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py”, line 729, in init
restore_signals, start_new_session)
File “/Users/andy/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py”, line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 7] Argument list too long: ‘/Users/andy/.local/share/virtualenvs/ansible-FTkjm-xR/bin/python’

`

So, I thought, maybe there is a preconfigured docker environment, that just works…

I’v just sent my manual to you. Hope it will be useful

пн, 29 апр. 2019 г. в 21:56, Андрей Тужилин <andrei.tuzhilin@gmail.com>:

I think the guide needs some polishing… It’s missing some statements about requirements.txt (and there are tons of them!) import for instance.
I have an issue with source hacking/env-setup - don’t actually know what it is actually, maybe it is in conflict with brew ansible package, which uses some environment too…

I’ve ended up creating a small docker-compose script to run everything (including python env and this hacking stuff) inside container, so no collisions would be possible. Maybe it will be useful in some way: https://github.com/astorath/ansible-test