Skip to content

Commit 2c107e3

Browse files
author
Manu Zope
committed
test(datasets): Make Sentry use generic test functions in Snuba
When we run tests in Sentry that hit Snuba, we insert records and delete the database at the end of every test run. We do this using the following test endpoints in Snuba: * `/tests/insert` * `/tests/eventstream` * `/tests/drop` These endpoints only worked for the `events` dataset. We want it to work for any dataset. So, getsentry/snuba#366 introduced 3 new test endpoints to Snuba with the goal of replacing the 3 endpoints mentioned earlier: * `/tests/<datastream>/insert` * `/tests/<datastream>/eventstream` * `/tests/<datastream>/drop` This PR makes Sentry use the new endpoints in Snuba. The next step is to remove the old non-generic endpoints from Snuba.
1 parent 9a3e5e3 commit 2c107e3

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/sentry/eventstream/snuba.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def _send(self, project_id, _type, extra_data=(), asynchronous=True):
249249

250250
try:
251251
resp = snuba._snuba_pool.urlopen(
252-
'POST', '/tests/eventstream',
252+
'POST', '/tests/events/eventstream',
253253
body=json.dumps(data),
254254
)
255255
if resp.status != 200:

src/sentry/testutils/cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ def setUp(self):
872872
def init_snuba(self):
873873
self.snuba_eventstream = SnubaEventStream()
874874
self.snuba_tagstore = SnubaCompatibilityTagStorage()
875-
assert requests.post(settings.SENTRY_SNUBA + '/tests/drop').status_code == 200
875+
assert requests.post(settings.SENTRY_SNUBA + '/tests/events/drop').status_code == 200
876876

877877
def store_event(self, *args, **kwargs):
878878
with contextlib.nested(
@@ -951,7 +951,7 @@ def snuba_insert(self, events):
951951
events = [events]
952952

953953
assert requests.post(
954-
settings.SENTRY_SNUBA + '/tests/insert',
954+
settings.SENTRY_SNUBA + '/tests/events/insert',
955955
data=json.dumps(events)
956956
).status_code == 200
957957

tests/snuba/tagstore/test_tagstore_backend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ def setUp(self):
101101
},
102102
}])
103103

104-
assert requests.post(settings.SENTRY_SNUBA + '/tests/insert', data=data).status_code == 200
104+
assert requests.post(
105+
settings.SENTRY_SNUBA +
106+
'/tests/events/insert',
107+
data=data).status_code == 200
105108

106109
def test_get_group_tag_keys_and_top_values(self):
107110
result = list(self.ts.get_group_tag_keys_and_top_values(

tests/snuba/tsdb/test_tsdb_backend.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ def setUp(self):
133133
},
134134
} for r in range(0, 14400, 600)]) # Every 10 min for 4 hours
135135

136-
assert requests.post(settings.SENTRY_SNUBA + '/tests/insert', data=data).status_code == 200
136+
assert requests.post(
137+
settings.SENTRY_SNUBA +
138+
'/tests/events/insert',
139+
data=data).status_code == 200
137140

138141
# snuba trims query windows based on first_seen/last_seen, so these need to be correct-ish
139142
self.proj1group1.first_seen = self.now

0 commit comments

Comments
 (0)