Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests.core.test_host.HelpersTest.test_write_updatedb: AssertionError: False is not true #575

Closed
nobuto-m opened this issue Feb 22, 2021 · 9 comments
Assignees

Comments

@nobuto-m
Copy link
Contributor

When I run tox -e py3, I will get the following test failure.

FAIL: tests.core.test_host.HelpersTest.test_write_updatedb
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/nobuto/src/corporate/charm-helpers/tests/core/test_host.py", line 1921, in test_write_updatedb
    self.assertTrue(handle.read.call_count == 1)
AssertionError: False is not true

Full logs for the record:

$ tox -e py3
.tox create: /home/nobuto/src/corporate/charm-helpers/.tox/.tox
.tox installdeps: pip < 20.3, virtualenv < 20.0, tox >= 3.2.0
py3 create: /home/nobuto/src/corporate/charm-helpers/.tox/py3
py3 installdeps: -r/home/nobuto/src/corporate/charm-helpers/test-requirements.txt
py3 installed: alabaster==0.7.12,amulet==1.21.0,Babel==2.9.0,certifi==2020.12.5,cffi==1.14.5,chardet==4.0.0,coverage==5.4,debtcollector==2.2.0,distro-info==0.0.0,dnspython==1.11.1,docutils==0.16,flake8==3.8.4,idna==2.10,imagesize==1.2.0,iso8601==0.1.14,Jinja2==2.11.3,jujubundlelib==0.5.6,keystoneauth1==4.3.0,libcharmstore==0.0.9,macaroonbakery==1.3.1,MarkupSafe==1.1.1,mccabe==0.6.1,mock==1.0.1,msgpack==1.0.2,netaddr==0.8.0,netifaces==0.10.0,nose==1.3.7,os-service-types==1.7.0,oslo.config==8.4.0,oslo.i18n==5.0.1,oslo.serialization==4.1.0,oslo.utils==4.8.0,packaging==20.9,path==13.3.0,path.py==12.5.0,pbr==5.5.1,positional==1.2.1,prettytable==0.7.2,protobuf==3.15.1,psutil==1.2.1,pycodestyle==2.6.0,pycparser==2.20,pyflakes==2.2.0,Pygments==2.8.0,pymacaroons==0.13.0,PyNaCl==1.4.0,pyparsing==2.4.7,pyRFC3339==1.1,python-distutils-extra==2.39,python-keystoneclient==2.3.2,pytz==2021.1,PyYAML==5.4.1,requests==2.25.1,rfc3986==1.4.0,six==1.15.0,snowballstemmer==2.1.0,Sphinx==3.5.1,sphinx-rtd-theme==0.5.1,sphinxcontrib-applehelp==1.0.2,sphinxcontrib-devhelp==1.0.2,sphinxcontrib-htmlhelp==1.0.3,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==1.0.3,sphinxcontrib-serializinghtml==1.1.4,stevedore==3.3.0,testtools==0.9.14,theblues==0.5.2,urllib3==1.26.3,wrapt==1.12.1
py3 run-test-pre: PYTHONHASHSEED='0'
py3 run-test: commands[0] | nosetests -s --nologcapture --with-coverage --cover-package=charmhelpers tests/
........................................................................................................................................................................................................................................................................................................................................................................................juju-log: DEPRECATION WARNING: Function add_ovsbridge_linuxbridge is being removed on/around 2021-01 : see lp:1877594
juju-log: DEPRECATION WARNING: Function setup_eni is being removed on/around 2021-01 : see lp:1877594
...............................................................................Skipping test because it isexcluded in audit config
..test: PASS
.................Validate mode of test-file-name: PASS
.Validate ownership of test-file-name: PASS
..............juju-log: INFO: Installing CA certificate from certificate relation
juju-log: INFO: Removing CA certificate /usr/local/share/ca-certificates/keystone_juju_ca_cert.crt
juju-log: INFO: Installing CA certificate from certificate relation
juju-log: INFO: Installing CA certificate from charm ssl_ca config to /usr/local/share/ca-certificates/keystone_juju_ca_cert.crt
juju-log: INFO: Installing CA certificate from certificate relation
...............................................................................juju-log: INFO: New endpoint change notification found: neutron-identity-service_3-keystone_1=2aa6
juju-log: INFO: New endpoint change notification found: neutron-identity-service_3-keystone_1=2aa6
........Checking when none
OpenStack Release: {}
.Checking when wallaby
OpenStack Release: {'OPENSTACK_CODENAME': 'wallaby'}
........................................................juju-log: DEBUG: Probe ports [77], result: [True]
juju-log: DEBUG: Probe ports [77], result: [False]
......................................................................................................................................................................................................................................juju-log: DEBUG: Add linux bond "bond0" to map for physical interface "eth0" with mac "00:00:5e:00:00:40".
juju-log: DEBUG: Add linux bond "bond0" to map for physical interface "eth1" with mac "00:00:5e:00:00:41".
juju-log: DEBUG: Add linux bond "bond0" to map for physical interface "eth0" with mac "00:00:5e:00:00:40".
juju-log: DEBUG: Add linux bond "bond0" to map for physical interface "eth1" with mac "00:00:5e:00:00:41".
juju-log: DEBUG: Add linux bond "bond0" to map for physical interface "eth0" with mac "00:00:5e:00:00:40".
juju-log: DEBUG: Add linux bond "bond0" to map for physical interface "eth1" with mac "00:00:5e:00:00:41".
juju-log: DEBUG: Add unmapped interface from config: name "bond0.1234" bridge "br-provider1"
.................juju-log: DEBUG: SR-IOV configured in auto mode: No device mapping for eth1
juju-log: DEBUG: SR-IOV configured in explicit mode: No device:numvfs pair for device eth1, skipping.
juju-log: DEBUG: SR-IOV configured in explicit mode: No device:numvfs pair for device eth0, skipping.
juju-log: DEBUG: SR-IOV configured in explicit mode: No device:numvfs pair for device eth0, skipping.
juju-log: WARNING: Requested VFs (64) too high for device eth1. Falling back to value supprted by device: 32
juju-log: WARNING: Requested VFs (64) too high for device eth1. Falling back to value supprted by device: 32
juju-log: DEBUG: SR-IOV configured in explicit mode: No device:numvfs pair for device eth0, skipping.
juju-log: WARNING: Requested VFs (64) too high for device eth1. Falling back to value supprted by device: 32
juju-log: WARNING: Requested VFs (64) too high for device eth1. Falling back to value supprted by device: 32
juju-log: DEBUG: SR-IOV configured in auto mode: No device mapping for eth1
juju-log: WARNING: Requested VFs (24) too high for device eth0. Falling back to value supprted by device: 16
juju-log: WARNING: Requested VFs (24) too high for device eth0. Falling back to value supprted by device: 16
..................................................................................................................................................................................................DEPRECATION WARNING: Function __init__ is being removed : The ``Pool`` baseclass has been replaced by ``BasePool`` class.
..................................................................................................................................................................................................................juju-log: ERROR: Found but was unable to parse previous config data, ignoring which will report all values as changed - Expecting value: line 1 column 1 (char 0)
.......................................................................................................................................................................................................................................................................................................F.......................................................................................................................................................................................................................................................................................
======================================================================
FAIL: tests.core.test_host.HelpersTest.test_write_updatedb
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/nobuto/src/corporate/charm-helpers/tests/core/test_host.py", line 1921, in test_write_updatedb
    self.assertTrue(handle.read.call_count == 1)
