Question: is_installed was changed for Debian and an installed package cannot be found after the change
See original GitHub issueHi, I’m finding differences running my molecules tests on Travis since the latest version of testinfra. My tests passed in 1.12, but now they are failing in 1.14.
I’m sure the package is installed in the machine, but the python tests says the opposite. Or maybe I’m wrong 🤔 Could you please help me with this issue?
Thanks!
Here I share my scenario:
Ansible task in my role:
- name: "Install jq and all GIT packages"
become: "yes"
apt:
name: "{{ item.name }}"
state: "{{ item.state }}"
changed_when: false
with_items:
- { name: "jq", state: "latest" }
- { name: "git-all", state: "latest" }
This is the output of the test execution:
TASK [jenkins-slave : Install jq and all GIT packages] *************************
ok: [instance] => (item={u'state': u'latest', u'name': u'jq'})
ok: [instance] => (item={u'state': u'latest', u'name': u'git-all'})
And the output of the idempotence check:
--> Action: 'idempotence'
Idempotence completed successfully.
This is the python test in molecule:
def test_git_all_is_installed(host):
assert host.package("git-all").is_installed
The output of the failing test result:
=================================== FAILURES ===================================
________________ test_git_all_is_installed[ansible://instance] _________________
host = <testinfra.host.Host object at 0x7fa2223b61d0>
def test_git_all_is_installed(host):
> assert host.package("git-all").is_installed
E AssertionError: assert False
E + where False = <package git-all>.is_installed
E + where <package git-all> = <class 'testinfra.modules.base.DebianPackage'>('git-all')
E + where <class 'testinfra.modules.base.DebianPackage'> = <testinfra.host.Host object at 0x7fa2223b61d0>.package
tests/test_default.py:29: AssertionError
------------------------------ Captured log call -------------------------------
ansible.py 61 INFO RUN Ansible(u'shell', u"dpkg-query -f '${Status}' -W git-all", {}): {'_ansible_no_log': False,
'_ansible_parsed': True,
u'changed': True,
u'cmd': u"dpkg-query -f '${Status}' -W git-all",
u'delta': u'0:00:00.042013',
u'end': u'2018-07-10 23:04:28.901809',
u'invocation': {u'module_args': {u'_raw_params': u"dpkg-query -f '${Status}' -W git-all",
u'_uses_shell': True,
u'chdir': None,
u'creates': None,
u'executable': None,
u'removes': None,
u'stdin': None,
u'warn': True}},
u'msg': u'non-zero return code',
u'rc': 1,
u'start': u'2018-07-10 23:04:28.859796',
u'stderr': u'dpkg-query: no packages found matching git-all',
'stderr_lines': [u'dpkg-query: no packages found matching git-all'],
u'stdout': u'',
'stdout_lines': []}
base.py 241 INFO RUN CommandResult(command=u"dpkg-query -f '${Status}' -W git-all", exit_status=1, stdout=u'', stderr=u'dpkg-query: no packages found matching git-all')
===================== 1 failed, 9 passed in 67.93 seconds ======================
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
is_installed was changed for Debian and an installed package ...
I'm sure the package is installed in the machine, but the python ... Debian and an installed package cannot be found after the...
Read more >Chapter 9. Keeping your Debian system up-to-date
Sometimes, a revised package will require the installation of a newly revised version of another package, in which case the installation will fail...
Read more >Chapter 2. Debian package management
Do not change default behavior of package management tools through configuration files without knowing their full impacts. Do not install random packages by ......
Read more >DontBreakDebian - Debian Wiki
First of all, apt-get upgrade default behavior is to upgrade any installed package to the highest available version.
Read more >Chapter 7. Basics of the Debian package management system
Package A conflicts with Package B when A will not operate if B is installed on the system. Most often, conflicts are cases...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tested this with molecule using your sample configuration and I still get passing tests. I’m fairly confident that the error you are getting is problems with your role + molecule configuration versus a bug with testinfra.
Perhaps you can create a gist of your example to show us how you have your environment setup so that we can try and reproduce the error using your gist?
I’ve personally tested this both with Vagrant, Docker and molecule and I cannot reproduce your error via testinfra. I get the error when the package is not installed which is the correct behavior of testinfra.
I’m just a contributor to testinfra and can say that I believe testinfra is behaving correctly in this case and wasn’t in 1.12.0. Just my $2.
Hey, thanks for such a detailed bugtrack 😊
My base OS is Ubuntu 16.04, this is something I did not add to the scenario. I set that at
molecule.yml
level: