diff --git a/requirements/pytest.txt b/requirements/pytest.txt index 1159d1112959..9c0db5e96bfe 100644 --- a/requirements/pytest.txt +++ b/requirements/pytest.txt @@ -1,8 +1,6 @@ # PyTest -pytest >= 4.0.1 -pytest-cov -pytest-salt == 2018.12.8 -pytest-timeout >= 1.3.3 -pytest-tempdir >= 2018.8.11 -pytest-helpers-namespace >= 2017.11.11 -pytest-salt-runtests-bridge >= 2019.1.30 +pytest >=4.6.6,<4.7 # PyTest 4.6.x are the last Py2 and Py3 releases +pytest-salt >= 2019.11.27 +pytest-tempdir >= 2019.10.12 +pytest-helpers-namespace >= 2019.1.8 +pytest-salt-runtests-bridge >= 2019.7.10 diff --git a/requirements/static/py2.7/darwin.txt b/requirements/static/py2.7/darwin.txt index c454efe3bee1..9e12f1c36639 100644 --- a/requirements/static/py2.7/darwin.txt +++ b/requirements/static/py2.7/darwin.txt @@ -27,9 +27,9 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 click==7.0 clustershell==1.8.1 -contextlib2==0.5.5 # via cherrypy +configparser==4.0.2 # via importlib-metadata +contextlib2==0.5.5 # via cherrypy, importlib-metadata cookies==2.2.1 # via responses -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -47,6 +47,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -70,10 +71,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -86,14 +88,13 @@ pycparser==2.19 pycryptodome==3.8.1 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -113,7 +114,7 @@ scp==0.13.2 # via junos-eznc selectors2==2.0.1 # via ncclient setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -125,11 +126,13 @@ urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py2.7/linux.txt b/requirements/static/py2.7/linux.txt index 3c46959fd755..e72c8bb69b69 100644 --- a/requirements/static/py2.7/linux.txt +++ b/requirements/static/py2.7/linux.txt @@ -25,9 +25,9 @@ cffi==1.12.2 chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 -contextlib2==0.5.5 # via cherrypy +configparser==4.0.2 # via importlib-metadata +contextlib2==0.5.5 # via cherrypy, importlib-metadata cookies==2.2.1 # via responses -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -45,6 +45,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via cryptography, docker, kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -66,10 +67,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -84,14 +86,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -112,7 +113,7 @@ selectors2==2.0.1 # via ncclient setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 supervisor==3.3.5 ; python_version < "3" @@ -122,8 +123,10 @@ tornado==4.5.3 ; python_version < "3" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py2.7/windows.txt b/requirements/static/py2.7/windows.txt index a50776715e80..94e4cce5f2e6 100644 --- a/requirements/static/py2.7/windows.txt +++ b/requirements/static/py2.7/windows.txt @@ -24,9 +24,9 @@ chardet==3.0.4 # via requests cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest -contextlib2==0.5.5 # via cherrypy +configparser==4.0.2 # via importlib-metadata +contextlib2==0.5.5 # via cherrypy, importlib-metadata cookies==2.2.1 # via responses -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -44,6 +44,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -64,10 +65,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -81,13 +83,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -108,7 +109,7 @@ scandir==1.10.0 # via pathlib2 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -119,6 +120,7 @@ tornado==4.5.3 ; python_version < "3" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -126,3 +128,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.4/linux.txt b/requirements/static/py3.4/linux.txt index 8351bb83b7d3..dafa99fa412f 100644 --- a/requirements/static/py3.4/linux.txt +++ b/requirements/static/py3.4/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 -pathlib2==2.3.3 # via pytest +pathlib2==2.3.3 # via importlib-metadata, pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -104,7 +104,7 @@ selectors2==2.0.1 # via ncclient setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -113,8 +113,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.5/darwin.txt b/requirements/static/py3.5/darwin.txt index 8a334a1a0fa0..62e17467da62 100644 --- a/requirements/static/py3.5/darwin.txt +++ b/requirements/static/py3.5/darwin.txt @@ -26,7 +26,6 @@ cherrypy==17.4.1 click==7.0 clustershell==1.8.1 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -41,6 +40,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -63,10 +63,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp pathlib2==2.3.3 # via pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -79,14 +80,13 @@ pycparser==2.19 pycryptodome==3.8.1 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -104,7 +104,7 @@ salttesting==2017.6.1 scp==0.13.2 # via junos-eznc setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -115,11 +115,13 @@ urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py3.5/linux.txt b/requirements/static/py3.5/linux.txt index cd8d3c396e73..53251aba132d 100644 --- a/requirements/static/py3.5/linux.txt +++ b/requirements/static/py3.5/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 pathlib2==2.3.3 # via pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -102,7 +102,7 @@ scp==0.13.2 # via junos-eznc setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pathlib2, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -111,8 +111,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.5/windows.txt b/requirements/static/py3.5/windows.txt index d56efcff653c..493c25317872 100644 --- a/requirements/static/py3.5/windows.txt +++ b/requirements/static/py3.5/windows.txt @@ -23,7 +23,6 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -38,6 +37,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -57,10 +57,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 pathlib2==2.3.3 # via pytest pathtools==0.1.2 # via watchdog -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -74,13 +75,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -100,7 +100,7 @@ salttesting==2017.6.1 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pathlib2, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -110,6 +110,7 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -117,3 +118,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.6/darwin.txt b/requirements/static/py3.6/darwin.txt index 04e21eed4e5b..fa85aee51004 100644 --- a/requirements/static/py3.6/darwin.txt +++ b/requirements/static/py3.6/darwin.txt @@ -26,7 +26,6 @@ cherrypy==17.4.1 click==7.0 clustershell==1.8.1 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -41,6 +40,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -63,10 +63,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -79,14 +80,13 @@ pycparser==2.19 pycryptodome==3.8.1 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -104,7 +104,7 @@ salttesting==2017.6.1 scp==0.13.2 # via junos-eznc setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -115,11 +115,13 @@ urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py3.6/linux.txt b/requirements/static/py3.6/linux.txt index ffb3c0a9a2f1..d7ee75252cc5 100644 --- a/requirements/static/py3.6/linux.txt +++ b/requirements/static/py3.6/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -102,7 +102,7 @@ scp==0.13.2 # via junos-eznc setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -111,8 +111,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.6/windows.txt b/requirements/static/py3.6/windows.txt index 4a430b1b693f..ae3a3f462398 100644 --- a/requirements/static/py3.6/windows.txt +++ b/requirements/static/py3.6/windows.txt @@ -23,7 +23,6 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -38,6 +37,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -57,10 +57,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -74,13 +75,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -100,7 +100,7 @@ salttesting==2017.6.1 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -110,6 +110,7 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -117,3 +118,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.7/darwin.txt b/requirements/static/py3.7/darwin.txt index 1115660cb634..de86338b601e 100644 --- a/requirements/static/py3.7/darwin.txt +++ b/requirements/static/py3.7/darwin.txt @@ -26,7 +26,6 @@ cherrypy==17.4.1 click==7.0 clustershell==1.8.1 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 dnspython==1.16.0 @@ -41,6 +40,7 @@ gitdb==0.6.4 gitpython==2.1.11 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -63,10 +63,11 @@ msgpack-python==0.5.6 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 # via junos-eznc, ncclient, scp pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.1 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -79,14 +80,13 @@ pycparser==2.19 pycryptodome==3.8.1 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -104,7 +104,7 @@ salttesting==2017.6.1 scp==0.13.2 # via junos-eznc setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kubernetes, mock, more-itertools, moto, ncclient, packaging, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -115,11 +115,13 @@ urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 vultr==1.0.1 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto yamlordereddictloader==0.4.0 zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata # Passthrough dependencies from pkg/osx/req.txt pyobjc==5.1.2 diff --git a/requirements/static/py3.7/linux.txt b/requirements/static/py3.7/linux.txt index 0c4615c563a3..21049e3309f0 100644 --- a/requirements/static/py3.7/linux.txt +++ b/requirements/static/py3.7/linux.txt @@ -24,7 +24,6 @@ chardet==3.0.4 # via requests cheroot==6.5.4 # via cherrypy cherrypy==17.3.0 contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov croniter==0.3.29 cryptography==2.6.1 # via moto, paramiko, pyopenssl dnspython==1.16.0 @@ -38,6 +37,7 @@ gitpython==2.1.11 google-auth==1.6.3 # via kubernetes hgtools==8.1.1 idna==2.8 # via requests +importlib-metadata==0.23 # via pluggy, pytest ipaddress==1.0.22 # via kubernetes jaraco.functools==2.0 # via tempora jinja2==2.10.1 @@ -58,10 +58,11 @@ moto==1.3.7 msgpack==0.5.6 ncclient==0.6.4 # via junos-eznc netaddr==0.7.19 # via junos-eznc +packaging==19.2 # via pytest paramiko==2.4.2 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -76,14 +77,13 @@ pygit2==0.28.2 pyinotify==0.9.6 pynacl==1.3.0 # via paramiko pyopenssl==19.0.0 +pyparsing==2.4.5 # via packaging pyserial==3.4 # via junos-eznc -pytest-cov==2.6.1 pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 # via botocore, croniter, kubernetes, moto python-etcd==0.4.5 python-gnupg==0.4.4 @@ -102,7 +102,7 @@ scp==0.13.2 # via junos-eznc setproctitle==1.1.10 setuptools-scm==3.2.0 singledispatch==3.4.0.3 # via tornado -six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via bcrypt, cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, junos-eznc, kazoo, kubernetes, mock, more-itertools, moto, ncclient, packaging, pygit2, pynacl, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 strict-rfc3339==0.7 tempora==1.14.1 # via portend @@ -111,8 +111,10 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/requirements/static/py3.7/windows.txt b/requirements/static/py3.7/windows.txt index 97c1ee3ae971..bebcce92b36d 100644 --- a/requirements/static/py3.7/windows.txt +++ b/requirements/static/py3.7/windows.txt @@ -23,7 +23,6 @@ cheroot==6.5.5 # via cherrypy cherrypy==17.4.1 colorama==0.4.1 # via pytest contextlib2==0.5.5 # via cherrypy -coverage==4.5.3 # via pytest-cov cryptography==2.6.1 dmidecode==0.9.0 dnspython==1.16.0 @@ -38,6 +37,7 @@ gitdb==0.6.4 gitpython==2.1.10 google-auth==1.6.3 # via kubernetes idna==2.8 +importlib-metadata==0.23 # via pluggy, pytest ioloop==0.1a0 ipaddress==1.0.22 jaraco.functools==2.0 # via tempora @@ -57,10 +57,11 @@ more-itertools==5.0.0 moto==1.3.7 msgpack-python==0.5.6 msgpack==0.5.6 +packaging==19.2 # via pytest patch==1.16 pathtools==0.1.2 # via watchdog pbr==5.1.3 # via mock -pluggy==0.9.0 # via pytest +pluggy==0.13.0 # via pytest portend==2.4 # via cherrypy psutil==5.6.1 py==1.8.0 # via pytest @@ -74,13 +75,12 @@ pycurl==7.43.0.2 pygit2==0.28.2 pymysql==0.9.3 pyopenssl==19.0.0 -pytest-cov==2.6.1 +pyparsing==2.4.5 # via packaging pytest-helpers-namespace==2019.1.8 -pytest-salt-runtests-bridge==2019.1.30 -pytest-salt==2018.12.8 -pytest-tempdir==2018.8.11 -pytest-timeout==1.3.3 -pytest==4.4.1 +pytest-salt-runtests-bridge==2019.7.10 +pytest-salt==2019.11.27 +pytest-tempdir==2019.10.12 +pytest==4.6.6 python-dateutil==2.8.0 python-etcd==0.4.5 python-gnupg==0.4.4 @@ -100,7 +100,7 @@ salttesting==2017.6.1 sed==0.3.1 setproctitle==1.1.10 singledispatch==3.4.0.3 -six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client +six==1.12.0 # via cheroot, cherrypy, cryptography, docker, docker-pycreds, google-auth, kubernetes, mock, more-itertools, moto, packaging, pygit2, pyopenssl, pytest, python-dateutil, python-jose, pyvmomi, responses, salttesting, singledispatch, tempora, websocket-client smmap2==2.0.5 # via gitdb2 smmap==0.9.0 strict-rfc3339==0.7 @@ -110,6 +110,7 @@ tornado==4.5.3 ; python_version >= "3.4" urllib3==1.24.2 # via botocore, kubernetes, python-etcd, requests virtualenv==16.4.3 watchdog==0.9.0 +wcwidth==0.1.7 # via pytest websocket-client==0.40.0 # via docker, kubernetes werkzeug==0.15.6 # via moto wheel==0.33.4 @@ -117,3 +118,4 @@ wmi==1.4.9 wrapt==1.11.1 # via aws-xray-sdk xmltodict==0.12.0 # via moto zc.lockfile==1.4 # via cherrypy +zipp==0.6.0 # via importlib-metadata diff --git a/salt/client/mixins.py b/salt/client/mixins.py index bff6a1c3e1ce..bd093e9ad1d4 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -510,6 +510,7 @@ def asynchronous(self, fun, low, user='UNKNOWN', pub=None): async_pub = pub if pub is not None else self._gen_async_pub() proc = salt.utils.process.SignalHandlingProcess( target=self._proc_function, + name='ProcessFunc', args=(fun, low, user, async_pub['tag'], async_pub['jid'])) with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM): # Reset current signals before starting the process in diff --git a/salt/grains/minion_process.py b/salt/grains/minion_process.py index 5ad95d5d8b55..b1120de617f1 100644 --- a/salt/grains/minion_process.py +++ b/salt/grains/minion_process.py @@ -3,75 +3,57 @@ Set grains describing the minion process. ''' +# Import Python Libs from __future__ import absolute_import, print_function, unicode_literals - import os # Import salt libs +import salt.utils.user import salt.utils.platform -try: - import pwd -except ImportError: - import getpass - pwd = None - -try: - import grp -except ImportError: - grp = None - def _uid(): ''' Grain for the minion User ID ''' - if salt.utils.platform.is_windows(): - return None - return os.getuid() + return salt.utils.user.get_uid() def _username(): ''' Grain for the minion username ''' - if pwd: - username = pwd.getpwuid(os.getuid()).pw_name - else: - username = getpass.getuser() - - return username + return salt.utils.user.get_user() def _gid(): ''' Grain for the minion Group ID ''' - if salt.utils.platform.is_windows(): - return None - return os.getgid() + return salt.utils.user.get_gid() def _groupname(): ''' Grain for the minion groupname ''' - if grp: - try: - groupname = grp.getgrgid(os.getgid()).gr_name - except KeyError: - groupname = '' - else: - groupname = '' - - return groupname + try: + return salt.utils.user.get_default_group(_username()) or '' + except KeyError: + return '' def _pid(): + ''' + Return the current process pid + ''' return os.getpid() def grains(): + ''' + Return the grains dictionary + ''' ret = { 'username': _username(), 'groupname': _groupname(), diff --git a/salt/loader.py b/salt/loader.py index 74d0e07d9209..e50b14fec1f2 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -957,7 +957,7 @@ def sdb(opts, functions=None, whitelist=None, utils=None): '__sdb__': functions, '__opts__': opts, '__utils__': utils, - '__salt__': minion_mods(opts, utils), + '__salt__': minion_mods(opts, utils=utils), }, whitelist=whitelist, ) diff --git a/salt/metaproxy/proxy.py b/salt/metaproxy/proxy.py index df3fdbec1364..5e2cf3a35ca8 100644 --- a/salt/metaproxy/proxy.py +++ b/salt/metaproxy/proxy.py @@ -726,7 +726,9 @@ def handle_decoded_payload(self, data): instance = None with default_signals(signal.SIGINT, signal.SIGTERM): process = SignalHandlingProcess( - target=self._target, args=(instance, self.opts, data, self.connected) + target=self._target, + name='ProcessPayload', + args=(instance, self.opts, data, self.connected) ) else: process = threading.Thread( diff --git a/salt/minion.py b/salt/minion.py index 5f701a6d21ee..123570dba132 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -1525,7 +1525,9 @@ def _handle_decoded_payload(self, data): instance = None with default_signals(signal.SIGINT, signal.SIGTERM): process = SignalHandlingProcess( - target=self._target, args=(instance, self.opts, data, self.connected) + target=self._target, + name='ProcessPayload', + args=(instance, self.opts, data, self.connected) ) else: process = threading.Thread( diff --git a/salt/modules/cp.py b/salt/modules/cp.py index e0fc3587a95e..e330948a70d2 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -423,6 +423,8 @@ def get_url(path, dest='', saltenv='base', makedirs=False, source_hash=None): log.error('Unable to fetch file %s from saltenv %s.', salt.utils.url.redact_http_basic_auth(path), saltenv) + if result: + return salt.utils.stringutils.to_unicode(result) return result @@ -443,7 +445,7 @@ def get_file_str(path, saltenv='base'): if isinstance(fn_, six.string_types): try: with salt.utils.files.fopen(fn_, 'r') as fp_: - return fp_.read() + return salt.utils.stringutils.to_unicode(fp_.read()) except IOError: return False return fn_ diff --git a/salt/transport/ipc.py b/salt/transport/ipc.py index dbcba18e5c5d..a0d26dd95fde 100644 --- a/salt/transport/ipc.py +++ b/salt/transport/ipc.py @@ -5,6 +5,7 @@ # Import Python libs from __future__ import absolute_import, print_function, unicode_literals +import sys import errno import logging import socket @@ -341,10 +342,6 @@ def _connect(self, timeout=None): def __del__(self): try: self.close() - except socket.error as exc: - if exc.errno != errno.EBADF: - # If its not a bad file descriptor error, raise - raise except TypeError: # This is raised when Python's GC has collected objects which # would be needed when calling self.close() @@ -364,7 +361,12 @@ def close(self): log.debug('Closing %s instance', self.__class__.__name__) if self.stream is not None and not self.stream.closed(): - self.stream.close() + try: + self.stream.close() + except socket.error as exc: + if exc.errno != errno.EBADF: + # If its not a bad file descriptor error, raise + six.reraise(*sys.exc_info()) class IPCMessageClient(IPCClient): diff --git a/tests/integration/netapi/test_client.py b/tests/integration/netapi/test_client.py index 5e538a3af4f3..998454d15166 100644 --- a/tests/integration/netapi/test_client.py +++ b/tests/integration/netapi/test_client.py @@ -44,7 +44,7 @@ def test_local(self): self.assertEqual(ret, {'minion': True, 'sub_minion': True}) def test_local_batch(self): - low = {'client': 'local_batch', 'tgt': '*', 'fun': 'test.ping'} + low = {'client': 'local_batch', 'tgt': '*', 'fun': 'test.ping', 'timeout': 300} low.update(self.eauth_creds) ret = self.netapi.run(low) diff --git a/tests/integration/shell/test_key.py b/tests/integration/shell/test_key.py index 96d806efcb2a..7a989a490447 100644 --- a/tests/integration/shell/test_key.py +++ b/tests/integration/shell/test_key.py @@ -11,6 +11,7 @@ from tests.support.case import ShellCase from tests.support.paths import TMP from tests.support.mixins import ShellCaseCommonTestsMixin +from tests.support.helpers import skip_if_not_root, destructiveTest # Import 3rd-party libs from salt.ext import six @@ -187,6 +188,8 @@ def test_list_acc(self): expect = ['Accepted Keys:', 'minion', 'sub_minion'] self.assertEqual(data, expect) + @skip_if_not_root + @destructiveTest def test_list_acc_eauth(self): ''' test salt-key -l with eauth @@ -197,6 +200,8 @@ def test_list_acc_eauth(self): self.assertEqual(data, expect) self._remove_user() + @skip_if_not_root + @destructiveTest def test_list_acc_eauth_bad_creds(self): ''' test salt-key -l with eauth and bad creds diff --git a/tests/support/helpers.py b/tests/support/helpers.py index 18da25f48603..684d803605d4 100644 --- a/tests/support/helpers.py +++ b/tests/support/helpers.py @@ -199,10 +199,28 @@ def test_sometimes_works(self): def wrap(cls): for attempt in range(0, attempts): try: + if attempt > 0: + # Run through setUp again + # We only run it after the first iteration(>0) because the regular + # test runner will have already ran setUp the first time + setup = getattr(cls, 'setUp', None) + if callable(setup): + setup() return caller(cls) except Exception as exc: + exc_info = sys.exc_info() + if isinstance(exc, SkipTest): + six.reraise(*exc_info) + if not isinstance(exc, AssertionError) and log.isEnabledFor(logging.DEBUG): + log.exception(exc, exc_info=exc_info) if attempt >= attempts -1: - raise exc + # We won't try to run tearDown once the attempts are exhausted + # because the regular test runner will do that for us + six.reraise(*exc_info) + # Run through tearDown again + teardown = getattr(cls, 'tearDown', None) + if callable(teardown): + teardown() backoff_time = attempt ** 2 log.info( 'Found Exception. Waiting %s seconds to retry.', diff --git a/tests/support/zfs.py b/tests/support/zfs.py new file mode 100644 index 000000000000..5b260ff82faf --- /dev/null +++ b/tests/support/zfs.py @@ -0,0 +1,870 @@ +# -*- coding: utf-8 -*- +''' + tests.support.zfs + ~~~~~~~~~~~~~~~~~ + + ZFS related unit test data structures +''' + +# Import Python libs +from __future__ import absolute_import, unicode_literals, print_function + +# Import salt libs +import salt.utils.zfs + +# Import Salt tests libs +from tests.support.mock import MagicMock, patch + + +class ZFSMockData(object): + + def __init__(self): + # property_map mocks + self.pmap_exec_zpool = { + 'retcode': 2, + 'stdout': '', + 'stderr': "\n".join([ + 'missing property argument', + 'usage:', + ' get [-Hp] [-o "all" | field[,...]] <"all" | property[,...]> ...', + '', + 'the following properties are supported:', + '', + ' PROPERTY EDIT VALUES', + '', + ' allocated NO ', + ' capacity NO ', + ' dedupratio NO <1.00x or higher if deduped>', + ' expandsize NO ', + ' fragmentation NO ', + ' free NO ', + ' freeing NO ', + ' guid NO ', + ' health NO ', + ' leaked NO ', + ' size NO ', + ' altroot YES ', + ' autoexpand YES on | off', + ' autoreplace YES on | off', + ' bootfs YES ', + ' bootsize YES ', + ' cachefile YES | none', + ' comment YES ', + ' dedupditto YES ', + ' delegation YES on | off', + ' failmode YES wait | continue | panic', + ' listsnapshots YES on | off', + ' readonly YES on | off', + ' version YES ', + ' feature@... YES disabled | enabled | active', + '', + 'The feature@ properties must be appended with a feature name.', + 'See zpool-features(5). ', + ]), + } + self.pmap_zpool = { + 'comment': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'freeing': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'listsnapshots': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'leaked': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'version': { + 'edit': True, + 'type': 'numeric', + 'values': '' + }, + 'write': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'replace': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'delegation': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'dedupditto': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'autoexpand': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'alloc': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'allocated': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'guid': { + 'edit': False, + 'type': 'numeric', + 'values': '' + }, + 'size': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'cap': { + 'edit': False, + 'type': 'numeric', + 'values': '' + }, + 'capacity': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + "capacity-alloc": { + "edit": False, + "type": "size", + "values": "" + }, + "capacity-free": { + "edit": False, + "type": "size", + "values": "" + }, + 'cachefile': { + 'edit': True, + 'type': 'str', + 'values': ' | none' + }, + "cksum": { + "edit": False, + "type": "numeric", + "values": "" + }, + 'bootfs': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'autoreplace': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + "bandwith-read": { + "edit": False, + "type": "size", + "values": "" + }, + "bandwith-write": { + "edit": False, + "type": "size", + "values": "" + }, + "operations-read": { + "edit": False, + "type": "size", + "values": "" + }, + "operations-write": { + "edit": False, + "type": "size", + "values": "" + }, + "read": { + "edit": False, + "type": "size", + "values": "" + }, + 'readonly': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'dedupratio': { + 'edit': False, + 'type': 'str', + 'values': '<1.00x or higher if deduped>' + }, + 'health': { + 'edit': False, + 'type': 'str', + 'values': '' + }, + 'feature@': { + 'edit': True, + 'type': 'str', + 'values': 'disabled | enabled | active' + }, + 'expandsize': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'listsnaps': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'bootsize': { + 'edit': True, + 'type': 'size', + 'values': '' + }, + 'free': { + 'edit': False, + 'type': 'size', + 'values': '' + }, + 'failmode': { + 'edit': True, + 'type': 'str', + 'values': 'wait | continue | panic' + }, + 'altroot': { + 'edit': True, + 'type': 'str', + 'values': '' + }, + 'expand': { + 'edit': True, + 'type': 'bool', + 'values': 'on | off' + }, + 'frag': { + 'edit': False, + 'type': 'str', + 'values': '' + }, + 'fragmentation': { + 'edit': False, + 'type': 'str', + 'values': '' + } + } + self.pmap_exec_zfs = { + 'retcode': 2, + 'stdout': '', + 'stderr': "\n".join([ + 'missing property argument', + 'usage:', + ' get [-crHp] [-d max] [-o "all" | field[,...]]', + ' [-t type[,...]] [-s source[,...]]', + ' <"all" | property[,...]> [filesystem|volume|snapshot|bookmark] ...', + '', + 'The following properties are supported:', + '', + ' PROPERTY EDIT INHERIT VALUES', + '', + ' available NO NO ', + ' clones NO NO [,...]', + ' compressratio NO NO <1.00x or higher if compressed>', + ' creation NO NO ', + ' defer_destroy NO NO yes | no', + ' filesystem_count NO NO ', + ' logicalreferenced NO NO ', + ' logicalused NO NO ', + ' mounted NO NO yes | no', + ' origin NO NO ', + ' receive_resume_token NO NO ', + ' refcompressratio NO NO <1.00x or higher if compressed>', + ' referenced NO NO ', + ' snapshot_count NO NO ', + ' type NO NO filesystem | volume | snapshot | bookmark', + ' used NO NO ', + ' usedbychildren NO NO ', + ' usedbydataset NO NO ', + ' usedbyrefreservation NO NO ', + ' usedbysnapshots NO NO ', + ' userrefs NO NO ', + ' written NO NO ', + ' aclinherit YES YES discard | noallow | restricted | passthrough | passthrough-x', + ' aclmode YES YES discard | groupmask | passthrough | restricted', + ' atime YES YES on | off', + ' canmount YES NO on | off | noauto', + ' casesensitivity NO YES sensitive | insensitive | mixed', + ' checksum YES YES on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr', + ' compression YES YES on | off | lzjb | gzip | gzip-[1-9] | zle | lz4', + ' copies YES YES 1 | 2 | 3', + ' dedup YES YES on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify', + ' devices YES YES on | off', + ' exec YES YES on | off', + ' filesystem_limit YES NO | none', + ' logbias YES YES latency | throughput', + ' mlslabel YES YES ', + ' mountpoint YES YES | legacy | none', + ' nbmand YES YES on | off', + ' normalization NO YES none | formC | formD | formKC | formKD', + ' primarycache YES YES all | none | metadata', + ' quota YES NO | none', + ' readonly YES YES on | off', + ' recordsize YES YES 512 to 1M, power of 2', + ' redundant_metadata YES YES all | most', + ' refquota YES NO | none', + ' refreservation YES NO | none', + ' reservation YES NO | none', + ' secondarycache YES YES all | none | metadata', + ' setuid YES YES on | off', + ' sharenfs YES YES on | off | share(1M) options', + ' sharesmb YES YES on | off | sharemgr(1M) options', + ' snapdir YES YES hidden | visible', + ' snapshot_limit YES NO | none', + ' sync YES YES standard | always | disabled', + ' utf8only NO YES on | off', + ' version YES NO 1 | 2 | 3 | 4 | 5 | current', + ' volblocksize NO YES 512 to 128k, power of 2', + ' volsize YES NO ', + ' vscan YES YES on | off', + ' xattr YES YES on | off', + ' zoned YES YES on | off', + ' userused@... NO NO ', + ' groupused@... NO NO ', + ' userquota@... YES NO | none', + ' groupquota@... YES NO | none', + ' written@ NO NO ', + '', + 'Sizes are specified in bytes with standard units such as K, M, G, etc.', + '', + 'User-defined properties can be specified by using a name containing a colon (:).', + '', + 'The {user|group}{used|quota}@ properties must be appended with', + 'a user or group specifier of one of these forms:', + ' POSIX name (eg: "matt")', + ' POSIX id (eg: "126829")', + ' SMB name@domain (eg: "matt@sun")', + ' SMB SID (eg: "S-1-234-567-89")', + ]), + } + self.pmap_zfs = { + "origin": { + "edit": False, + "inherit": False, + "values": "", + "type": "str" + }, + "setuid": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "referenced": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "vscan": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "logicalused": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "userrefs": { + "edit": False, + "inherit": False, + "values": "", + "type": "numeric" + }, + "primarycache": { + "edit": True, + "inherit": True, + "values": "all | none | metadata", + "type": "str" + }, + "logbias": { + "edit": True, + "inherit": True, + "values": "latency | throughput", + "type": "str" + }, + "creation": { + "edit": False, + "inherit": False, + "values": "", + "type": "str" + }, + "sync": { + "edit": True, + "inherit": True, + "values": "standard | always | disabled", + "type": "str" + }, + "dedup": { + "edit": True, + "inherit": True, + "values": "on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify", + "type": "bool" + }, + "sharenfs": { + "edit": True, + "inherit": True, + "values": "on | off | share(1m) options", + "type": "bool" + }, + "receive_resume_token": { + "edit": False, + "inherit": False, + "values": "", + "type": "str" + }, + "usedbyrefreservation": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "sharesmb": { + "edit": True, + "inherit": True, + "values": "on | off | sharemgr(1m) options", + "type": "bool" + }, + "rdonly": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "reservation": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "reserv": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "mountpoint": { + "edit": True, + "inherit": True, + "values": " | legacy | none", + "type": "str" + }, + "casesensitivity": { + "edit": False, + "inherit": True, + "values": "sensitive | insensitive | mixed", + "type": "str" + }, + "utf8only": { + "edit": False, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "usedbysnapshots": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "readonly": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "written@": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "avail": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "recsize": { + "edit": True, + "inherit": True, + "values": "512 to 1m, power of 2", + "type": "str" + }, + "atime": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "compression": { + "edit": True, + "inherit": True, + "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", + "type": "bool" + }, + "snapdir": { + "edit": True, + "inherit": True, + "values": "hidden | visible", + "type": "str" + }, + "aclmode": { + "edit": True, + "inherit": True, + "values": "discard | groupmask | passthrough | restricted", + "type": "str" + }, + "zoned": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "copies": { + "edit": True, + "inherit": True, + "values": "1 | 2 | 3", + "type": "numeric" + }, + "snapshot_limit": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "numeric" + }, + "aclinherit": { + "edit": True, + "inherit": True, + "values": "discard | noallow | restricted | passthrough | passthrough-x", + "type": "str" + }, + "compressratio": { + "edit": False, + "inherit": False, + "values": "<1.00x or higher if compressed>", + "type": "str" + }, + "xattr": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "written": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "version": { + "edit": True, + "inherit": False, + "values": "1 | 2 | 3 | 4 | 5 | current", + "type": "numeric" + }, + "recordsize": { + "edit": True, + "inherit": True, + "values": "512 to 1m, power of 2", + "type": "str" + }, + "refquota": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "filesystem_limit": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "numeric" + }, + "lrefer.": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "type": { + "edit": False, + "inherit": False, + "values": "filesystem | volume | snapshot | bookmark", + "type": "str" + }, + "secondarycache": { + "edit": True, + "inherit": True, + "values": "all | none | metadata", + "type": "str" + }, + "refer": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "available": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "used": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "exec": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "compress": { + "edit": True, + "inherit": True, + "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", + "type": "bool" + }, + "volblock": { + "edit": False, + "inherit": True, + "values": "512 to 128k, power of 2", + "type": "str" + }, + "refcompressratio": { + "edit": False, + "inherit": False, + "values": "<1.00x or higher if compressed>", + "type": "str" + }, + "quota": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "groupquota@": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "userquota@": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "snapshot_count": { + "edit": False, + "inherit": False, + "values": "", + "type": "numeric" + }, + "volsize": { + "edit": True, + "inherit": False, + "values": "", + "type": "size" + }, + "clones": { + "edit": False, + "inherit": False, + "values": "[,...]", + "type": "str" + }, + "canmount": { + "edit": True, + "inherit": False, + "values": "on | off | noauto", + "type": "bool" + }, + "mounted": { + "edit": False, + "inherit": False, + "values": "yes | no", + "type": "bool_alt" + }, + "groupused@": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "normalization": { + "edit": False, + "inherit": True, + "values": "none | formc | formd | formkc | formkd", + "type": "str" + }, + "usedbychildren": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "usedbydataset": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "mlslabel": { + "edit": True, + "inherit": True, + "values": "", + "type": "str" + }, + "refreserv": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "defer_destroy": { + "edit": False, + "inherit": False, + "values": "yes | no", + "type": "bool_alt" + }, + "volblocksize": { + "edit": False, + "inherit": True, + "values": "512 to 128k, power of 2", + "type": "str" + }, + "lused.": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "redundant_metadata": { + "edit": True, + "inherit": True, + "values": "all | most", + "type": "str" + }, + "filesystem_count": { + "edit": False, + "inherit": False, + "values": "", + "type": "numeric" + }, + "devices": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + }, + "refreservation": { + "edit": True, + "inherit": False, + "values": " | none", + "type": "size" + }, + "userused@": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "logicalreferenced": { + "edit": False, + "inherit": False, + "values": "", + "type": "size" + }, + "checksum": { + "edit": True, + "inherit": True, + "values": "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr", + "type": "bool" + }, + "nbmand": { + "edit": True, + "inherit": True, + "values": "on | off", + "type": "bool" + } + } + + def _from_auto(self, name, value, source='auto'): + ''' + some more complex patching for zfs.from_auto + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.from_auto(name, value, source) + + def _from_auto_dict(self, values, source='auto'): + ''' + some more complex patching for zfs.from_auto_dict + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.from_auto_dict(values, source) + + def _to_auto(self, name, value, source='auto', convert_to_human=True): + ''' + some more complex patching for zfs.to_auto + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.to_auto(name, value, source, convert_to_human) + + def _to_auto_dict(self, values, source='auto', convert_to_human=True): + ''' + some more complex patching for zfs.to_auto_dict + ''' + with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)), \ + patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + return salt.utils.zfs.to_auto_dict(values, source, convert_to_human) + + def get_patched_utils(self): + return { + 'zfs.is_supported': MagicMock(return_value=True), + 'zfs.has_feature_flags': MagicMock(return_value=True), + 'zfs.property_data_zpool': MagicMock(return_value=self.pmap_zpool), + 'zfs.property_data_zfs': MagicMock(return_value=self.pmap_zfs), + # NOTE: we make zpool_command and zfs_command a NOOP + # these are extensively tested in tests.unit.utils.test_zfs + 'zfs.zpool_command': MagicMock(return_value='/bin/false'), + 'zfs.zfs_command': MagicMock(return_value='/bin/false'), + # NOTE: from_auto_dict is a special snowflake + # internally it calls multiple calls from + # salt.utils.zfs but we cannot patch those using + # the common methode, __utils__ is not available + # so they are direct calls, we do some voodoo here. + 'zfs.from_auto_dict': self._from_auto_dict, + 'zfs.from_auto': self._from_auto, + 'zfs.to_auto_dict': self._to_auto_dict, + 'zfs.to_auto': self._to_auto, + } diff --git a/tests/unit/modules/test_zfs.py b/tests/unit/modules/test_zfs.py index e66357f783da..e92cf2701d60 100644 --- a/tests/unit/modules/test_zfs.py +++ b/tests/unit/modules/test_zfs.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -22,9 +23,6 @@ NO_MOCK_REASON, ) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch - # Import Salt Execution module to test import salt.utils.zfs import salt.modules.zfs as zfs @@ -43,6 +41,10 @@ class ZfsTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) + utils = salt.loader.utils( opts, whitelist=['zfs', 'args', 'systemd', 'path', 'platform']) @@ -65,7 +67,7 @@ def test_exists_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertTrue(zfs.exists('myzpool/mydataset')) def test_exists_failure_not_exists(self): @@ -78,7 +80,7 @@ def test_exists_failure_not_exists(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertFalse(zfs.exists('myzpool/mydataset')) def test_exists_failure_invalid_name(self): @@ -91,7 +93,7 @@ def test_exists_failure_invalid_name(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertFalse(zfs.exists('myzpool/')) def test_create_success(self): @@ -105,7 +107,7 @@ def test_create_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset')) def test_create_success_with_create_parent(self): @@ -119,7 +121,7 @@ def test_create_success_with_create_parent(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset/mysubdataset', create_parent=True)) def test_create_success_with_properties(self): @@ -133,7 +135,7 @@ def test_create_success_with_properties(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual( res, zfs.create( @@ -159,7 +161,7 @@ def test_create_error_missing_dataset(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool')) def test_create_error_trailing_slash(self): @@ -176,7 +178,7 @@ def test_create_error_trailing_slash(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/')) def test_create_error_no_such_pool(self): @@ -193,7 +195,7 @@ def test_create_error_no_such_pool(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset')) def test_create_error_missing_parent(self): @@ -210,7 +212,7 @@ def test_create_error_missing_parent(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.create('myzpool/mydataset/mysubdataset')) def test_destroy_success(self): @@ -224,7 +226,7 @@ def test_destroy_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.destroy('myzpool/mydataset')) def test_destroy_error_not_exists(self): @@ -241,7 +243,7 @@ def test_destroy_error_not_exists(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.destroy('myzpool/mydataset')) def test_destroy_error_has_children(self): @@ -266,7 +268,7 @@ def test_destroy_error_has_children(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.destroy('myzpool/mydataset')) def test_rename_success(self): @@ -280,7 +282,7 @@ def test_rename_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rename('myzpool/mydataset', 'myzpool/newdataset')) def test_rename_error_not_exists(self): @@ -297,7 +299,7 @@ def test_rename_error_not_exists(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rename('myzpool/mydataset', 'myzpool/newdataset')) def test_list_success(self): @@ -318,7 +320,7 @@ def test_list_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool')) def test_list_parsable_success(self): @@ -339,7 +341,7 @@ def test_list_parsable_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool', parsable=False)) def test_list_custom_success(self): @@ -360,7 +362,7 @@ def test_list_custom_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool', properties='canmount,used,avail,compression')) def test_list_custom_parsable_success(self): @@ -381,7 +383,7 @@ def test_list_custom_parsable_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool', properties='canmount,used,avail,compression', parsable=False)) def test_list_error_no_dataset(self): @@ -395,7 +397,7 @@ def test_list_error_no_dataset(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_('myzpool')) def test_list_mount_success(self): @@ -415,7 +417,7 @@ def test_list_mount_success(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.list_mount()) def test_mount_success(self): @@ -429,7 +431,7 @@ def test_mount_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.mount('myzpool/mydataset')) def test_mount_failure(self): @@ -443,7 +445,7 @@ def test_mount_failure(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.mount('myzpool/mydataset')) def test_unmount_success(self): @@ -457,7 +459,7 @@ def test_unmount_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.unmount('myzpool/mydataset')) def test_unmount_failure(self): @@ -474,7 +476,7 @@ def test_unmount_failure(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.unmount('myzpool/mydataset')) def test_inherit_success(self): @@ -485,7 +487,7 @@ def test_inherit_success(self): ret = {'pid': 45193, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.inherit('compression', 'myzpool/mydataset')) def test_inherit_failure(self): @@ -499,7 +501,7 @@ def test_inherit_failure(self): ret = {'pid': 43898, 'retcode': 1, 'stderr': "'canmount' property cannot be inherited", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.inherit('canmount', 'myzpool/mydataset')) def test_diff(self): @@ -521,7 +523,7 @@ def test_diff(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.diff('myzpool/mydataset@yesterday', 'myzpool/mydataset')) def test_diff_parsed_time(self): @@ -545,7 +547,7 @@ def test_diff_parsed_time(self): ret['stderr'] = '' mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.diff('myzpool/data@yesterday', 'myzpool/data', parsable=False)) def test_rollback_success(self): @@ -556,7 +558,7 @@ def test_rollback_success(self): ret = {'pid': 56502, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rollback('myzpool/mydataset@yesterday')) def test_rollback_failure(self): @@ -582,7 +584,7 @@ def test_rollback_failure(self): } mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.rollback('myzpool/mydataset@yesterday')) def test_clone_success(self): @@ -593,7 +595,7 @@ def test_clone_success(self): ret = {'pid': 64532, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.clone('myzpool/mydataset@yesterday', 'myzpool/yesterday')) def test_clone_failure(self): @@ -607,7 +609,7 @@ def test_clone_failure(self): ret = {'pid': 64864, 'retcode': 1, 'stderr': "cannot create 'myzpool/archive/yesterday': parent does not exist", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.clone('myzpool/mydataset@yesterday', 'myzpool/archive/yesterday')) def test_promote_success(self): @@ -618,7 +620,7 @@ def test_promote_success(self): ret = {'pid': 69075, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.promote('myzpool/yesterday')) def test_promote_failure(self): @@ -632,7 +634,7 @@ def test_promote_failure(self): ret = {'pid': 69209, 'retcode': 1, 'stderr': "cannot promote 'myzpool/yesterday': not a cloned filesystem", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.promote('myzpool/yesterday')) def test_bookmark_success(self): @@ -644,7 +646,7 @@ def test_bookmark_success(self): ret = {'pid': 20990, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.bookmark('myzpool/mydataset@yesterday', 'myzpool/mydataset#important')) def test_holds_success(self): @@ -658,7 +660,7 @@ def test_holds_success(self): ret = {'pid': 40216, 'retcode': 0, 'stderr': '', 'stdout': 'myzpool/mydataset@baseline\timportant \tWed Dec 23 21:06 2015\nmyzpool/mydataset@baseline\trelease-1.0\tWed Dec 23 21:08 2015'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.holds('myzpool/mydataset@baseline')) def test_holds_failure(self): @@ -671,7 +673,7 @@ def test_holds_failure(self): ret = {'pid': 40993, 'retcode': 1, 'stderr': "cannot open 'myzpool/mydataset@baseline': dataset does not exist", 'stdout': 'no datasets available'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.holds('myzpool/mydataset@baseline')) def test_hold_success(self): @@ -682,7 +684,7 @@ def test_hold_success(self): ret = {'pid': 50876, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.hold('important', 'myzpool/mydataset@baseline', 'myzpool/mydataset@release-1.0')) def test_hold_failure(self): @@ -696,7 +698,7 @@ def test_hold_failure(self): ret = {'pid': 51006, 'retcode': 1, 'stderr': "cannot hold snapshot 'myzpool/mydataset@baseline': tag already exists on this dataset", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.hold('important', 'myzpool/mydataset@baseline')) def test_release_success(self): @@ -707,7 +709,7 @@ def test_release_success(self): ret = {'pid': 50876, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.release('important', 'myzpool/mydataset@baseline', 'myzpool/mydataset@release-1.0')) def test_release_failure(self): @@ -721,7 +723,7 @@ def test_release_failure(self): ret = {'pid': 51006, 'retcode': 1, 'stderr': "cannot release hold from snapshot 'myzpool/mydataset@baseline': no such tag on this dataset", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.release('important', 'myzpool/mydataset@baseline')) def test_snapshot_success(self): @@ -732,7 +734,7 @@ def test_snapshot_success(self): ret = {'pid': 69125, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.snapshot('myzpool/mydataset@baseline')) def test_snapshot_failure(self): @@ -746,7 +748,7 @@ def test_snapshot_failure(self): ret = {'pid': 68526, 'retcode': 1, 'stderr': "cannot create snapshot 'myzpool/mydataset@baseline': dataset already exists", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.snapshot('myzpool/mydataset@baseline')) def test_snapshot_failure2(self): @@ -760,7 +762,7 @@ def test_snapshot_failure2(self): ret = {'pid': 69256, 'retcode': 2, 'stderr': "cannot open 'myzpool/mydataset': dataset does not exist\nusage:\n\tsnapshot [-r] [-o property=value] ... @ ...\n\nFor the property list, run: zfs set|get\n\nFor the delegated permission list, run: zfs allow|unallow", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.snapshot('myzpool/mydataset@baseline')) def test_set_success(self): @@ -771,7 +773,7 @@ def test_set_success(self): ret = {'pid': 79736, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.set('myzpool/mydataset', compression='lz4')) def test_set_failure(self): @@ -785,7 +787,7 @@ def test_set_failure(self): ret = {'pid': 79887, 'retcode': 1, 'stderr': "cannot set property for 'myzpool/mydataset': 'canmount' must be one of 'on | off | noauto'", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.set('myzpool/mydataset', canmount='lz4')) def test_get_success(self): @@ -802,7 +804,7 @@ def test_get_success(self): ret = {'pid': 562, 'retcode': 0, 'stderr': '', 'stdout': 'myzpool\tused\t906238099456'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.get('myzpool', properties='used', fields='value')) def test_get_parsable_success(self): @@ -819,5 +821,5 @@ def test_get_parsable_success(self): ret = {'pid': 562, 'retcode': 0, 'stderr': '', 'stdout': 'myzpool\tused\t906238099456'} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(res, zfs.get('myzpool', properties='used', fields='value', parsable=False)) diff --git a/tests/unit/modules/test_zpool.py b/tests/unit/modules/test_zpool.py index 1ec1497c97c7..d3ad2634b9ac 100644 --- a/tests/unit/modules/test_zpool.py +++ b/tests/unit/modules/test_zpool.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, print_function, unicode_literals # Import Salt Testing libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -22,8 +23,6 @@ NO_MOCK_REASON, ) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch # Import Salt Execution module to test import salt.utils.zfs @@ -44,6 +43,9 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) utils = salt.loader.utils( opts, whitelist=['zfs', 'args', 'systemd', 'path', 'platform']) @@ -67,7 +69,7 @@ def test_exists_success(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertTrue(zpool.exists('myzpool')) def test_exists_failure(self): @@ -81,7 +83,7 @@ def test_exists_failure(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertFalse(zpool.exists('myzpool')) def test_healthy(self): @@ -95,7 +97,7 @@ def test_healthy(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertTrue(zpool.healthy()) def test_status(self): @@ -121,7 +123,7 @@ def test_status(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.status() self.assertEqual('ONLINE', ret['mypool']['state']) @@ -144,7 +146,7 @@ def test_iostat(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.iostat('mypool', parsable=False) self.assertEqual('46.7G', ret['mypool']['capacity-alloc']) @@ -172,7 +174,7 @@ def test_iostat_parsable(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.iostat('mypool', parsable=True) self.assertEqual(50143743180, ret['mypool']['capacity-alloc']) @@ -186,7 +188,7 @@ def test_list(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.list_(parsable=False) res = OrderedDict([('mypool', OrderedDict([ ('size', '1.81T'), @@ -208,7 +210,7 @@ def test_list_parsable(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.list_(parsable=True) res = OrderedDict([('mypool', OrderedDict([ ('size', 1990116046274), @@ -230,7 +232,7 @@ def test_get(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.get('mypool', 'size', parsable=False) res = OrderedDict(OrderedDict([('size', '1.81T')])) self.assertEqual(ret, res) @@ -245,7 +247,7 @@ def test_get_parsable(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.get('mypool', 'size', parsable=True) res = OrderedDict(OrderedDict([('size', 1990116046274)])) self.assertEqual(ret, res) @@ -260,7 +262,7 @@ def test_get_whitespace(self): ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.get('mypool', 'comment') res = OrderedDict(OrderedDict([('comment', "my testing pool")])) self.assertEqual(ret, res) @@ -278,7 +280,7 @@ def test_scrub_start(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.scrub('mypool') res = OrderedDict(OrderedDict([('scrubbing', True)])) self.assertEqual(ret, res) @@ -296,7 +298,7 @@ def test_scrub_pause(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.scrub('mypool', pause=True) res = OrderedDict(OrderedDict([('scrubbing', False)])) self.assertEqual(ret, res) @@ -314,7 +316,7 @@ def test_scrub_stop(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.scrub('mypool', stop=True) res = OrderedDict(OrderedDict([('scrubbing', False)])) self.assertEqual(ret, res) @@ -330,7 +332,7 @@ def test_split_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', True)]) self.assertEqual(ret, res) @@ -346,7 +348,7 @@ def test_split_exist_new(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', 'Unable to split datapool: pool already exists')]) self.assertEqual(ret, res) @@ -362,7 +364,7 @@ def test_split_missing_pool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', "cannot open 'datapool': no such pool")]) self.assertEqual(ret, res) @@ -378,7 +380,7 @@ def test_split_not_mirror(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', 'Unable to split datapool: Source pool must be composed only of mirrors')]) self.assertEqual(ret, res) @@ -394,7 +396,7 @@ def test_labelclear_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([('labelcleared', True)]) self.assertEqual(ret, res) @@ -410,7 +412,7 @@ def test_labelclear_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([ ('labelcleared', False), @@ -429,7 +431,7 @@ def test_labelclear_cleared(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([ ('labelcleared', False), @@ -450,7 +452,7 @@ def test_labelclear_exported(self): ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.labelclear('/dev/rdsk/c0t0d0', force=False) res = OrderedDict([ ('labelcleared', False), @@ -470,7 +472,7 @@ def test_create_file_vdev_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.create_file_vdev('64M', '/vdisks/disk0') res = OrderedDict([ ('/vdisks/disk0', 'created'), @@ -489,7 +491,7 @@ def test_create_file_vdev_nospace(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.create_file_vdev('64M', '/vdisks/disk0') res = OrderedDict([ ('/vdisks/disk0', 'failed'), @@ -510,7 +512,7 @@ def test_export_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.export('mypool') res = OrderedDict([('exported', True)]) self.assertEqual(ret, res) @@ -526,7 +528,7 @@ def test_export_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.export('mypool') res = OrderedDict([('exported', False), ('error', "cannot open 'mypool': no such pool")]) self.assertEqual(ret, res) @@ -542,7 +544,7 @@ def test_import_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.import_('mypool') res = OrderedDict([('imported', True)]) self.assertEqual(ret, res) @@ -561,7 +563,7 @@ def test_import_duplicate(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.import_('mypool') res = OrderedDict([ ('imported', False), @@ -580,7 +582,7 @@ def test_import_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.import_('mypool') res = OrderedDict([ ('imported', False), @@ -599,7 +601,7 @@ def test_online_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.online('mypool', '/dev/rdsk/c0t0d0') res = OrderedDict([('onlined', True)]) self.assertEqual(ret, res) @@ -615,7 +617,7 @@ def test_online_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.online('mypool', '/dev/rdsk/c0t0d1') res = OrderedDict([ ('onlined', False), @@ -634,7 +636,7 @@ def test_offline_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.offline('mypool', '/dev/rdsk/c0t0d0') res = OrderedDict([('offlined', True)]) self.assertEqual(ret, res) @@ -650,7 +652,7 @@ def test_offline_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.offline('mypool', '/dev/rdsk/c0t0d1') res = OrderedDict([ ('offlined', False), @@ -669,7 +671,7 @@ def test_offline_noreplica(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.offline('mypool', '/dev/rdsk/c0t0d1') res = OrderedDict([ ('offlined', False), @@ -688,7 +690,7 @@ def test_reguid_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reguid('mypool') res = OrderedDict([('reguided', True)]) self.assertEqual(ret, res) @@ -704,7 +706,7 @@ def test_reguid_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reguid('mypool') res = OrderedDict([ ('reguided', False), @@ -723,7 +725,7 @@ def test_reopen_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reopen('mypool') res = OrderedDict([('reopened', True)]) self.assertEqual(ret, res) @@ -739,7 +741,7 @@ def test_reopen_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.reopen('mypool') res = OrderedDict([ ('reopened', False), @@ -758,7 +760,7 @@ def test_upgrade_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.upgrade('mypool') res = OrderedDict([('upgraded', True)]) self.assertEqual(ret, res) @@ -774,7 +776,7 @@ def test_upgrade_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.upgrade('mypool') res = OrderedDict([ ('upgraded', False), @@ -797,7 +799,7 @@ def test_history_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.history('mypool') res = OrderedDict([ ('mypool', OrderedDict([ @@ -818,7 +820,7 @@ def test_history_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.history('mypool') res = OrderedDict([ ('error', "cannot open 'mypool': no such pool"), @@ -836,7 +838,7 @@ def test_clear_success(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.clear('mypool') res = OrderedDict([('cleared', True)]) self.assertEqual(ret, res) @@ -852,7 +854,7 @@ def test_clear_nopool(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.clear('mypool') res = OrderedDict([ ('cleared', False), @@ -870,7 +872,7 @@ def test_clear_nodevice(self): mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.clear('mypool', '/dev/rdsk/c0t0d0') res = OrderedDict([ ('cleared', False), diff --git a/tests/unit/states/test_zfs.py b/tests/unit/states/test_zfs.py index d944f331020d..0d673958c8b7 100644 --- a/tests/unit/states/test_zfs.py +++ b/tests/unit/states/test_zfs.py @@ -12,6 +12,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing Libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -20,9 +21,6 @@ MagicMock, patch) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch - # Import Salt Execution module to test import salt.utils.zfs import salt.states.zfs as zfs @@ -39,6 +37,9 @@ class ZfsTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) utils = salt.loader.utils(opts, whitelist=['zfs']) zfs_obj = { zfs: { @@ -61,7 +62,7 @@ def test_filesystem_absent_nofs(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_absent('myzpool/filesystem')) def test_filesystem_absent_removed(self): @@ -77,7 +78,7 @@ def test_filesystem_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_absent('myzpool/filesystem')) def test_filesystem_absent_fail(self): @@ -104,7 +105,7 @@ def test_filesystem_absent_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_absent('myzpool/filesystem')) def test_volume_absent_novol(self): @@ -118,7 +119,7 @@ def test_volume_absent_novol(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_absent('myzpool/volume')) def test_volume_absent_removed(self): @@ -134,7 +135,7 @@ def test_volume_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_absent('myzpool/volume')) def test_volume_absent_fail(self): @@ -161,7 +162,7 @@ def test_volume_absent_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_absent('myzpool/volume')) def test_snapshot_absent_nosnap(self): @@ -175,7 +176,7 @@ def test_snapshot_absent_nosnap(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_absent('myzpool/filesystem@snap')) def test_snapshot_absent_removed(self): @@ -191,7 +192,7 @@ def test_snapshot_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_absent('myzpool/filesystem@snap')) def test_snapshot_absent_fail(self): @@ -210,7 +211,7 @@ def test_snapshot_absent_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_absent('myzpool/filesystem@snap')) def test_bookmark_absent_nobook(self): @@ -224,7 +225,7 @@ def test_bookmark_absent_nobook(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_absent('myzpool/filesystem#book')) def test_bookmark_absent_removed(self): @@ -240,7 +241,7 @@ def test_bookmark_absent_removed(self): mock_destroy = MagicMock(return_value=OrderedDict([('destroyed', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_absent('myzpool/filesystem#book')) def test_hold_absent_nohold(self): @@ -254,7 +255,7 @@ def test_hold_absent_nohold(self): mock_holds = MagicMock(return_value=OrderedDict([])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_absent('myhold', 'myzpool/filesystem@snap')) def test_hold_absent_removed(self): @@ -274,7 +275,7 @@ def test_hold_absent_removed(self): mock_release = MagicMock(return_value=OrderedDict([('released', True)])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ patch.dict(zfs.__salt__, {'zfs.release': mock_release}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_absent('myhold', 'myzpool/filesystem@snap')) def test_hold_absent_fail(self): @@ -290,7 +291,7 @@ def test_hold_absent_fail(self): ('error', "cannot open 'myzpool/filesystem@snap': dataset does not exist"), ])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_absent('myhold', 'myzpool/filesystem@snap')) def test_hold_present(self): @@ -304,7 +305,7 @@ def test_hold_present(self): mock_holds = MagicMock(return_value=OrderedDict([('myhold', 'Thu Feb 15 16:24 2018')])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_present('myhold', 'myzpool/filesystem@snap')) def test_hold_present_new(self): @@ -320,7 +321,7 @@ def test_hold_present_new(self): mock_hold = MagicMock(return_value=OrderedDict([('held', True)])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ patch.dict(zfs.__salt__, {'zfs.hold': mock_hold}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_present('myhold', 'myzpool/filesystem@snap')) def test_hold_present_fail(self): @@ -339,7 +340,7 @@ def test_hold_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.holds': mock_holds}), \ patch.dict(zfs.__salt__, {'zfs.hold': mock_hold}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.hold_present('myhold', 'myzpool/filesystem@snap')) def test_filesystem_present(self): @@ -364,7 +365,7 @@ def test_filesystem_present(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present('myzpool/filesystem')) def test_filesystem_present_new(self): @@ -380,7 +381,7 @@ def test_filesystem_present_new(self): mock_create = MagicMock(return_value=OrderedDict([('created', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present('myzpool/filesystem')) def test_filesystem_present_update(self): @@ -407,7 +408,7 @@ def test_filesystem_present_update(self): with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ patch.dict(zfs.__salt__, {'zfs.set': mock_set}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present( name='myzpool/filesystem', properties={'compression': 'lz4'}, @@ -429,7 +430,7 @@ def test_filesystem_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.filesystem_present('myzpool/filesystem')) def test_volume_present(self): @@ -454,7 +455,7 @@ def test_volume_present(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present('myzpool/volume', volume_size='1G')) def test_volume_present_new(self): @@ -470,7 +471,7 @@ def test_volume_present_new(self): mock_create = MagicMock(return_value=OrderedDict([('created', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present('myzpool/volume', volume_size='1G')) def test_volume_present_update(self): @@ -497,7 +498,7 @@ def test_volume_present_update(self): with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ patch.dict(zfs.__salt__, {'zfs.set': mock_set}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present( name='myzpool/volume', volume_size='1G', @@ -520,7 +521,7 @@ def test_volume_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.create': mock_create}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.volume_present('myzpool/volume', volume_size='1G')) def test_bookmark_present(self): @@ -534,7 +535,7 @@ def test_bookmark_present(self): mock_exists = MagicMock(return_value=True) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_present('mybookmark', 'myzpool/filesystem@snap')) def test_bookmark_present_new(self): @@ -550,7 +551,7 @@ def test_bookmark_present_new(self): mock_bookmark = MagicMock(return_value=OrderedDict([('bookmarked', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.bookmark': mock_bookmark}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_present('mybookmark', 'myzpool/filesystem@snap')) def test_bookmark_present_fail(self): @@ -569,7 +570,7 @@ def test_bookmark_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.bookmark': mock_bookmark}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.bookmark_present('mybookmark', 'myzpool/filesystem@snap')) def test_snapshot_present(self): @@ -583,7 +584,7 @@ def test_snapshot_present(self): mock_exists = MagicMock(return_value=True) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_present('myzpool/filesystem@snap')) def test_snapshot_present_new(self): @@ -599,7 +600,7 @@ def test_snapshot_present_new(self): mock_snapshot = MagicMock(return_value=OrderedDict([('snapshotted', True)])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.snapshot': mock_snapshot}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_present('myzpool/filesystem@snap')) def test_snapshot_present_fail(self): @@ -618,7 +619,7 @@ def test_snapshot_present_fail(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.snapshot': mock_snapshot}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.snapshot_present('myzpool/filesystem@snap')) def test_propmoted(self): @@ -640,7 +641,7 @@ def test_propmoted(self): ])) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.promoted('myzpool/filesystem')) def test_propmoted_clone(self): @@ -664,7 +665,7 @@ def test_propmoted_clone(self): with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ patch.dict(zfs.__salt__, {'zfs.get': mock_get}), \ patch.dict(zfs.__salt__, {'zfs.promote': mock_promote}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.promoted('myzpool/filesystem')) def test_propmoted_fail(self): @@ -678,7 +679,7 @@ def test_propmoted_fail(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.promoted('myzpool/filesystem')) def test_scheduled_snapshot_fail(self): @@ -692,5 +693,5 @@ def test_scheduled_snapshot_fail(self): mock_exists = MagicMock(return_value=False) with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \ - patch.dict(zfs.__utils__, utils_patch): + patch.dict(zfs.__utils__, self.utils_patch): self.assertEqual(ret, zfs.scheduled_snapshot('myzpool/filesystem', 'shadow', schedule={'hour': 6})) diff --git a/tests/unit/states/test_zpool.py b/tests/unit/states/test_zpool.py index 334cdc665fe1..d41ced75010a 100644 --- a/tests/unit/states/test_zpool.py +++ b/tests/unit/states/test_zpool.py @@ -12,6 +12,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing Libs +from tests.support.zfs import ZFSMockData from tests.support.mixins import LoaderModuleMockMixin from tests.support.unit import skipIf, TestCase from tests.support.mock import ( @@ -20,9 +21,6 @@ MagicMock, patch) -# Import test data from salt.utils.zfs test -from tests.unit.utils.test_zfs import utils_patch - # Import Salt Execution module to test import salt.utils.zfs import salt.states.zpool as zpool @@ -39,6 +37,9 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin): ''' def setup_loader_modules(self): self.opts = opts = salt.config.DEFAULT_MINION_OPTS.copy() + self.utils_patch = ZFSMockData().get_patched_utils() + for key in ('opts', 'utils_patch'): + self.addCleanup(delattr, self, key) utils = salt.loader.utils(opts, whitelist=['zfs']) zpool_obj = { zpool: { @@ -61,7 +62,7 @@ def test_absent_without_pool(self): mock_exists = MagicMock(return_value=False) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool'), ret) def test_absent_destroy_pool(self): @@ -81,7 +82,7 @@ def test_absent_destroy_pool(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.destroy': mock_destroy}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool'), ret) def test_absent_exporty_pool(self): @@ -101,7 +102,7 @@ def test_absent_exporty_pool(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.export': mock_destroy}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool', export=True), ret) def test_absent_busy(self): @@ -128,7 +129,7 @@ def test_absent_busy(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.export': mock_destroy}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.absent('myzpool', export=True), ret) def test_present_import_success(self): @@ -150,7 +151,7 @@ def test_present_import_success(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.import': mock_import}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.present('myzpool', config=config), ret) def test_present_import_fail(self): @@ -172,7 +173,7 @@ def test_present_import_fail(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.import': mock_import}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.present('myzpool', config=config), ret) def test_present_create_success(self): @@ -208,7 +209,7 @@ def test_present_create_success(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.create': mock_create}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', @@ -235,7 +236,7 @@ def test_present_create_fail(self): mock_exists = MagicMock(return_value=False) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual(zpool.present('myzpool', config=config), ret) def test_present_create_passthrough_fail(self): @@ -279,7 +280,7 @@ def test_present_create_passthrough_fail(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.create': mock_create}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', @@ -361,7 +362,7 @@ def test_present_update_success(self): with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.get': mock_get}), \ patch.dict(zpool.__salt__, {'zpool.set': mock_set}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', @@ -438,7 +439,7 @@ def test_present_update_nochange_success(self): ])) with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}), \ patch.dict(zpool.__salt__, {'zpool.get': mock_get}), \ - patch.dict(zpool.__utils__, utils_patch): + patch.dict(zpool.__utils__, self.utils_patch): self.assertEqual( zpool.present( 'myzpool', diff --git a/tests/unit/utils/test_zfs.py b/tests/unit/utils/test_zfs.py index 29b3fe893f49..37ad70df0870 100644 --- a/tests/unit/utils/test_zfs.py +++ b/tests/unit/utils/test_zfs.py @@ -14,6 +14,7 @@ from __future__ import absolute_import, unicode_literals, print_function # Import Salt Testing libs +from tests.support.zfs import ZFSMockData from tests.support.unit import skipIf, TestCase from tests.support.mock import ( MagicMock, @@ -26,863 +27,8 @@ import salt.utils.zfs as zfs # Import Salt Utils -import salt.loader from salt.utils.odict import OrderedDict -# property_map mocks -pmap_exec_zpool = { - 'retcode': 2, - 'stdout': '', - 'stderr': "\n".join([ - 'missing property argument', - 'usage:', - ' get [-Hp] [-o "all" | field[,...]] <"all" | property[,...]> ...', - '', - 'the following properties are supported:', - '', - ' PROPERTY EDIT VALUES', - '', - ' allocated NO ', - ' capacity NO ', - ' dedupratio NO <1.00x or higher if deduped>', - ' expandsize NO ', - ' fragmentation NO ', - ' free NO ', - ' freeing NO ', - ' guid NO ', - ' health NO ', - ' leaked NO ', - ' size NO ', - ' altroot YES ', - ' autoexpand YES on | off', - ' autoreplace YES on | off', - ' bootfs YES ', - ' bootsize YES ', - ' cachefile YES | none', - ' comment YES ', - ' dedupditto YES ', - ' delegation YES on | off', - ' failmode YES wait | continue | panic', - ' listsnapshots YES on | off', - ' readonly YES on | off', - ' version YES ', - ' feature@... YES disabled | enabled | active', - '', - 'The feature@ properties must be appended with a feature name.', - 'See zpool-features(5). ', - ]), -} -pmap_zpool = { - 'comment': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'freeing': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'listsnapshots': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'leaked': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'version': { - 'edit': True, - 'type': 'numeric', - 'values': '' - }, - 'write': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'replace': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'delegation': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'dedupditto': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'autoexpand': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'alloc': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'allocated': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'guid': { - 'edit': False, - 'type': 'numeric', - 'values': '' - }, - 'size': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'cap': { - 'edit': False, - 'type': 'numeric', - 'values': '' - }, - 'capacity': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - "capacity-alloc": { - "edit": False, - "type": "size", - "values": "" - }, - "capacity-free": { - "edit": False, - "type": "size", - "values": "" - }, - 'cachefile': { - 'edit': True, - 'type': 'str', - 'values': ' | none' - }, - "cksum": { - "edit": False, - "type": "numeric", - "values": "" - }, - 'bootfs': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'autoreplace': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - "bandwith-read": { - "edit": False, - "type": "size", - "values": "" - }, - "bandwith-write": { - "edit": False, - "type": "size", - "values": "" - }, - "operations-read": { - "edit": False, - "type": "size", - "values": "" - }, - "operations-write": { - "edit": False, - "type": "size", - "values": "" - }, - "read": { - "edit": False, - "type": "size", - "values": "" - }, - 'readonly': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'dedupratio': { - 'edit': False, - 'type': 'str', - 'values': '<1.00x or higher if deduped>' - }, - 'health': { - 'edit': False, - 'type': 'str', - 'values': '' - }, - 'feature@': { - 'edit': True, - 'type': 'str', - 'values': 'disabled | enabled | active' - }, - 'expandsize': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'listsnaps': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'bootsize': { - 'edit': True, - 'type': 'size', - 'values': '' - }, - 'free': { - 'edit': False, - 'type': 'size', - 'values': '' - }, - 'failmode': { - 'edit': True, - 'type': 'str', - 'values': 'wait | continue | panic' - }, - 'altroot': { - 'edit': True, - 'type': 'str', - 'values': '' - }, - 'expand': { - 'edit': True, - 'type': 'bool', - 'values': 'on | off' - }, - 'frag': { - 'edit': False, - 'type': 'str', - 'values': '' - }, - 'fragmentation': { - 'edit': False, - 'type': 'str', - 'values': '' - } -} -pmap_exec_zfs = { - 'retcode': 2, - 'stdout': '', - 'stderr': "\n".join([ - 'missing property argument', - 'usage:', - ' get [-crHp] [-d max] [-o "all" | field[,...]]', - ' [-t type[,...]] [-s source[,...]]', - ' <"all" | property[,...]> [filesystem|volume|snapshot|bookmark] ...', - '', - 'The following properties are supported:', - '', - ' PROPERTY EDIT INHERIT VALUES', - '', - ' available NO NO ', - ' clones NO NO [,...]', - ' compressratio NO NO <1.00x or higher if compressed>', - ' creation NO NO ', - ' defer_destroy NO NO yes | no', - ' filesystem_count NO NO ', - ' logicalreferenced NO NO ', - ' logicalused NO NO ', - ' mounted NO NO yes | no', - ' origin NO NO ', - ' receive_resume_token NO NO ', - ' refcompressratio NO NO <1.00x or higher if compressed>', - ' referenced NO NO ', - ' snapshot_count NO NO ', - ' type NO NO filesystem | volume | snapshot | bookmark', - ' used NO NO ', - ' usedbychildren NO NO ', - ' usedbydataset NO NO ', - ' usedbyrefreservation NO NO ', - ' usedbysnapshots NO NO ', - ' userrefs NO NO ', - ' written NO NO ', - ' aclinherit YES YES discard | noallow | restricted | passthrough | passthrough-x', - ' aclmode YES YES discard | groupmask | passthrough | restricted', - ' atime YES YES on | off', - ' canmount YES NO on | off | noauto', - ' casesensitivity NO YES sensitive | insensitive | mixed', - ' checksum YES YES on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr', - ' compression YES YES on | off | lzjb | gzip | gzip-[1-9] | zle | lz4', - ' copies YES YES 1 | 2 | 3', - ' dedup YES YES on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify', - ' devices YES YES on | off', - ' exec YES YES on | off', - ' filesystem_limit YES NO | none', - ' logbias YES YES latency | throughput', - ' mlslabel YES YES ', - ' mountpoint YES YES | legacy | none', - ' nbmand YES YES on | off', - ' normalization NO YES none | formC | formD | formKC | formKD', - ' primarycache YES YES all | none | metadata', - ' quota YES NO | none', - ' readonly YES YES on | off', - ' recordsize YES YES 512 to 1M, power of 2', - ' redundant_metadata YES YES all | most', - ' refquota YES NO | none', - ' refreservation YES NO | none', - ' reservation YES NO | none', - ' secondarycache YES YES all | none | metadata', - ' setuid YES YES on | off', - ' sharenfs YES YES on | off | share(1M) options', - ' sharesmb YES YES on | off | sharemgr(1M) options', - ' snapdir YES YES hidden | visible', - ' snapshot_limit YES NO | none', - ' sync YES YES standard | always | disabled', - ' utf8only NO YES on | off', - ' version YES NO 1 | 2 | 3 | 4 | 5 | current', - ' volblocksize NO YES 512 to 128k, power of 2', - ' volsize YES NO ', - ' vscan YES YES on | off', - ' xattr YES YES on | off', - ' zoned YES YES on | off', - ' userused@... NO NO ', - ' groupused@... NO NO ', - ' userquota@... YES NO | none', - ' groupquota@... YES NO | none', - ' written@ NO NO ', - '', - 'Sizes are specified in bytes with standard units such as K, M, G, etc.', - '', - 'User-defined properties can be specified by using a name containing a colon (:).', - '', - 'The {user|group}{used|quota}@ properties must be appended with', - 'a user or group specifier of one of these forms:', - ' POSIX name (eg: "matt")', - ' POSIX id (eg: "126829")', - ' SMB name@domain (eg: "matt@sun")', - ' SMB SID (eg: "S-1-234-567-89")', - ]), -} -pmap_zfs = { - "origin": { - "edit": False, - "inherit": False, - "values": "", - "type": "str" - }, - "setuid": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "referenced": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "vscan": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "logicalused": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "userrefs": { - "edit": False, - "inherit": False, - "values": "", - "type": "numeric" - }, - "primarycache": { - "edit": True, - "inherit": True, - "values": "all | none | metadata", - "type": "str" - }, - "logbias": { - "edit": True, - "inherit": True, - "values": "latency | throughput", - "type": "str" - }, - "creation": { - "edit": False, - "inherit": False, - "values": "", - "type": "str" - }, - "sync": { - "edit": True, - "inherit": True, - "values": "standard | always | disabled", - "type": "str" - }, - "dedup": { - "edit": True, - "inherit": True, - "values": "on | off | verify | sha256[,verify], sha512[,verify], skein[,verify], edonr,verify", - "type": "bool" - }, - "sharenfs": { - "edit": True, - "inherit": True, - "values": "on | off | share(1m) options", - "type": "bool" - }, - "receive_resume_token": { - "edit": False, - "inherit": False, - "values": "", - "type": "str" - }, - "usedbyrefreservation": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "sharesmb": { - "edit": True, - "inherit": True, - "values": "on | off | sharemgr(1m) options", - "type": "bool" - }, - "rdonly": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "reservation": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "reserv": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "mountpoint": { - "edit": True, - "inherit": True, - "values": " | legacy | none", - "type": "str" - }, - "casesensitivity": { - "edit": False, - "inherit": True, - "values": "sensitive | insensitive | mixed", - "type": "str" - }, - "utf8only": { - "edit": False, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "usedbysnapshots": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "readonly": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "written@": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "avail": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "recsize": { - "edit": True, - "inherit": True, - "values": "512 to 1m, power of 2", - "type": "str" - }, - "atime": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "compression": { - "edit": True, - "inherit": True, - "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", - "type": "bool" - }, - "snapdir": { - "edit": True, - "inherit": True, - "values": "hidden | visible", - "type": "str" - }, - "aclmode": { - "edit": True, - "inherit": True, - "values": "discard | groupmask | passthrough | restricted", - "type": "str" - }, - "zoned": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "copies": { - "edit": True, - "inherit": True, - "values": "1 | 2 | 3", - "type": "numeric" - }, - "snapshot_limit": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "numeric" - }, - "aclinherit": { - "edit": True, - "inherit": True, - "values": "discard | noallow | restricted | passthrough | passthrough-x", - "type": "str" - }, - "compressratio": { - "edit": False, - "inherit": False, - "values": "<1.00x or higher if compressed>", - "type": "str" - }, - "xattr": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "written": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "version": { - "edit": True, - "inherit": False, - "values": "1 | 2 | 3 | 4 | 5 | current", - "type": "numeric" - }, - "recordsize": { - "edit": True, - "inherit": True, - "values": "512 to 1m, power of 2", - "type": "str" - }, - "refquota": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "filesystem_limit": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "numeric" - }, - "lrefer.": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "type": { - "edit": False, - "inherit": False, - "values": "filesystem | volume | snapshot | bookmark", - "type": "str" - }, - "secondarycache": { - "edit": True, - "inherit": True, - "values": "all | none | metadata", - "type": "str" - }, - "refer": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "available": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "used": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "exec": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "compress": { - "edit": True, - "inherit": True, - "values": "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4", - "type": "bool" - }, - "volblock": { - "edit": False, - "inherit": True, - "values": "512 to 128k, power of 2", - "type": "str" - }, - "refcompressratio": { - "edit": False, - "inherit": False, - "values": "<1.00x or higher if compressed>", - "type": "str" - }, - "quota": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "groupquota@": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "userquota@": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "snapshot_count": { - "edit": False, - "inherit": False, - "values": "", - "type": "numeric" - }, - "volsize": { - "edit": True, - "inherit": False, - "values": "", - "type": "size" - }, - "clones": { - "edit": False, - "inherit": False, - "values": "[,...]", - "type": "str" - }, - "canmount": { - "edit": True, - "inherit": False, - "values": "on | off | noauto", - "type": "bool" - }, - "mounted": { - "edit": False, - "inherit": False, - "values": "yes | no", - "type": "bool_alt" - }, - "groupused@": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "normalization": { - "edit": False, - "inherit": True, - "values": "none | formc | formd | formkc | formkd", - "type": "str" - }, - "usedbychildren": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "usedbydataset": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "mlslabel": { - "edit": True, - "inherit": True, - "values": "", - "type": "str" - }, - "refreserv": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "defer_destroy": { - "edit": False, - "inherit": False, - "values": "yes | no", - "type": "bool_alt" - }, - "volblocksize": { - "edit": False, - "inherit": True, - "values": "512 to 128k, power of 2", - "type": "str" - }, - "lused.": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "redundant_metadata": { - "edit": True, - "inherit": True, - "values": "all | most", - "type": "str" - }, - "filesystem_count": { - "edit": False, - "inherit": False, - "values": "", - "type": "numeric" - }, - "devices": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - }, - "refreservation": { - "edit": True, - "inherit": False, - "values": " | none", - "type": "size" - }, - "userused@": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "logicalreferenced": { - "edit": False, - "inherit": False, - "values": "", - "type": "size" - }, - "checksum": { - "edit": True, - "inherit": True, - "values": "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein | edonr", - "type": "bool" - }, - "nbmand": { - "edit": True, - "inherit": True, - "values": "on | off", - "type": "bool" - } -} - - -def _from_auto(name, value, source='auto'): - ''' - some more complex patching for zfs.from_auto - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.from_auto(name, value, source) - - -def _from_auto_dict(values, source='auto'): - ''' - some more complex patching for zfs.from_auto_dict - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.from_auto_dict(values, source) - - -def _to_auto(name, value, source='auto', convert_to_human=True): - ''' - some more complex patching for zfs.to_auto - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.to_auto(name, value, source, convert_to_human) - - -def _to_auto_dict(values, source='auto', convert_to_human=True): - ''' - some more complex patching for zfs.to_auto_dict - ''' - with patch.object(salt.utils.zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)), \ - patch.object(salt.utils.zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - return salt.utils.zfs.to_auto_dict(values, source, convert_to_human) - - -utils_patch = { - 'zfs.is_supported': MagicMock(return_value=True), - 'zfs.has_feature_flags': MagicMock(return_value=True), - 'zfs.property_data_zpool': MagicMock(return_value=pmap_zpool), - 'zfs.property_data_zfs': MagicMock(return_value=pmap_zfs), - # NOTE: we make zpool_command and zfs_command a NOOP - # these are extensively tested in tests.unit.utils.test_zfs - 'zfs.zpool_command': MagicMock(return_value='/bin/false'), - 'zfs.zfs_command': MagicMock(return_value='/bin/false'), - # NOTE: from_auto_dict is a special snowflake - # internally it calls multiple calls from - # salt.utils.zfs but we cannot patch those using - # the common methode, __utils__ is not available - # so they are direct calls, we do some voodoo here. - 'zfs.from_auto_dict': _from_auto_dict, - 'zfs.from_auto': _from_auto, - 'zfs.to_auto_dict': _to_auto_dict, - 'zfs.to_auto': _to_auto, -} - # Skip this test case if we don't have access to mock! @skipIf(NO_MOCK, NO_MOCK_REASON) @@ -890,7 +36,17 @@ class ZfsUtilsTestCase(TestCase): ''' This class contains a set of functions that test salt.utils.zfs utils ''' - ## NOTE: test parameter parsing + def setUp(self): + # property_map mocks + mock_data = ZFSMockData() + self.pmap_zfs = mock_data.pmap_zfs + self.pmap_zpool = mock_data.pmap_zpool + self.pmap_exec_zfs = mock_data.pmap_exec_zfs + self.pmap_exec_zpool = mock_data.pmap_exec_zpool + for name in ('pmap_zfs', 'pmap_zpool', 'pmap_exec_zfs', 'pmap_exec_zpool'): + self.addCleanup(delattr, self, name) + + # NOTE: test parameter parsing def test_is_supported(self): ''' Test zfs.is_supported method @@ -908,8 +64,8 @@ def test_property_data_zpool(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, '_exec', MagicMock(return_value=pmap_exec_zpool)): - self.assertEqual(zfs.property_data_zpool(), pmap_zpool) + with patch.object(zfs, '_exec', MagicMock(return_value=self.pmap_exec_zpool)): + self.assertEqual(zfs.property_data_zpool(), self.pmap_zpool) def test_property_data_zfs(self): ''' @@ -917,10 +73,10 @@ def test_property_data_zfs(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, '_exec', MagicMock(return_value=pmap_exec_zfs)): - self.assertEqual(zfs.property_data_zfs(), pmap_zfs) + with patch.object(zfs, '_exec', MagicMock(return_value=self.pmap_exec_zfs)): + self.assertEqual(zfs.property_data_zfs(), self.pmap_zfs) - ## NOTE: testing from_bool results + # NOTE: testing from_bool results def test_from_bool_on(self): ''' Test from_bool with 'on' @@ -977,7 +133,7 @@ def test_from_bool_alt_passthrough(self): self.assertEqual(zfs.from_bool_alt('passthrough'), 'passthrough') self.assertEqual(zfs.from_bool_alt(zfs.from_bool_alt('passthrough')), 'passthrough') - ## NOTE: testing to_bool results + # NOTE: testing to_bool results def test_to_bool_true(self): ''' Test to_bool with True @@ -1034,7 +190,7 @@ def test_to_bool_alt_passthrough(self): self.assertEqual(zfs.to_bool_alt('passthrough'), 'passthrough') self.assertEqual(zfs.to_bool_alt(zfs.to_bool_alt('passthrough')), 'passthrough') - ## NOTE: testing from_numeric results + # NOTE: testing from_numeric results def test_from_numeric_str(self): ''' Test from_numeric with '42' @@ -1063,7 +219,7 @@ def test_from_numeric_passthrough(self): self.assertEqual(zfs.from_numeric('passthrough'), 'passthrough') self.assertEqual(zfs.from_numeric(zfs.from_numeric('passthrough')), 'passthrough') - ## NOTE: testing to_numeric results + # NOTE: testing to_numeric results def test_to_numeric_str(self): ''' Test to_numeric with '42' @@ -1092,7 +248,7 @@ def test_to_numeric_passthrough(self): self.assertEqual(zfs.to_numeric('passthrough'), 'passthrough') self.assertEqual(zfs.to_numeric(zfs.to_numeric('passthrough')), 'passthrough') - ## NOTE: testing from_size results + # NOTE: testing from_size results def test_from_size_absolute(self): ''' Test from_size with '5G' @@ -1121,7 +277,7 @@ def test_from_size_passthrough(self): self.assertEqual(zfs.from_size('passthrough'), 'passthrough') self.assertEqual(zfs.from_size(zfs.from_size('passthrough')), 'passthrough') - ## NOTE: testing to_size results + # NOTE: testing to_size results def test_to_size_str_absolute(self): ''' Test to_size with '5368709120' @@ -1164,7 +320,7 @@ def test_to_size_passthrough(self): self.assertEqual(zfs.to_size('passthrough'), 'passthrough') self.assertEqual(zfs.to_size(zfs.to_size('passthrough')), 'passthrough') - ## NOTE: testing from_str results + # NOTE: testing from_str results def test_from_str_space(self): ''' Test from_str with "\"my pool/my dataset\" @@ -1200,12 +356,12 @@ def test_from_str_passthrough(self): self.assertEqual(zfs.from_str('passthrough'), 'passthrough') self.assertEqual(zfs.from_str(zfs.from_str('passthrough')), 'passthrough') - ## NOTE: testing to_str results + # NOTE: testing to_str results def test_to_str_space(self): ''' Test to_str with 'my pool/my dataset' ''' - ## NOTE: for fun we use both the '"str"' and "\"str\"" way of getting the literal string: "str" + # NOTE: for fun we use both the '"str"' and "\"str\"" way of getting the literal string: "str" self.assertEqual(zfs.to_str('my pool/my dataset'), '"my pool/my dataset"') self.assertEqual(zfs.to_str(zfs.to_str('my pool/my dataset')), "\"my pool/my dataset\"") @@ -1230,7 +386,7 @@ def test_to_str_passthrough(self): self.assertEqual(zfs.to_str('passthrough'), 'passthrough') self.assertEqual(zfs.to_str(zfs.to_str('passthrough')), 'passthrough') - ## NOTE: testing is_snapshot + # NOTE: testing is_snapshot def test_is_snapshot_snapshot(self): ''' Test is_snapshot with a valid snapshot name @@ -1249,7 +405,7 @@ def test_is_snapshot_filesystem(self): ''' self.assertFalse(zfs.is_snapshot('zpool_name/dataset')) - ## NOTE: testing is_bookmark + # NOTE: testing is_bookmark def test_is_bookmark_snapshot(self): ''' Test is_bookmark with a valid snapshot name @@ -1268,7 +424,7 @@ def test_is_bookmark_filesystem(self): ''' self.assertFalse(zfs.is_bookmark('zpool_name/dataset')) - ## NOTE: testing is_dataset + # NOTE: testing is_dataset def test_is_dataset_snapshot(self): ''' Test is_dataset with a valid snapshot name @@ -1287,15 +443,15 @@ def test_is_dataset_filesystem(self): ''' self.assertTrue(zfs.is_dataset('zpool_name/dataset')) - ## NOTE: testing zfs_command + # NOTE: testing zfs_command def test_zfs_command_simple(self): ''' Test if zfs_command builds the correct string ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zfs_command('list'), "/sbin/zfs list" @@ -1307,8 +463,8 @@ def test_zfs_command_none_target(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zfs_command('list', target=[None, 'mypool', None]), "/sbin/zfs list mypool" @@ -1320,8 +476,8 @@ def test_zfs_command_flag(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1336,8 +492,8 @@ def test_zfs_command_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-t': 'snap', # only list snapshots } @@ -1352,8 +508,8 @@ def test_zfs_command_flag_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1371,8 +527,8 @@ def test_zfs_command_target(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1390,8 +546,8 @@ def test_zfs_command_target_with_space(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1409,8 +565,8 @@ def test_zfs_command_property(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zfs_command('get', property_name='quota', target='mypool'), "/sbin/zfs get quota mypool" @@ -1422,8 +578,8 @@ def test_zfs_command_property_value(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-r', # recursive ] @@ -1438,8 +594,8 @@ def test_zfs_command_multi_property_value(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): property_name = ['quota', 'readonly'] property_value = ['5G', 'no'] self.assertEqual( @@ -1453,8 +609,8 @@ def test_zfs_command_fs_props(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-p', # create parent ] @@ -1473,8 +629,8 @@ def test_zfs_command_fs_props_with_space(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_props = { 'quota': '4.2M', 'compression': 'lz4', @@ -1484,15 +640,15 @@ def test_zfs_command_fs_props_with_space(self): '/sbin/zfs create -o compression=lz4 -o quota=4404019 "my pool/jorge\'s dataset"' ) - ## NOTE: testing zpool_command + # NOTE: testing zpool_command def test_zpool_command_simple(self): ''' Test if zfs_command builds the correct string ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zpool_command('list'), "/sbin/zpool list" @@ -1504,8 +660,8 @@ def test_zpool_command_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-o': 'name,size', # show only name and size } @@ -1520,8 +676,8 @@ def test_zpool_command_opt_list(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-d': ['/tmp', '/zvol'], } @@ -1536,8 +692,8 @@ def test_zpool_command_flag_opt(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-o': 'name,size', # show only name and size } @@ -1552,8 +708,8 @@ def test_zpool_command_target(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_opts = { '-o': 'name,size', # show only name and size } @@ -1568,8 +724,8 @@ def test_zpool_command_target_with_space(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): fs_props = { 'quota': '100G', } @@ -1587,8 +743,8 @@ def test_zpool_command_property(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): self.assertEqual( zfs.zpool_command('get', property_name='comment', target='mypool'), "/sbin/zpool get comment mypool" @@ -1600,8 +756,8 @@ def test_zpool_command_property_value(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): my_flags = [ '-v', # verbose ] @@ -1616,8 +772,8 @@ def test_parse_command_result_success(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 0 res['stderr'] = '' @@ -1633,8 +789,8 @@ def test_parse_command_result_success_nolabel(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 0 res['stderr'] = '' @@ -1650,8 +806,8 @@ def test_parse_command_result_fail(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = '' @@ -1667,8 +823,8 @@ def test_parse_command_result_nolabel(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = '' @@ -1684,8 +840,8 @@ def test_parse_command_result_fail_message(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = "\n".join([ @@ -1705,8 +861,8 @@ def test_parse_command_result_fail_message_nolabel(self): ''' with patch.object(zfs, '_zfs_cmd', MagicMock(return_value='/sbin/zfs')): with patch.object(zfs, '_zpool_cmd', MagicMock(return_value='/sbin/zpool')): - with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=pmap_zfs)): - with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=pmap_zpool)): + with patch.object(zfs, 'property_data_zfs', MagicMock(return_value=self.pmap_zfs)): + with patch.object(zfs, 'property_data_zpool', MagicMock(return_value=self.pmap_zpool)): res = {} res['retcode'] = 1 res['stderr'] = "\n".join([ @@ -1719,5 +875,3 @@ def test_parse_command_result_fail_message_nolabel(self): zfs.parse_command_result(res), OrderedDict([('error', 'ice is not hot')]), ) - -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4