Skip to content

Remove 3.5 and xenial support (SC-711)#1167

Merged
blackboxsw merged 3 commits into
canonical:mainfrom
TheRealFalcon:remove-3.5
Jan 10, 2022
Merged

Remove 3.5 and xenial support (SC-711)#1167
blackboxsw merged 3 commits into
canonical:mainfrom
TheRealFalcon:remove-3.5

Conversation

@TheRealFalcon
Copy link
Copy Markdown
Contributor

@TheRealFalcon TheRealFalcon commented Jan 6, 2022

Proposed Commit Message

Remove 3.5 and xenial support

Includes:
 - Update tox.ini and .travis.yml accordingly
 - Cleanup tox.ini with new tox syntax and cloud-init dependencies
 - Update documentation accordingly
 - Replace/remove xenial references where additional testing isn't required
 - Remove xenial checks in integration tests
 - Replace yield_fixture with fixture in pytest tests

Sections of code commented with lines like "Remove when Xenial is no
longer supported" still exist as they'll require additional testing.

Additional Context

I created a separate ticket for dealing with code that would need additional testing.

Test Steps

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

@TheRealFalcon TheRealFalcon added the wip Work in progress, do not land label Jan 6, 2022
@TheRealFalcon TheRealFalcon changed the title WIP: Remove 3.5 and xenial support WIP: Remove 3.5 and xenial support (SC-711) Jan 6, 2022
should be placed before the value under test:
``assert expected_value == function_under_test()``


Copy link
Copy Markdown
Contributor Author

@TheRealFalcon TheRealFalcon Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I snuck this removal in here as I was modifying this file as this rule seems arbitrarily restrictive and one I purposely ignore all the time 🙂

If anybody disagrees, I can put it back in.

@TheRealFalcon TheRealFalcon changed the title WIP: Remove 3.5 and xenial support (SC-711) Remove 3.5 and xenial support (SC-711) Jan 6, 2022
@TheRealFalcon TheRealFalcon removed the wip Work in progress, do not land label Jan 6, 2022
Comment thread doc/rtd/topics/testing.rst Outdated
reproduced by running::

py.test-3 --fixtures -q | grep "^[^ -]" | grep -v '\(no\|capturelog\)' | sort | sed 's/.*/* ``\0``/'
python3 -m pytest --fixtures -q | grep "^[^ -]" | grep -v '\(no\|capturelog\)' | sort | sed 's/.*/* ``\0``/'
Copy link
Copy Markdown
Member

@holmanb holmanb Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments on this one-liner:

Presumably the "no" is to remove no tests ran in 0.00s, but this filters out no_cover on more recent pytest versions - future-proof with longer match string.

"capturelog" doesn't filter anything on pytest 6.2.5, I assume this is something old that isn't needed?

It looks like " [session scope]" is being manually removed after running the command. This can be updated with a small updated to the sed command.

Assuming others agree with the above comments, this is what I propose:

python3 -m pytest  --fixtures -q | grep "^[^ -]" | grep -v 'no tests ran in' | sort | sed 's/ \[session scope\]//g;s/.*/* ``\0``/g'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, thanks!

Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Related: We still have a couple of comments saying "todo: remove when 2.7 is no longer supported" in the codebase. When we get around to removing 3.5-specific code, we may want to keep those in mind as well :)

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @TheRealFalcon this looks really good, only comments I have are some of the tox refactors as I think we need to be able to support running these targets on Bionic, Focal and Impish. I think we still need a dev target that pins a different httpretty that the straight lowest-supported testenv. Also we need to make sure tox -e lowest-supported works on Bionic directly right?

Here's a diff of what I think works for my inline comments:

diff --git a/tox.ini b/tox.ini
index d57111331..1a6a441d2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py3, lowest-supported, flake8, pylint, black, isort
+envlist = py3, lowest-supported-dev, flake8, pylint, black, isort
 recreate = True
 
 [testenv]
@@ -54,7 +54,7 @@ commands = {envpython} -m pytest \
             {posargs:--cov=cloudinit --cov-branch \
             tests/unittests}
 
