openstack-charmers / zaza

A Python3-only functional test framework for Charms
Apache License 2.0
10 stars 47 forks source link

Support for Python 3.9 #445

Open xavpaice opened 3 years ago

xavpaice commented 3 years ago

Traceback received while attempting to run zaza tests from a machine updated to 21.04:

func installed: aiohttp==3.7.4.post0,argcomplete==1.12.3,async-generator==1.10,async-timeout==3.0.1,attrs==21.2.0,bcrypt==3.2.0,certifi==2020.12.5,cffi==1.14.5,chardet==4.0.0,charmhelpers==0.20.21,colorclass==2.2.0,cryptography==3.3.2,debtcollector==2.2.0,hvac==0.6.4,idna==2.10,Jinja2==3.0.0,juju==2.8.6,juju-wait==2.8.4,jujubundlelib==0.5.6,macaroonbakery==1.3.1,MarkupSafe==2.0.0,multidict==5.1.0,mypy-extensions==0.4.3,netaddr==0.8.0,netifaces==0.10.9,oauthlib==3.1.0,oslo.config==6.11.3,oslo.i18n==5.0.1,paramiko==2.7.2,pbr==5.6.0,protobuf==3.17.0,pyasn1==0.4.8,pycparser==2.20,pymacaroons==0.13.0,pymongo==3.11.4,PyNaCl==1.4.0,pyRFC3339==1.1,python-libmaas==0.6.6,pytz==2021.1,PyYAML==5.4.1,requests==2.25.1,rfc3986==1.5.0,six==1.16.0,stevedore==3.3.0,Tempita==0.5.2,tenacity==7.0.0,terminaltables==3.1.0,theblues==0.5.2,toposort==1.6,typing-extensions==3.10.0.0,typing-inspect==0.6.0,urllib3==1.26.4,websockets==8.1,wrapt==1.12.1,yarl==1.6.3,zaza @ git+https://github.com/openstack-charmers/zaza.git@27a69726bd48ec1257d2f698e54d666b364167ea
func run-test-pre: PYTHONHASHSEED='3981672497'
func run-test: commands[0] | functest-run-suite
Traceback (most recent call last):
  File "/home/xav/charms/charm-graylog/src/.tox/func/bin/functest-run-suite", line 8, in <module>
    sys.exit(main())
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 308, in main
    func_test_runner(
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 242, in func_test_runner
    run_env_deployment(env_deployment, keep_model=preserve_model,
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 106, in run_env_deployment
    prepare.prepare(
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/utilities/run_report.py", line 144, in wrapper
    result = f(*args, **kwds)
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/charm_lifecycle/prepare.py", line 39, in prepare
    zaza.controller.add_model(
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/__init__.py", line 77, in _wrapper
    return run(_run_it())
  File "/home/xav/charms/charm-graylog/src/.tox/func/lib/python3.9/site-packages/zaza/__init__.py", line 43, in run
    pending_tasks = [p for p in asyncio.Task.all_tasks()
AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'
ERROR: InvocationError for command /home/xav/charms/charm-graylog/src/.tox/func/bin/functest-run-suite (exited with code 1)
____________________________________________________________________________________________________ summary _____________________________________________________________________________________________________
ERROR:   func: commands failed
make: *** [Makefile:76: functional] Error 1

It turns out that asyncio.Task.all_tasks() and current_task() have been deprecated since python 3.7 and is fully removed in 3.9. So all references to asyncio.Task.all_tasks() should change to asyncio.all_tasks(). I believe this is only in zaza/init.py.

ajkavanagh commented 3 years ago

Note that the fix will need to be careful as we need to retain xenial (py35) compatibility at present for the CI system.