Skip to content

Commit

Permalink
Revert "add an admin only route for getting a tracemalloc (#3755)" (#…
Browse files Browse the repository at this point in the history
…3757)

This reverts commit 4a831d9.
  • Loading branch information
ewdurbin committed Apr 18, 2018
1 parent 4a831d9 commit 77ab8b1
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 36 deletions.
1 change: 0 additions & 1 deletion tests/unit/test_routes.py
Expand Up @@ -73,7 +73,6 @@ def add_policy(name, filename):

assert config.add_route.calls == [
pretend.call("health", "/_health/"),
pretend.call("memory", "/_memory/"),
pretend.call("force-status", "/_force-status/{status:[45]\d\d}/"),
pretend.call('index', '/', domain=warehouse),
pretend.call("robots.txt", "/robots.txt", domain=warehouse),
Expand Down
19 changes: 1 addition & 18 deletions tests/unit/test_views.py
Expand Up @@ -11,7 +11,6 @@
# limitations under the License.

import datetime
import tracemalloc

import pretend
import pytest
Expand All @@ -26,7 +25,7 @@
from warehouse.views import (
SEARCH_BOOSTS, SEARCH_FIELDS, current_user_indicator, forbidden, health,
httpexception_view, index, robotstxt, opensearchxml, search, force_status,
flash_messages, forbidden_include, memory
flash_messages, forbidden_include
)

from ..common.db.accounts import UserFactory
Expand Down Expand Up @@ -554,22 +553,6 @@ def test_health():
assert request.db.execute.calls == [pretend.call("SELECT 1")]


def test_memory(monkeypatch):
request = pretend.stub()
snapshot = pretend.stub(
statistics=pretend.call_recorder(
lambda x: ['a line', 'another line']
)
)
take_snapshot = pretend.call_recorder(
lambda: snapshot,
)
monkeypatch.setattr(tracemalloc, "take_snapshot", take_snapshot)
memory(request)
assert take_snapshot.calls == [pretend.call()]
assert snapshot.statistics.calls == [pretend.call('lineno')]


class TestForceStatus:

def test_valid(self):
Expand Down
1 change: 0 additions & 1 deletion warehouse/routes.py
Expand Up @@ -20,7 +20,6 @@ def includeme(config):

# Simple Route for health checks.
config.add_route("health", "/_health/")
config.add_route("memory", "/_memory/")

# Internal route to make it easier to force a particular status for
# debugging HTTPException templates.
Expand Down
13 changes: 0 additions & 13 deletions warehouse/views.py
Expand Up @@ -11,7 +11,6 @@
# limitations under the License.

import collections
import tracemalloc

from pyramid.httpexceptions import (
HTTPException, HTTPSeeOther, HTTPMovedPermanently, HTTPNotFound,
Expand Down Expand Up @@ -371,15 +370,3 @@ def force_status(request):
raise exception_response(int(request.matchdict["status"]))
except KeyError:
raise exception_response(404) from None


@view_config(
route_name="memory",
permission="admin",
uses_session=True,
renderer='string',
)
def memory(request):
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')
return '\n'.join(str(s) for s in top_stats[:20])
3 changes: 0 additions & 3 deletions warehouse/wsgi.py
Expand Up @@ -10,9 +10,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import tracemalloc

from warehouse.config import configure

tracemalloc.start()
application = configure().make_wsgi_app()

0 comments on commit 77ab8b1

Please sign in to comment.