-[testenv:lowest-supported]
+[lowest-supported-deps]
 # Tox is going to install requirements from pip. This is fine for
 # testing python version compatibility, but when we build cloud-init, we are
 # building against the dependencies in the OS repo, not pip. The OS
@@ -73,11 +73,26 @@ deps =
     jsonschema==2.6.0
     netifaces==0.10.4
     # test-requirements
-    httpretty==0.8.14
     pytest==3.3.2
     pytest-cov==2.5.1
-    attrs==17.4.0  # Needed by pytest and default causes failures
+    # attrs==17.4.0  # Needed by pytest and default causes failures
+    attrs=17.4.0
+
+[testenv:lowest-supported]
 commands = {[testenv:py3]commands}
+deps =
+    {[lowest-supported-deps]deps}
+    # Official lowest-supported deps released in bionic-updates
+    httpretty==0.8.14
+
+[testenv:lowest-supported-dev]
+commands = {[testenv:py3]commands}
+deps =
+    {[lowest-supported-deps]deps}
+    # httpretty in bionic is 0.8.14, not 0.9.5.  The oldest version to work with
+    # Python 3.7+ is 0.9.5, because it is the first to include this commit:
+    # https://github.com/gabrielfalcao/HTTPretty/commit/5776d97da3992b9071db5e21faf175f6e8729060
+    httpretty==0.9.5
 
 [testenv:doc]
 deps =

Comment thread tox.ini Outdated
[testenv:py27]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
[testenv:lowest-supported]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can do away with a shared lowest-supported-deps definition just yet.
Since lowest-supported is included in our default envlist it'll be run automatically in developer environments via tox -p auto. Without continuing to "pin" httpretty=0.9.5 in a lowest-supported-dev target we'll fail to pass locally on focal, hirsute and I think impish too.

It'd like to ensure developers can run this build env to avoid getting a suprirse if CI runs it and fails. What do you think?

Comment thread tox.ini Outdated
httpretty==0.8.14
pytest==3.3.2
pytest-cov==2.5.1
attrs==17.4.0 # Needed by pytest and default causes failures
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline comments still break on bionic tox. This comment needs to be a separate line otherwise we'll hit something like:

ERROR: Invalid requirement: 'attrs==17.4.0 #  Needed by pytest and default causes failures'

@blackboxsw
Copy link
Copy Markdown
Collaborator

Note I discovered a potentially related set of failures with running tox -e py3 tests/unittests/test_ds_identify.py on Bionic. Seems we have a test leaking into the underlying filesystem and getting back unexpected data:
http://paste.ubuntu.com/p/MM2XjX7by5/

Includes:
 - Update tox.ini and .travis.yml accordingly
 - Cleanup tox.ini with new tox syntax and cloud-init dependencies
 - Update documentation accordingly
 - Replace/remove xenial references where additional testing isn't required
 - Remove xenial checks in integration tests
 - Replace yield_fixture with fixture in pytest tests

Sections of code commented with lines like "Remove when Xenial is no
longer supported" still exist as they're require additional testing.
@TheRealFalcon
Copy link
Copy Markdown
Contributor Author

Really good comments @blackboxsw , thanks. I never knew why we had so many xenial definitions in our tox definition, and now I do 😄 .

Updated based on comments.

@blackboxsw
Copy link
Copy Markdown
Collaborator

Note I discovered a potentially related set of failures with running tox -e py3 tests/unittests/test_ds_identify.py on Bionic. Seems we have a test leaking into the underlying filesystem and getting back unexpected data: http://paste.ubuntu.com/p/MM2XjX7by5/

Put up the related PR to avoid leaks detecting a valid LXD datasource in test_ds_identify. #1178

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1! Bring it home! Bye bye xenial.

@blackboxsw blackboxsw merged commit dc1aabf into canonical:main Jan 10, 2022
@TheRealFalcon TheRealFalcon deleted the remove-3.5 branch January 10, 2022 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants