-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
test(event_manager): Test case #74526
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b33c2b1
test(event_manager): Test case
armenzg 32d8f62
Touch ups
armenzg d13307a
Few more test changes
armenzg acb7197
Force failure
armenzg fe99599
Update tests/sentry/event_manager/test_event_manager.py
armenzg 8356c23
Typing
armenzg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -564,6 +564,84 @@ def test_resolved_in_release_regression_activity_follows_semver( | |
assert regressed_activity.data["follows_semver"] is True | ||
assert regressed_activity.data["resolved_in_version"] == "foo@1.0.0" | ||
|
||
def resolve_in_release(self, group: Group, release: Release) -> Activity: | ||
group.update(status=GroupStatus.RESOLVED, substatus=None) | ||
resolution = GroupResolution.objects.create( | ||
release=release, | ||
group=group, | ||
type=GroupResolution.Type.in_release, | ||
) | ||
return Activity.objects.create( | ||
group=group, | ||
project=group.project, | ||
type=ActivityType.SET_RESOLVED_IN_RELEASE.value, | ||
ident=resolution.id, | ||
data={"version": release.version}, | ||
) | ||
|
||
@mock.patch("sentry.event_manager.plugin_is_regression") | ||
def test_does_not_resolve_for_semver(self, plugin_is_regression: mock.MagicMock) -> None: | ||
plugin_is_regression.return_value = True | ||
|
||
def _date(minutes: int) -> datetime: | ||
return timezone.now() - timedelta(minutes=minutes) | ||
|
||
first_release_version = "com.foo.FooTest@387.0+387.0.18" | ||
first_release = self.create_release(version=first_release_version, date_added=_date(90)) | ||
|
||
manager = EventManager( | ||
make_event( | ||
event_id="a" * 32, | ||
checksum="a" * 32, | ||
# 10 minutes after release creation | ||
timestamp=time() - 80 * 60, | ||
release=first_release.version, | ||
) | ||
) | ||
event = manager.save(self.project.id) | ||
assert event.group is not None | ||
group = event.group | ||
|
||
patch_version6 = "com.foo.FooTest@388.0+388.0.6" | ||
release_06 = self.create_release(version=patch_version6, date_added=_date(70)) | ||
|
||
patch_version8 = "com.foo.Foo@388.0+388.0.8" | ||
release_08 = self.create_release(version=patch_version8, date_added=_date(65)) | ||
|
||
self.create_release(version="com.foo.Foo@388.0+388.0.13", date_added=_date(60)) | ||
|
||
# Marking as resolved in the second latest release | ||
self.resolve_in_release(group, release_08) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the releases above already exist once the developer calls "resolve in release X". |
||
|
||
# Creates event for an older release | ||
manager = EventManager( | ||
make_event( | ||
event_id="c" * 32, | ||
checksum="a" * 32, | ||
timestamp=time(), | ||
# Notice that the event is for an older release | ||
release=release_06.version, | ||
) | ||
) | ||
event = manager.save(self.project.id) | ||
assert event.group is not None | ||
group = event.group | ||
|
||
# # XXX: The GH issue shows that it should have unresolved | ||
# assert group.status == GroupStatus.RESOLVED | ||
# # XXX: The GH issue shows that it should have a regression | ||
# with pytest.raises(Activity.DoesNotExist): | ||
# Activity.objects.get(group=group, type=ActivityType.SET_REGRESSION.value) | ||
|
||
# When GroupResolution.has_resolution(group, release) does not execute we reproduce the issue | ||
assert group.status == GroupStatus.UNRESOLVED | ||
regressed_activity = Activity.objects.get( | ||
group=group, type=ActivityType.SET_REGRESSION.value | ||
) | ||
assert regressed_activity.data["version"] == release_06.version | ||
assert regressed_activity.data["follows_semver"] is True | ||
assert regressed_activity.data["resolved_in_version"] == release_08.version | ||
|
||
def test_has_pending_commit_resolution(self) -> None: | ||
project_id = self.project.id | ||
event = self.make_release_event("1.0", project_id) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm forcing the issue to happen.
In my test case, we end up reaching this comparison:
sentry/src/sentry/models/groupresolution.py
Lines 156 to 172 in 159d52c