Skip to content

Enable use of the caplog fixture in pytest tests, and add a cc_final_message test using it#461

Merged
blackboxsw merged 5 commits into
canonical:masterfrom
OddBloke:cc_final_message
Jun 30, 2020
Merged

Enable use of the caplog fixture in pytest tests, and add a cc_final_message test using it#461
blackboxsw merged 5 commits into
canonical:masterfrom
OddBloke:cc_final_message

Conversation

@OddBloke
Copy link
Copy Markdown
Collaborator

caplog is only available in pytest itself from 3.0 onwards. In xenial, we only have pytest 2.8.7. However, in xenial we do have pytest-catchlog available (as python3-pytest-catchlog), so we use that where appropriate.

OddBloke added 4 commits June 26, 2020 12:28
This package provides the `caplog` fixture which was later merged into
pytest itself; from bionic onwards we can depend on its presence in the
pytest package itself.
And call `bddeb` appropriately in the Travis integration test.
@OddBloke
Copy link
Copy Markdown
Collaborator Author

This additional Build-Depends will require an update to the xenial daily branch for daily builds to continue working (which I will push up for review in a minute), and an update to the release branch when we next SRU. If we don't remember to make the change, the package build will fail, forcing us to fix it; I don't think we particularly need to track this elsewhere.

@OddBloke
Copy link
Copy Markdown
Collaborator Author

(which I will push up for review in a minute)

#462

Comment thread packages/bddeb
Comment on lines +94 to +95
if templ_data['debian_release'] == 'xenial':
requires.append('python3-pytest-catchlog')
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@smoser I don't know if you have a better idea of how to introduce a release-specific requirement. I looked at expanding read-dependencies to handle it, but it doesn't currently have any concept of release-specific requirements (and doesn't even take a release parameter).

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.

@OddBloke yeah I had thought initially of extending packages/pkg-deps.json (which ./tools/read-dependencies uses to differentiate pkgs per distro). We almost went down that route with a PR to support centos6 vs 7 pkg name differences (prior to us dropping py2 support).

As it is, we have a fractured set of dependency definitions:

  • tox.ini defined series-specific dependency diffs that are not reflected in test-requirements.txt,
  • .travis.yml uses apt-get build-dep to get package deps.
  • make ci-deps-ubuntu uses ./tools/read-dependencies directly, which means it will have no visibility to this xenial-specific requirement,

It'd be nice to put that release param into read-dependencies explicitly and let it source both test-requirements.txt and and specialized test-requirements-xenial.txt file if present. Then tox could call out that specific dependency in a separate file and read-dependencies could also source it if provided with a --release param.

I realize this may be more work than it's worth for this effort (and single use case). So I'm happy to be "talked off the ledge"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@OddBloke yeah I had thought initially of extending packages/pkg-deps.json (which ./tools/read-dependencies uses to differentiate pkgs per distro). We almost went down that route with a PR to support centos6 vs 7 pkg name differences (prior to us dropping py2 support).

As it is, we have a fractured set of dependency definitions:

* tox.ini defined series-specific dependency diffs that are not reflected in test-requirements.txt,
* .travis.yml uses `apt-get build-dep` to get package deps.

This is no longer the case as of 2be1223.

* make ci-deps-ubuntu uses ./tools/read-dependencies directly, which means it will have no visibility to this xenial-specific requirement,

Does anything use this? The only references to it I can find are its definition in the Makefile, and a Changelog entry.

It'd be nice to put that release param into read-dependencies explicitly and let it source both test-requirements.txt and and specialized test-requirements-xenial.txt file if present. Then tox could call out that specific dependency in a separate file and read-dependencies could also source it if provided with a --release param.

Agreed that we could certainly improve this.

I realize this may be more work than it's worth for this effort (and single use case). So I'm happy to be "talked off the ledge"

Yeah, given we only have a single motivating example currently makes this feel like more work than is justified: bear in mind that we will never add new Depends in already-released Ubuntu versions, so the only time we would see another case like this is (a) if we introduce a new build dependency, and (b) that build dependency is either named differently or absent in a target Ubuntu release. So this feels like a YAGNI situation, to me.

What do you think?

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.

  • make ci-deps-ubuntu: is probably something that only I use, I can't find it in any qa-scripts or server-jenkins-logs. We might as well drop it (separate PR)
  • As for improving test-requirements.txt to add seperate test-requirements-xenial.txt we can chat about that as a separate PR idea as well. I don't feel this case is strong enough to warrant it on this PR

I think you are right that this may be over-engineering by trying to extend read-dependencies to handle this single case.
We can revisit one we have one or two other use-cases which would require that change.

Copy link
Copy Markdown
Contributor

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

Nice find of python3-pytest-catchlog

@blackboxsw blackboxsw self-assigned this Jun 29, 2020
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.

Thanks for the discussion and responses. My review comments were not blocking.

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