|
12 | 12 | from sentry.conf.server import SENTRY_GROUPING_UPDATE_MIGRATION_PHASE
|
13 | 13 | from sentry.event_manager import _get_updated_group_title
|
14 | 14 | from sentry.eventtypes.base import DefaultEvent
|
| 15 | +from sentry.grouping.ingest.config import update_grouping_config_if_needed |
15 | 16 | from sentry.grouping.result import CalculatedHashes
|
16 | 17 | from sentry.models.auditlogentry import AuditLogEntry
|
17 | 18 | from sentry.models.group import Group
|
@@ -171,6 +172,37 @@ def test_auto_updates_grouping_config(self):
|
171 | 172 | )
|
172 | 173 | assert actual_expiry == expected_expiry or actual_expiry == expected_expiry - 1
|
173 | 174 |
|
| 175 | + def test_disabled_auto_update_does_not_update(self): |
| 176 | + self.project.update_option("sentry:grouping_config", LEGACY_CONFIG) |
| 177 | + |
| 178 | + with override_settings(SENTRY_GROUPING_AUTO_UPDATE_ENABLED=True): |
| 179 | + self.project.update_option("sentry:grouping_auto_update", False) |
| 180 | + save_new_event({"message": "foo"}, self.project) |
| 181 | + # It does not update the config because it is False |
| 182 | + assert self.project.get_option("sentry:grouping_config") == LEGACY_CONFIG |
| 183 | + |
| 184 | + def test_deprecated_configs_upgrade_automatically(self): |
| 185 | + # This is not yet a deprecated config but we will simulate it |
| 186 | + self.project.update_option("sentry:grouping_config", "mobile:2021-02-12") |
| 187 | + self.project.update_option("sentry:grouping_auto_update", False) |
| 188 | + |
| 189 | + with override_settings(SENTRY_GROUPING_AUTO_UPDATE_ENABLED=True): |
| 190 | + update_grouping_config_if_needed(self.project) |
| 191 | + # Nothing changes |
| 192 | + assert self.project.get_option("sentry:grouping_config") == "mobile:2021-02-12" |
| 193 | + assert self.project.get_option("sentry:grouping_auto_update") is False |
| 194 | + |
| 195 | + # XXX: In the future, once the mobile grouping is added to the list, we will remove this line |
| 196 | + with mock.patch( |
| 197 | + "sentry.grouping.ingest.config.CONFIGS_TO_DEPRECATE", |
| 198 | + new=["mobile:2021-02-12"], |
| 199 | + ): |
| 200 | + update_grouping_config_if_needed(self.project) |
| 201 | + # Even though auto update is disabled we have upgraded the project |
| 202 | + assert self.project.get_option("sentry:grouping_config") == DEFAULT_GROUPING_CONFIG |
| 203 | + # We have also updated the auto_update option |
| 204 | + assert self.project.get_option("sentry:grouping_auto_update") is True |
| 205 | + |
174 | 206 |
|
175 | 207 | class PlaceholderTitleTest(TestCase):
|
176 | 208 | """
|
|
0 commit comments