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

chore: make reset_gitlab() better #1785

Merged
merged 1 commit into from
Jul 22, 2022
Merged

chore: make reset_gitlab() better #1785

merged 1 commit into from
Jul 22, 2022

Conversation

JohnVillalovos
Copy link
Member

@JohnVillalovos JohnVillalovos commented Dec 29, 2021

Saw issues in the CI where reset_gitlab() would fail. It would fail to
delete the group that is created when GitLab starts up. Extending the
timeout didn't fix the issue.

Changed the code to use the new helpers.safe_delete() function.
Which will delete the resource and then make sure it is deleted before
returning.

Also added some logging functionality that can be seen if logging is
turned on in pytest.

@JohnVillalovos JohnVillalovos marked this pull request as draft December 29, 2021 05:42
@JohnVillalovos JohnVillalovos changed the title wip: make reset_gitlab() better chore: make reset_gitlab() better Dec 29, 2021
@JohnVillalovos JohnVillalovos marked this pull request as ready for review December 29, 2021 08:06
@JohnVillalovos
Copy link
Member Author

JohnVillalovos commented Dec 29, 2021

@nejch Please look at the functional testing logs and let me know what you think.

@JohnVillalovos
Copy link
Member Author

JohnVillalovos commented Dec 29, 2021

An example of what this is fixing from https://github.com/python-gitlab/python-gitlab/runs/4656774636?check_suite_focus=true#step:5:27

tests/functional/api/test_clusters.py::test_project_clusters 
-------------------------------- live log setup --------------------------------
2021-12-29 08:13:06.617 [    INFO] (conftest.py:gl:L258) Create python-gitlab gitlab.Gitlab object
2021-12-29 08:13:07.660 [    INFO] (conftest.py:_reset_gitlab_delete_resources:L35) Mark for deletion project: 'Monitoring'
2021-12-29 08:13:08.277 [    INFO] (conftest.py:_reset_gitlab_delete_resources:L44) Mark for deletion group: 'GitLab Instance'
2021-12-29 08:13:08.684 [    INFO] (conftest.py:wait_for_maximum_list_length:L83) Iteration: 0: items in projects: []
2021-12-29 08:13:08.954 [    INFO] (conftest.py:wait_for_maximum_list_length:L83) Iteration: 0: items in groups: ['GitLab Instance']

# NOTE(jlvillal): Deleting again and no message about already marked for deletion, so this is a fix.
2021-12-29 08:13:08.955 [    INFO] (conftest.py:wait_for_maximum_list_length:L88) Marking again for deletion groups: 'GitLab Instance'
2021-12-29 08:13:09.142 [    INFO] (conftest.py:wait_for_maximum_list_length:L83) Iteration: 1: items in groups: ['GitLab Instance']

# NOTE(jlvillal): 2nd time through, deleting again but this time indicates already marked for deletion.
2021-12-29 08:13:09.143 [    INFO] (conftest.py:wait_for_maximum_list_length:L88) Marking again for deletion groups: 'GitLab Instance'
2021-12-29 08:13:09.177 [    INFO] (conftest.py:wait_for_maximum_list_length:L94) Already marked for deletion: 'GitLab Instance' 404: 404 Group Not Found

# NOTE(jlvillal): 3rd time through and group is now gone.
2021-12-29 08:13:09.308 [    INFO] (conftest.py:wait_for_maximum_list_length:L83) Iteration: 2: items in groups: []
2021-12-29 08:13:09.359 [    INFO] (conftest.py:wait_for_maximum_list_length:L83) Iteration: 0: items in variables: []
2021-12-29 08:13:09.525 [    INFO] (conftest.py:wait_for_maximum_list_length:L83) Iteration: 0: items in users: ['Administrator']

Saw issues in the CI where reset_gitlab() would fail. It would fail to
delete the group that is created when GitLab starts up. Extending the
timeout didn't fix the issue.

Changed the code to use the new `helpers.safe_delete()` function.
Which will delete the resource and then make sure it is deleted before
returning.

Also added some logging functionality that can be seen if logging is
turned on in pytest.
@JohnVillalovos
Copy link
Member Author

@nejch By using safe_delete() it simplified things 🙂

@nejch
Copy link
Member

nejch commented Jul 22, 2022

@nejch By using safe_delete() it simplified things slightly_smiling_face

Amazing, love to see code get deleted 😅

@nejch nejch merged commit 789ef81 into main Jul 22, 2022
@nejch nejch deleted the jlvillal/reset_gitlab branch July 22, 2022 19:56
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

2 participants