Remove localhost references from tests

Using localhost in dummy URLs is a bad idea, because if you get
your mocking slightly wrong, some tests try to connect to the
services running in your local test environment.

Change-Id: I5550c397230f94740c63e6cab30ac35b3ae85297
This commit is contained in:
Steven Hardy 2013-08-30 11:12:24 +01:00
parent 566bc32217
commit 752da8e0c1
10 changed files with 27 additions and 27 deletions

View File

@ -108,7 +108,7 @@ class AutoScalingTest(HeatTestCase):
super(AutoScalingTest, self).setUp()
utils.setup_dummy_db()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
self.fc = fakes.FakeKeystoneClient()
def create_scaling_group(self, t, stack, resource_name):

View File

@ -93,7 +93,7 @@ class CeilometerAlarmTest(HeatTestCase):
generic_resource.SignalResource)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
self.fc = fakes.FakeKeystoneClient()
self.fa = FakeCeilometerClient()

View File

@ -110,7 +110,7 @@ class LoadBalancerTest(HeatTestCase):
username='test_stack.CfnLBUser')
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
utils.setup_dummy_db()
def create_loadbalancer(self, t, stack, resource_name):

View File

@ -196,7 +196,7 @@ class WaitCondMetadataUpdateTest(HeatTestCase):
self.fc = fakes.FakeKeystoneClient()
self.man = service.EngineService('a-host', 'a-topic')
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
# Note tests creating a stack should be decorated with @stack_delete_after
# to ensure the stack is properly cleaned up

View File

@ -89,8 +89,8 @@ class NovaUtilsTests(HeatTestCase):
self.m.StubOutWithMock(nova_utils.cfg, 'CONF')
cnf = nova_utils.cfg.CONF
cnf.instance_user = 'testuser'
cnf.heat_metadata_server_url = 'http://localhost:123'
cnf.heat_watch_server_url = 'http://localhost:345'
cnf.heat_metadata_server_url = 'http://_testnoexisthost_:123'
cnf.heat_watch_server_url = 'http://_testnoexisthost_:345'
cnf.instance_connection_is_secure = False
cnf.instance_connection_https_validate_certificates = False
self.m.ReplayAll()
@ -100,8 +100,8 @@ class NovaUtilsTests(HeatTestCase):
self.assertTrue("Content-Type: text/part-handler;" in data)
self.assertTrue("Content-Type: text/x-cfninitdata;" in data)
self.assertTrue("Content-Type: text/x-shellscript;" in data)
self.assertTrue("http://localhost:345" in data)
self.assertTrue("http://localhost:123" in data)
self.assertTrue("http://_testnoexisthost_:345" in data)
self.assertTrue("http://_testnoexisthost_:123" in data)
self.assertTrue("[Boto]" in data)
self.assertTrue('testuser' in data)
self.m.VerifyAll()

View File

@ -91,7 +91,7 @@ class s3Test(HeatTestCase):
'X-Container-Read': 'test_tenant:test_username'}
).AndReturn(None)
swiftclient.Connection.get_auth().MultipleTimes().AndReturn(
('http://localhost:8080/v_2', None))
('http://_testnoexisthost_:8080/v_2', None))
swiftclient.Connection.delete_container(container_name).AndReturn(None)
self.m.ReplayAll()
@ -102,8 +102,8 @@ class s3Test(HeatTestCase):
ref_id = rsrc.FnGetRefId()
self.assertEqual(container_name, ref_id)
self.assertEqual('localhost', rsrc.FnGetAtt('DomainName'))
url = 'http://localhost:8080/v_2/%s' % ref_id
self.assertEqual('_testnoexisthost_', rsrc.FnGetAtt('DomainName'))
url = 'http://_testnoexisthost_:8080/v_2/%s' % ref_id
self.assertEqual(url, rsrc.FnGetAtt('WebsiteURL'))

View File

@ -58,7 +58,7 @@ class SignalTest(HeatTestCase):
generic_resource.GenericResource)
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
self.stack_id = 'STACKABCD1234'
self.fc = fakes.FakeKeystoneClient()
@ -100,7 +100,7 @@ class SignalTest(HeatTestCase):
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
expected_url = "".join([
'http://127.0.0.1:8000/v1/signal/',
'http://_testnoexisthost_:8000/v1/signal/',
'arn%3Aopenstack%3Aheat%3A%3Atest_tenant%3Astacks%2F',
'test_stack%2FSTACKABCD1234%2Fresources%2F',
'signal_handler?',
@ -109,7 +109,7 @@ class SignalTest(HeatTestCase):
'AWSAccessKeyId=4567&',
'SignatureVersion=2&',
'Signature=',
'MJIFh7LKCpVlK6pCxe2WfYrRsfO7FU3Wt%2BzQFo2rYSY%3D'])
'dPUzYOioXbSUJjdl9C%2FXtw1VLfAnJf7uj69ZJ%2BiGNv0%3D'])
self.assertEqual(expected_url, rsrc.FnGetAtt('AlarmUrl'))
self.m.VerifyAll()

View File

