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

add clean_up method for store_test_failures tests to stop hanging art… #803

Merged
merged 6 commits into from
Jul 7, 2023

Conversation

McKnight-42
Copy link
Contributor

@McKnight-42 McKnight-42 commented Jun 29, 2023

…ifacts in bigquery

resolves # hanging artifacts left during test runs due to change in schema name not caught by default teardown method

Description

would look to what branches we need to backport

Checklist

@McKnight-42 McKnight-42 added the Skip Changelog Skips GHA to check for changelog file label Jun 29, 2023
@McKnight-42 McKnight-42 self-assigned this Jun 29, 2023
@McKnight-42 McKnight-42 requested a review from a team as a code owner June 29, 2023 21:32
@cla-bot cla-bot bot added the cla:yes label Jun 29, 2023
class TestBigQueryStoreTestFailures(StoreTestFailuresBase):
def test_store_and_assert(self, project):
@pytest.fixture(scope="function")
def clean_up(self, project):
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a teardown method. In my experience, such a method tends to get called teardown_method ("method" not because this is a method, but because the scope is "function") and runs automatically.

With that in mind, would you mind if we rename it, add autouse=True in the fixture decorator, and remove clean_up from the signature of test_store_and_assert? It would all behave the same (unless StoreTestFailuresBase has additional tests), but it would follow conventions that I've seen.

Copy link
Contributor Author

@McKnight-42 McKnight-42 Jul 6, 2023

Choose a reason for hiding this comment

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

I think we historically in other tests call this teardown method clean_up as it differs from the default one all functional tests run that only drop a default schema name. if we'd like to pivot to calling these make sure all schemas are dropped methods to teardown might be a little project across all adapters and core. would just have to make sure we don't cause issue with normal run (can look into it as part of support rotation).

I can retest the autouse=True field but if I recall that for some reason didn't work when I was testing this initially we have other examples of it being a function scope and passed into the tests to trigger.

class TestBigQueryStoreTestFailures(StoreTestFailuresBase):
@pytest.fixture(autouse=True)
def teardown_method(self, project):
Copy link
Contributor Author

@McKnight-42 McKnight-42 Jul 6, 2023

Choose a reason for hiding this comment

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

Should this be something we go change in all tests that have a clean_up method instead?

Copy link
Contributor

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 to actively change it, but if we're adding new items or updating something, then I'd change it as part of that. Also, you still need scope="function", so it would be @pytest.fixture(scope="function", autouse=True)

@McKnight-42 McKnight-42 merged commit 2fb5681 into main Jul 7, 2023
@McKnight-42 McKnight-42 deleted the mcknight/fix-test-store-test branch July 7, 2023 05:43
@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

The backport to 1.5.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.5.latest 1.5.latest
# Navigate to the new working tree
cd .worktrees/backport-1.5.latest
# Create a new branch
git switch --create backport-803-to-1.5.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 2fb56817037ef3f4ad8723765ed2db862edfb897
# Push it to GitHub
git push --set-upstream origin backport-803-to-1.5.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.5.latest

Then, create a pull request where the base branch is 1.5.latest and the compare/head branch is backport-803-to-1.5.latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants