cleanup servers, api tokens after spawner shutdown

prevents growing table of unused servers and tokens
This commit is contained in:
Min RK
2016-07-08 16:50:43 +02:00
parent 4801d647c1
commit 2eaecd22ba
2 changed files with 16 additions and 0 deletions

View File

@@ -347,6 +347,7 @@ def test_spawn(app, io_loop):
's': ['value'],
'i': 5,
}
before_servers = sorted(db.query(orm.Server), key=lambda s: s.url)
r = api_request(app, 'users', name, 'server', method='post', data=json.dumps(options))
assert r.status_code == 201
assert 'pid' in user.state
@@ -379,6 +380,13 @@ def test_spawn(app, io_loop):
status = io_loop.run_sync(app_user.spawner.poll)
assert status == 0
# check that we cleaned up after ourselves
assert user.server is None
after_servers = sorted(db.query(orm.Server), key=lambda s: s.url)
assert before_servers == after_servers
tokens = list(db.query(orm.APIToken).filter(orm.APIToken.user_id==user.id))
assert tokens == []
def test_slow_spawn(app, io_loop):
# app.tornado_application.settings['spawner_class'] = mocking.SlowSpawner