Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Makes pulp_smash a pytest plugin #1262

Merged

Conversation

bmbouter
Copy link
Member

@bmbouter bmbouter commented Dec 7, 2021

This provides a common place for any pytest fixtures to be added.

@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from 19759b5 to 01c1ff4 Compare December 7, 2021 23:07
@bmbouter bmbouter marked this pull request as draft December 7, 2021 23:07
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 7, 2021


@pytest.fixture
def async_monitor_task(tasks_api_client):
Copy link
Member

Choose a reason for hiding this comment

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

I still fail to see the value in this being a "fixture".

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I'm not finished with this one yet. The issue I'm struggling with is that if this becomes a normal function then I can't access the chain of fixtures it depends on tasks_api_client -> pulpcore client fixtures. I'm going to look at this more today.

Copy link
Member

Choose a reason for hiding this comment

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

Oh right. There is a point.


@pytest.fixture
def tasks_api_client(pulpcore_client):
return TasksApi(pulpcore_client)
Copy link
Member

Choose a reason for hiding this comment

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

I pretty much like this. Can we mark it as scope="session"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was a very good idea.

@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch 2 times, most recently from d1ea780 to dee2a3c Compare December 8, 2021 20:25
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from dee2a3c to ea9039a Compare December 8, 2021 20:51
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch 2 times, most recently from 008569f to 6ce1ec5 Compare December 8, 2021 21:38
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 8, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from 6ce1ec5 to b516e90 Compare December 8, 2021 22:00
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 9, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 9, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 9, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 9, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 10, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from b516e90 to cd77852 Compare December 10, 2021 17:22
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 10, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 10, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from cd77852 to a0e2657 Compare December 10, 2021 17:40
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from bc72bbd to 87d4427 Compare December 15, 2021 19:56
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch 2 times, most recently from 48137c9 to 724376e Compare December 15, 2021 21:03
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from 724376e to 8faee76 Compare December 15, 2021 21:07
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 15, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 16, 2021
Comment on lines 143 to 151
@pytest.fixture
def delete_orphans_post():
yield
delete_orphans()


@pytest.fixture
def delete_orphans_pre_post(delete_orphans_pre, delete_orphans_post):
yield
Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of think we should delete these two, and have everyone use delete_orphans_pre. Doing it both before and after for each test is a lot and will slow us down. Additionally, I'm not even sure the post will free up actual orphans due to the run order. After the test finishes and it's tearing down all of the fixtures, if the delete_orphans_post runs before the deletion of the repository itself, it won't even free the orphans. Rather than worry about fixing that, let's just use delete_orphans_pre. @mdellweg wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

sounds good. We could depend other fixtures on this one to get the order right.
(cleanup is in reverse dependency order.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I made this change and the runtime dropped by a few more seconds for the 7 tests I've been running. It also removed one unecessary fixture in the other PR too.

@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from 8faee76 to 2234680 Compare December 16, 2021 16:18
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 16, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 16, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 16, 2021
bmbouter added a commit to bmbouter/pulpcore that referenced this pull request Dec 16, 2021
Copy link
Member

@mdellweg mdellweg left a comment

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 need the conftest.py in this repo. But probably does not hurt also.

pulp_smash/pulp3/pytest_plugin/__init__.py Show resolved Hide resolved
pulp_smash/pulp3/pytest_plugin/__init__.py Outdated Show resolved Hide resolved
pulp_smash/pulp3/pytest_plugin/__init__.py Show resolved Hide resolved
pulp_smash/pulp3/pytest_plugin/__init__.py Show resolved Hide resolved
pulp_smash/pulp3/pytest_plugin/__init__.py Show resolved Hide resolved


@pytest.fixture
def gen_object_with_cleanup():
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe gen_objects_with_cleanup_async_delete ?

Copy link
Member

Choose a reason for hiding this comment

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

I would do autodetection whether there is waiting on tasks needed.

@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from 2234680 to 2a157d2 Compare December 17, 2021 15:11
This provides a common place for any pytest fixtures to be added.
@bmbouter bmbouter force-pushed the add-pytest-plugin-with-aiohttp-fixutres branch from 2a157d2 to c797c74 Compare December 17, 2021 15:56
@bmbouter bmbouter merged commit 677f50e into pulp:main Dec 17, 2021
@bmbouter bmbouter deleted the add-pytest-plugin-with-aiohttp-fixutres branch December 17, 2021 16:57
bmbouter added a commit to pulp/pulpcore that referenced this pull request Dec 17, 2021
import socket
import ssl

from dataclasses import dataclass
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks compatibility with Python 3.6

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm, maybe I need to rework this so it doesn't break old release branches....

Copy link
Member Author

Choose a reason for hiding this comment

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

This got addressed a04c4ee

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.

None yet

4 participants