@ -130,7 +130,7 @@ class swiftTest(HeatTestCase):
'X-Container-Read': None}
).AndReturn(None)
swiftclient.Connection.get_auth().MultipleTimes().AndReturn(
('http://localhost:8080/v_2', None))
('http://_testnoexisthost_:8080/v_2', None))
swiftclient.Connection.head_container(
mox.IgnoreArg()).MultipleTimes().AndReturn(headers)
swiftclient.Connection.delete_container(container_name).AndReturn(None)
@ -143,8 +143,8 @@ class swiftTest(HeatTestCase):
ref_id = rsrc.FnGetRefId()
self.assertEqual(container_name, ref_id)
self.assertEqual('localhost', rsrc.FnGetAtt('DomainName'))
url = 'http://localhost:8080/v_2/%s' % ref_id
self.assertEqual('_testnoexisthost_', rsrc.FnGetAtt('DomainName'))
url = 'http://_testnoexisthost_:8080/v_2/%s' % ref_id
self.assertEqual(url, rsrc.FnGetAtt('WebsiteURL'))
self.assertEqual('82', rsrc.FnGetAtt('ObjectCount'))

View File

@ -84,7 +84,7 @@ class WaitConditionTest(HeatTestCase):
'get_status')
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
self.fc = fakes.FakeKeystoneClient()
@ -278,7 +278,7 @@ class WaitConditionTest(HeatTestCase):
stack_id = 'STACK_HUBSID_1234'
t = json.loads(test_template_waitcondition)
badhandle = ("http://127.0.0.1:8000/v1/waitcondition/" +
badhandle = ("http://_testnoexisthost_:8000/v1/waitcondition/" +
"arn%3Aopenstack%3Aheat%3A%3Atest_tenant" +
"%3Astacks%2Ftest_stack%2F" +
"bad1" +
@ -299,7 +299,7 @@ class WaitConditionTest(HeatTestCase):
stack_id = 'STACKABCD1234'
t = json.loads(test_template_waitcondition)
badhandle = ("http://127.0.0.1:8000/v1/waitcondition/" +
badhandle = ("http://_testnoexisthost_:8000/v1/waitcondition/" +
"arn%3Aopenstack%3Aheat%3A%3Atest_tenant" +
"%3Astacks%2FBAD_stack%2F" +
stack_id + "%2Fresources%2FWaitHandle")
@ -318,7 +318,7 @@ class WaitConditionTest(HeatTestCase):
stack_id = 'STACKABCD1234'
t = json.loads(test_template_waitcondition)
badhandle = ("http://127.0.0.1:8000/v1/waitcondition/" +
badhandle = ("http://_testnoexisthost_:8000/v1/waitcondition/" +
"arn%3Aopenstack%3Aheat%3A%3ABAD_tenant" +
"%3Astacks%2Ftest_stack%2F" +
stack_id + "%2Fresources%2FWaitHandle")
@ -337,7 +337,7 @@ class WaitConditionTest(HeatTestCase):
stack_id = 'STACK_HUBR_1234'
t = json.loads(test_template_waitcondition)
badhandle = ("http://127.0.0.1:8000/v1/waitcondition/" +
badhandle = ("http://_testnoexisthost_:8000/v1/waitcondition/" +
"arn%3Aopenstack%3Aheat%3A%3Atest_tenant" +
"%3Astacks%2Ftest_stack%2F" +
stack_id + "%2Fresources%2FBADHandle")
@ -355,7 +355,7 @@ class WaitConditionTest(HeatTestCase):
self.m.ReplayAll()
stack_id = 'STACKABCD1234'
t = json.loads(test_template_waitcondition)
badhandle = ("http://127.0.0.1:8000/v1/waitcondition/" +
badhandle = ("http://_testnoexisthost_:8000/v1/waitcondition/" +
"arn%3Aopenstack%3Aheat%3A%3Atest_tenant" +
"%3Astacks%2Ftest_stack%2F" +
stack_id + "%2Fresources%2FWaitForTheHandle")
@ -373,7 +373,7 @@ class WaitConditionHandleTest(HeatTestCase):
def setUp(self):
super(WaitConditionHandleTest, self).setUp()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
'http://_testnoexisthost_:8000/v1/waitcondition')
self.fc = fakes.FakeKeystoneClient()
utils.setup_dummy_db()
@ -432,7 +432,7 @@ class WaitConditionHandleTest(HeatTestCase):
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
expected_url = "".join([
'http://127.0.0.1:8000/v1/waitcondition/',
'http://_testnoexisthost_:8000/v1/waitcondition/',
'arn%3Aopenstack%3Aheat%3A%3Atest_tenant%3Astacks%2F',
'test_stack2%2F', stack_id, '%2Fresources%2F',
'WaitHandle?',
@ -441,7 +441,7 @@ class WaitConditionHandleTest(HeatTestCase):
'AWSAccessKeyId=4567&',
'SignatureVersion=2&',
'Signature=',
'ePyTwmC%2F1kSigeo%2Fha7kP8Avvb45G9Y7WOQWe4F%2BnXM%3D'])
'dGH5JuZW9mOQ%2Fs3aun7vm5ATj0YemC7C8zCHOeG6Fbs%3D'])
self.assertEqual(unicode(expected_url), rsrc.FnGetRefId())

View File

@ -136,7 +136,7 @@ def dummy_context(user='test_username', tenant_id='test_tenant_id',
'username': user,
'password': password,
'roles': roles,
'auth_url': 'http://localhost:5000/v2.0',
'auth_url': 'http://_testnoexisthost_:5000/v2.0',
'auth_token': 'abcd1234'
})