Browse Source

Change evacuate test hostnames to preferable ones

The hostname grammar in RFC952 does not allow for underscores in
hostnames. However, some evacuate tests use them in each hostname.
This patch changes them to hyphens instead.

Change-Id: Id961e74a0bbeefbc843678edd74c02466b6d6885
changes/08/59308/4
Ken'ichi Ohmichi 9 years ago
parent
commit
9888f61128
  1. 44
      nova/tests/api/openstack/compute/contrib/test_evacuate.py
  2. 33
      nova/tests/api/openstack/compute/plugins/v3/test_evacuate.py

44
nova/tests/api/openstack/compute/contrib/test_evacuate.py

@ -47,7 +47,7 @@ def fake_compute_api_get(self, context, instance_id):
def fake_service_get_by_compute_host(self, context, host):
if host == 'bad_host':
if host == 'bad-host':
raise exception.ComputeHostNotFound(host=host)
else:
return {
@ -80,7 +80,29 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'false',
'adminPass': 'MyNewPass'
}
})
req.content_type = 'application/json'
res = req.get_response(app)
self.assertEqual(res.status_int, 200)
def test_evacuate_with_underscore_in_hostname(self):
ctxt = context.get_admin_context()
ctxt.user_id = 'fake'
ctxt.project_id = 'fake'
ctxt.is_admin = True
app = fakes.wsgi_app(fake_auth_context=ctxt)
req = webob.Request.blank('/v2/fake/servers/%s/action' % self.UUID)
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
# NOTE: The hostname grammar in RFC952 does not allow for
# underscores in hostnames. However, we should test that it
# is supported because it sometimes occurs in real systems.
'host': 'underscore_hostname',
'onSharedStorage': 'false',
'adminPass': 'MyNewPass'
}
@ -99,7 +121,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'false',
'adminPass': 'MyNewPass'
}
@ -119,7 +141,7 @@ class EvacuateTest(test.NoDBTestCase):
req.content_type = 'application/json'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'false',
'adminPass': 'MyNewPass'
}
@ -161,7 +183,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'adminPass': 'MyNewPass'
}
})
@ -179,7 +201,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'bad_host',
'host': 'bad-host',
'onSharedStorage': 'false',
'adminPass': 'MyNewPass'
}
@ -199,7 +221,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'false',
'adminPass': 'MyNewPass'
}
@ -228,7 +250,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'True',
'adminPass': 'MyNewPass'
}
@ -255,7 +277,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'False',
}
})
@ -284,7 +306,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'True',
}
})
@ -307,7 +329,7 @@ class EvacuateTest(test.NoDBTestCase):
req.method = 'POST'
req.body = jsonutils.dumps({
'evacuate': {
'host': 'my_host',
'host': 'my-host',
'onSharedStorage': 'True',
}
})

33
nova/tests/api/openstack/compute/plugins/v3/test_evacuate.py

@ -43,7 +43,7 @@ def fake_compute_api_get(self, context, instance_id):
def fake_service_get_by_compute_host(self, context, host):
if host == 'bad_host':
if host == 'bad-host':
raise exception.ComputeHostNotFound(host=host)
else:
return {
@ -90,13 +90,13 @@ class EvacuateTest(test.NoDBTestCase):
self.assertEqual(res.status_int, 400)
def test_evacuate_instance_without_on_shared_storage(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'admin_password': 'MyNewPass'})
res = req.get_response(app)
self.assertEqual(res.status_int, 400)
def test_evacuate_instance_with_bad_host(self):
req, app = self._gen_request_with_app({'host': 'bad_host',
req, app = self._gen_request_with_app({'host': 'bad-host',
'on_shared_storage': 'False',
'admin_password': 'MyNewPass'})
@ -104,7 +104,22 @@ class EvacuateTest(test.NoDBTestCase):
self.assertEqual(res.status_int, 404)
def test_evacuate_instance_with_target(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'on_shared_storage': 'False',
'admin_password': 'MyNewPass'})
self.stubs.Set(compute_api.API, 'update', self._fake_update)
resp = req.get_response(app)
self.assertEqual(resp.status_int, 200)
resp_json = jsonutils.loads(resp.body)
self.assertEqual("MyNewPass", resp_json['admin_password'])
def test_evacuate_instance_with_underscore_in_hostname(self):
# NOTE: The hostname grammar in RFC952 does not allow for
# underscores in hostnames. However, we should test that it
# is supported because it sometimes occurs in real systems.
req, app = self._gen_request_with_app({'host': 'underscore_hostname',
'on_shared_storage': 'False',
'admin_password': 'MyNewPass'})
@ -116,7 +131,7 @@ class EvacuateTest(test.NoDBTestCase):
self.assertEqual("MyNewPass", resp_json['admin_password'])
def test_evacuate_shared_and_pass(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'on_shared_storage': 'True',
'admin_password': 'MyNewPass'})
self.stubs.Set(compute_api.API, 'update', self._fake_update)
@ -125,7 +140,7 @@ class EvacuateTest(test.NoDBTestCase):
self.assertEqual(res.status_int, 400)
def test_evacuate_not_shared_pass_generated(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'on_shared_storage': 'False'})
self.stubs.Set(compute_api.API, 'update', self._fake_update)
@ -137,7 +152,7 @@ class EvacuateTest(test.NoDBTestCase):
len(resp_json['admin_password']))
def test_evacuate_shared(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'on_shared_storage': 'True'})
self.stubs.Set(compute_api.API, 'update', self._fake_update)
@ -147,7 +162,7 @@ class EvacuateTest(test.NoDBTestCase):
self.assertIsNone(resp_json['admin_password'])
def test_evacuate_with_active_service(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'on_shared_storage': 'false',
'admin_password': 'MyNewPass'})
@ -160,7 +175,7 @@ class EvacuateTest(test.NoDBTestCase):
self.assertEqual(res.status_int, 400)
def test_not_admin(self):
req, app = self._gen_request_with_app({'host': 'my_host',
req, app = self._gen_request_with_app({'host': 'my-host',
'on_shared_storage': 'True'},
is_admin=False)

Loading…
Cancel
Save