AssertionError: False is not true


Name                                                                Stmts   Miss  Cover
---------------------------------------------------------------------------------------
charmhelpers/__init__.py                                               45     12    73%
charmhelpers/cli/__init__.py                                          108      1    99%
charmhelpers/context.py                                                85      0   100%
charmhelpers/contrib/__init__.py                                        0      0   100%
charmhelpers/contrib/amulet/__init__.py                                 0      0   100%
charmhelpers/contrib/amulet/utils.py                                  360    216    40%
charmhelpers/contrib/ansible/__init__.py                               70      2    97%
charmhelpers/contrib/benchmark/__init__.py                             47      2    96%
charmhelpers/contrib/charmhelpers/__init__.py                          87      8    91%
charmhelpers/contrib/charmsupport/__init__.py                           0      0   100%
charmhelpers/contrib/charmsupport/nrpe.py                             219     34    84%
charmhelpers/contrib/database/__init__.py                               0      0   100%
charmhelpers/contrib/database/mysql.py                                414    118    71%
charmhelpers/contrib/hahelpers/__init__.py                              0      0   100%
charmhelpers/contrib/hahelpers/apache.py                               39      1    97%
charmhelpers/contrib/hahelpers/cluster.py                             192      7    96%
charmhelpers/contrib/hardening/__init__.py                              0      0   100%
charmhelpers/contrib/hardening/apache/__init__.py                       2      0   100%
charmhelpers/contrib/hardening/apache/checks/__init__.py                9      6    33%
charmhelpers/contrib/hardening/apache/checks/config.py                 27      0   100%
charmhelpers/contrib/hardening/audits/__init__.py                      12      1    92%
charmhelpers/contrib/hardening/audits/apache.py                        52      5    90%
charmhelpers/contrib/hardening/audits/apt.py                           49      7    86%
charmhelpers/contrib/hardening/audits/file.py                         268     77    71%
charmhelpers/contrib/hardening/harden.py                               36      4    89%
charmhelpers/contrib/hardening/host/__init__.py                         2      0   100%
charmhelpers/contrib/hardening/host/checks/__init__.py                 17     14    18%
charmhelpers/contrib/hardening/host/checks/apt.py                      11      0   100%
charmhelpers/contrib/hardening/host/checks/limits.py                   15      3    80%
charmhelpers/contrib/hardening/host/checks/login.py                    15      6    60%
charmhelpers/contrib/hardening/host/checks/minimize_access.py          13      0   100%
charmhelpers/contrib/hardening/host/checks/pam.py                      56     27    52%
charmhelpers/contrib/hardening/host/checks/profile.py                  16      0   100%
charmhelpers/contrib/hardening/host/checks/securetty.py                12      0   100%
charmhelpers/contrib/hardening/host/checks/suid_sgid.py                28      0   100%
charmhelpers/contrib/hardening/host/checks/sysctl.py                   78     28    64%
charmhelpers/contrib/hardening/mysql/__init__.py                        2      0   100%
charmhelpers/contrib/hardening/mysql/checks/__init__.py                 9      6    33%
charmhelpers/contrib/hardening/mysql/checks/config.py                  19      2    89%
charmhelpers/contrib/hardening/ssh/__init__.py                          2      0   100%
charmhelpers/contrib/hardening/ssh/checks/__init__.py                   9      6    33%
charmhelpers/contrib/hardening/ssh/checks/config.py                   224     72    68%
charmhelpers/contrib/hardening/templating.py                           29     13    55%
charmhelpers/contrib/hardening/utils.py                                60     20    67%
charmhelpers/contrib/network/__init__.py                                0      0   100%
charmhelpers/contrib/network/ip.py                                    310     26    92%
charmhelpers/contrib/network/ovs/__init__.py                          206     12    94%
charmhelpers/contrib/network/ovs/ovn.py                                66      4    94%
charmhelpers/contrib/network/ovs/ovsdb.py                              53      0   100%
charmhelpers/contrib/network/ovs/utils.py                               3      0   100%
charmhelpers/contrib/network/ufw.py                                   132      4    97%
charmhelpers/contrib/openstack/__init__.py                              0      0   100%
charmhelpers/contrib/openstack/alternatives.py                         12      0   100%
charmhelpers/contrib/openstack/audits/__init__.py                      85     21    75%
charmhelpers/contrib/openstack/audits/openstack_security_guide.py      90     15    83%
charmhelpers/contrib/openstack/cert_utils.py                          183      5    97%
charmhelpers/contrib/openstack/context.py                            1424     90    94%
charmhelpers/contrib/openstack/exceptions.py                            2      0   100%
charmhelpers/contrib/openstack/ha/__init__.py                           0      0   100%
charmhelpers/contrib/openstack/ha/utils.py                            126      5    96%
charmhelpers/contrib/openstack/ip.py                                   83      7    92%
charmhelpers/contrib/openstack/keystone.py                             85     20    76%
charmhelpers/contrib/openstack/neutron.py                             109      4    96%
charmhelpers/contrib/openstack/policyd.py                             204     24    88%
charmhelpers/contrib/openstack/ssh_migrations.py                      137      4    97%
charmhelpers/contrib/openstack/templating.py                          143     23    84%
charmhelpers/contrib/openstack/utils.py                               909     96    89%
charmhelpers/contrib/openstack/vaultlocker.py                          91     19    79%
charmhelpers/contrib/peerstorage/__init__.py                          116     16    86%
charmhelpers/contrib/saltstack/__init__.py                             14      0   100%
charmhelpers/contrib/ssl/__init__.py                                   36      5    86%
charmhelpers/contrib/ssl/service.py                                   115     16    86%
charmhelpers/contrib/storage/__init__.py                                0      0   100%
charmhelpers/contrib/storage/linux/__init__.py                          0      0   100%
charmhelpers/contrib/storage/linux/bcache.py                           35      1    97%
charmhelpers/contrib/storage/linux/ceph.py                            775     65    92%
charmhelpers/contrib/storage/linux/loopback.py                         30      0   100%
charmhelpers/contrib/storage/linux/lvm.py                              52      0   100%
charmhelpers/contrib/storage/linux/utils.py                            39      7    82%
charmhelpers/contrib/templating/__init__.py                             0      0   100%
charmhelpers/contrib/templating/contexts.py                            58      2    97%
charmhelpers/contrib/templating/jinja.py                               16      6    62%
charmhelpers/contrib/templating/pyformat.py                             7      0   100%
charmhelpers/contrib/unison/__init__.py                               149      2    99%
charmhelpers/coordinator.py                                           183      0   100%
charmhelpers/core/__init__.py                                           0      0   100%
charmhelpers/core/decorators.py                                        37      0   100%
charmhelpers/core/files.py                                              6      0   100%
charmhelpers/core/fstab.py                                             74      9    88%
charmhelpers/core/hookenv.py                                          774     67    91%
charmhelpers/core/host.py                                             508     53    90%
charmhelpers/core/host_factory/__init__.py                              0      0   100%
charmhelpers/core/host_factory/centos.py                               40      7    82%
charmhelpers/core/host_factory/ubuntu.py                               40      5    88%
charmhelpers/core/hugepage.py                                          28      0   100%
charmhelpers/core/kernel.py                                            28      0   100%
charmhelpers/core/kernel_factory/__init__.py                            0      0   100%
charmhelpers/core/kernel_factory/centos.py                             11      0   100%
charmhelpers/core/kernel_factory/ubuntu.py                              7      0   100%
charmhelpers/core/services/__init__.py                                  2      0   100%
charmhelpers/core/services/base.py                                    137     24    82%
charmhelpers/core/services/helpers.py                                 119      5    96%
charmhelpers/core/strutils.py                                          55      0   100%
charmhelpers/core/sysctl.py                                            26      0   100%
charmhelpers/core/templating.py                                        37     11    70%
charmhelpers/core/unitdata.py                                         178     11    94%
charmhelpers/fetch/__init__.py                                         94      4    96%
charmhelpers/fetch/archiveurl.py                                       83     21    75%
charmhelpers/fetch/bzrurl.py                                           43      5    88%
charmhelpers/fetch/centos.py                                           95     11    88%
charmhelpers/fetch/giturl.py                                           37      8    78%
charmhelpers/fetch/python/__init__.py                                   0      0   100%
charmhelpers/fetch/python/packages.py                                  77     16    79%
charmhelpers/fetch/python/version.py                                    6      0   100%
charmhelpers/fetch/snap.py                                             60     11    82%
charmhelpers/fetch/ubuntu.py                                          215     23    89%
charmhelpers/fetch/ubuntu_apt_pkg.py                                  140     11    92%
charmhelpers/osplatform.py                                             22      9    59%
charmhelpers/payload/__init__.py                                        1      0   100%
charmhelpers/payload/archive.py                                        37      0   100%
charmhelpers/payload/execd.py                                          30      0   100%
tools/__init__.py                                                       0      0   100%
tools/charm_helpers_sync/__init__.py                                    0      0   100%
tools/charm_helpers_sync/charm_helpers_sync.py                        167     51    69%
---------------------------------------------------------------------------------------
TOTAL                                                               12030   1559    87%
----------------------------------------------------------------------
Ran 1859 tests in 11.235s

