Cleanup eventlet use in tests

The tests in test_wsgi should stop the server once the test is over,
otherwise it would continue running and potentially affect other
tests.

Also, there were a couple of tests that did
environment.use_eventlet() in setUp, which has no effect since this
was already done in keystone.tests.core, and it's incorrect to put
this in a test setUp since it would affect other tests as it's an
application-wide library setting.

Closes-Bug: #1400565
Change-Id: Ibb00a1afa64cf46aaa0eafaca895bcf7a1f69eb0
This commit is contained in:
Brant Knudson 2014-12-10 14:58:12 -06:00
parent 71c9bf5fed
commit 20b272a7b4
2 changed files with 3 additions and 7 deletions

View File

@ -23,7 +23,6 @@ from testtools import matchers
from keystone import assignment
from keystone import auth
from keystone.common import authorization
from keystone.common import environment
from keystone import config
from keystone import exception
from keystone.models import token_model
@ -84,11 +83,6 @@ class AuthTest(tests.TestCase):
self.empty_context = {'environment': {}}
self.controller = token.controllers.Auth()
# This call sets up, among other things, the call to popen
# that will be used to run the CMS command. These tests were
# passing only due to the global nature of the call. If the
# tests in this file are run alone, API calls return unauthorized.
environment.use_eventlet(monkeypatch_thread=False)
def assertEqualTokens(self, a, b, enforce_audit_ids=True):
"""Assert that two tokens are equal.

View File

@ -374,7 +374,6 @@ class ServerTest(tests.TestCase):
def setUp(self):
super(ServerTest, self).setUp()
environment.use_eventlet()
self.host = '127.0.0.1'
self.port = '1234'
@ -387,6 +386,7 @@ class ServerTest(tests.TestCase):
server = environment.Server(mock.MagicMock(), host=self.host,
port=self.port)
server.start()
self.addCleanup(server.stop)
self.assertTrue(mock_listen.called)
self.assertFalse(mock_sock_dup.setsockopt.called)
@ -399,6 +399,7 @@ class ServerTest(tests.TestCase):
server = environment.Server(mock.MagicMock(), host=self.host,
port=self.port, keepalive=True)
server.start()
self.addCleanup(server.stop)
mock_sock_dup.setsockopt.assert_called_once_with(socket.SOL_SOCKET,
socket.SO_KEEPALIVE,
1)
@ -414,6 +415,7 @@ class ServerTest(tests.TestCase):
port=self.port, keepalive=True,
keepidle=1)
server.start()
self.addCleanup(server.stop)
self.assertEqual(mock_sock_dup.setsockopt.call_count, 2)