From d8831aaa513d4380212d91dac5bf6061ac5287fa Mon Sep 17 00:00:00 2001 From: Manu Zope Date: Thu, 18 Jul 2019 11:56:37 -0700 Subject: [PATCH] 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, https://github.com/getsentry/snuba/pull/366 introduced 3 new test endpoints to Snuba with the goal of replacing the 3 endpoints mentioned earlier: * `/tests//insert` * `/tests//eventstream` * `/tests//drop` This PR makes Sentry use the new endpoints in Snuba. The next step is to remove the old non-generic endpoints from Snuba. --- src/sentry/eventstream/snuba.py | 2 +- src/sentry/testutils/cases.py | 4 ++-- tests/snuba/tagstore/test_tagstore_backend.py | 5 ++++- tests/snuba/tsdb/test_tsdb_backend.py | 5 ++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/sentry/eventstream/snuba.py b/src/sentry/eventstream/snuba.py index f7661a5b566007..9046c2c65ec52b 100644 --- a/src/sentry/eventstream/snuba.py +++ b/src/sentry/eventstream/snuba.py @@ -249,7 +249,7 @@ def _send(self, project_id, _type, extra_data=(), asynchronous=True): try: resp = snuba._snuba_pool.urlopen( - 'POST', '/tests/eventstream', + 'POST', '/tests/events/eventstream', body=json.dumps(data), ) if resp.status != 200: diff --git a/src/sentry/testutils/cases.py b/src/sentry/testutils/cases.py index b5defbb91434fd..98c9575ad93f19 100644 --- a/src/sentry/testutils/cases.py +++ b/src/sentry/testutils/cases.py @@ -872,7 +872,7 @@ def setUp(self): def init_snuba(self): self.snuba_eventstream = SnubaEventStream() self.snuba_tagstore = SnubaCompatibilityTagStorage() - assert requests.post(settings.SENTRY_SNUBA + '/tests/drop').status_code == 200 + assert requests.post(settings.SENTRY_SNUBA + '/tests/events/drop').status_code == 200 def store_event(self, *args, **kwargs): with contextlib.nested( @@ -951,7 +951,7 @@ def snuba_insert(self, events): events = [events] assert requests.post( - settings.SENTRY_SNUBA + '/tests/insert', + settings.SENTRY_SNUBA + '/tests/events/insert', data=json.dumps(events) ).status_code == 200 diff --git a/tests/snuba/tagstore/test_tagstore_backend.py b/tests/snuba/tagstore/test_tagstore_backend.py index 163a4aa74c6823..d01ffddd313d52 100644 --- a/tests/snuba/tagstore/test_tagstore_backend.py +++ b/tests/snuba/tagstore/test_tagstore_backend.py @@ -101,7 +101,10 @@ def setUp(self): }, }]) - assert requests.post(settings.SENTRY_SNUBA + '/tests/insert', data=data).status_code == 200 + assert requests.post( + settings.SENTRY_SNUBA + + '/tests/events/insert', + data=data).status_code == 200 def test_get_group_tag_keys_and_top_values(self): result = list(self.ts.get_group_tag_keys_and_top_values( diff --git a/tests/snuba/tsdb/test_tsdb_backend.py b/tests/snuba/tsdb/test_tsdb_backend.py index dc512440de4b6b..d3900dcad72ac7 100644 --- a/tests/snuba/tsdb/test_tsdb_backend.py +++ b/tests/snuba/tsdb/test_tsdb_backend.py @@ -133,7 +133,10 @@ def setUp(self): }, } for r in range(0, 14400, 600)]) # Every 10 min for 4 hours - assert requests.post(settings.SENTRY_SNUBA + '/tests/insert', data=data).status_code == 200 + assert requests.post( + settings.SENTRY_SNUBA + + '/tests/events/insert', + data=data).status_code == 200 # snuba trims query windows based on first_seen/last_seen, so these need to be correct-ish self.proj1group1.first_seen = self.now