FAILED (failures=1)
ERROR: InvocationError for command /home/nobuto/src/corporate/charm-helpers/.tox/py3/bin/nosetests -s --nologcapture --with-coverage --cover-package=charmhelpers tests/ (exited with code 1)
___________________________________________________________________________________________________ summary ___________________________________________________________________________________________________
ERROR:   py3: commands failed
@ajkavanagh
Copy link
Contributor

Hi Nobutu,

What version of python/Ubuntu are you running this on, please?

Thanks

@nobuto-m
Copy link
Contributor Author

What version of python/Ubuntu are you running this on, please?

Ubuntu 20.10 and Python3 3.8.6-0ubuntu1.

@nobuto-m
Copy link
Contributor Author

FWIW, I tried the same operation with a fresh LXD container with Ubuntu 20.04 LTS. And I can reproduce the test failure there as well.

As a side note, requiring bzr outside of venv to run tests is a bit weird.

$ lxc launch ubuntu:focal tox-test; alert
$ lxc exec tox-test -- sudo -i -u ubuntu

$ sudo apt update && sudo apt install -y build-essential tox python3-dev bzr zip
$ sudo snap install juju --classic

$ git clone https://github.com/juju/charm-helpers.git
$ cd charm-helpers/ && tox -e py3
...
juju-log: WARNING: Requested VFs (24) too high for device eth0. Falling back to value supprted by device: 16
juju-log: WARNING: Requested VFs (24) too high for device eth0. Falling back to value supprted by device: 16
..................................................................................................................................................................................................DEPRECATION WARNING: Function __init__ is being removed : The ``Pool`` baseclass has been replaced by ``BasePool`` class.
..................................................................................................................................................................................................................juju-log: ERROR: Found but was unable to parse previous config data, ignoring which will report all values as changed - Expecting value: line 1 column 1 (char 0)
.......................................................................................................................................................................................................................................................................................................F.......................................................................................................................................................................................................................................................................................
======================================================================
FAIL: tests.core.test_host.HelpersTest.test_write_updatedb
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/ubuntu/charm-helpers/tests/core/test_host.py", line 1921, in test_write_updatedb
    self.assertTrue(handle.read.call_count == 1)
AssertionError: False is not true

@ajkavanagh
Copy link
Contributor

Yup, me too; it's due to a lack of mocking in the function-under-test. I'm sorting it out now.

@ajkavanagh ajkavanagh self-assigned this Feb 22, 2021
@nobuto-m
Copy link
Contributor Author

Good to know that was reproduced on your end.

Another side note, invoking juju command is also weird. Without installing it beforehand,

$ sudo snap install juju --classic

The tests will fail as follows, but it may be worthy a separate bug instead of mixing everything into this.

======================================================================
ERROR: Failure: OSError (juju not found, do you have Juju installed?)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/charm-helpers/.tox/py3/lib/python3.8/site-packages/amulet/helpers.py", line 70, in juju
    p = subprocess.Popen(['juju'] + args, env=env, stdout=subprocess.PIPE,
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'juju'

@ajkavanagh
Copy link
Contributor

Yes, there's also something odd going on in the amulet/test_utils.py file, which imports the Amulet module that wants juju to be installed. The unit tests for a module shouldn't be dependent on an external program. Going to sort that bit out first.

@ajkavanagh
Copy link
Contributor

So I've updated the tests in the module to pass on py38 on groovy. re: the juju command, I got:

root@groovy:~/git/github.com/juju/charm-helpers# snap install juju --classic
juju 2.8.8 from Canonical✓ installed
root@groovy:~/git/github.com/juju/charm-helpers# juju
Welcome to the Juju interactive shell.
Type "help" to see a list of available commands.
Type "q" or ^D or ^C to quit.

no controllers registered$

Are you getting something different, or was it a test failing? (I fixed that too, where the amulet module is trying to invoke the juju command).

@nobuto-m
Copy link
Contributor Author

Are you getting something different, or was it a test failing?

The test failed only when juju is not installed on a local system. But your PR will solve it.

I see other two weird dependencies to run tests so filed a separate bug just for tracking purpose:
#577

@ajkavanagh
Copy link
Contributor

This should be resolved by #577 - please re-open if there are still issues. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants