From 752da8e0c1b22709fcbbbe906efb48dbf2217510 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Fri, 30 Aug 2013 11:12:24 +0100 Subject: [PATCH] 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 --- heat/tests/test_autoscaling.py | 2 +- heat/tests/test_ceilometer_alarm.py | 2 +- heat/tests/test_loadbalancer.py | 2 +- heat/tests/test_metadata_refresh.py | 2 +- heat/tests/test_nova_utils.py | 8 ++++---- heat/tests/test_s3.py | 6 +++--- heat/tests/test_signal.py | 6 +++--- heat/tests/test_swift.py | 6 +++--- heat/tests/test_waitcondition.py | 18 +++++++++--------- heat/tests/utils.py | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index b9b2e745..caaa393a 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -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): diff --git a/heat/tests/test_ceilometer_alarm.py b/heat/tests/test_ceilometer_alarm.py index 9261720a..84522a1a 100644 --- a/heat/tests/test_ceilometer_alarm.py +++ b/heat/tests/test_ceilometer_alarm.py @@ -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() diff --git a/heat/tests/test_loadbalancer.py b/heat/tests/test_loadbalancer.py index fdd8232c..528729c4 100644 --- a/heat/tests/test_loadbalancer.py +++ b/heat/tests/test_loadbalancer.py @@ -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): diff --git a/heat/tests/test_metadata_refresh.py b/heat/tests/test_metadata_refresh.py index 4ab21398..a3f0598a 100644 --- a/heat/tests/test_metadata_refresh.py +++ b/heat/tests/test_metadata_refresh.py @@ -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 diff --git a/heat/tests/test_nova_utils.py b/heat/tests/test_nova_utils.py index d9be8317..e9b0e299 100644 --- a/heat/tests/test_nova_utils.py +++ b/heat/tests/test_nova_utils.py @@ -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() diff --git a/heat/tests/test_s3.py b/heat/tests/test_s3.py index f9abb241..cdd49072 100644 --- a/heat/tests/test_s3.py +++ b/heat/tests/test_s3.py @@ -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')) diff --git a/heat/tests/test_signal.py b/heat/tests/test_signal.py index 963a63a8..68d42835 100644 --- a/heat/tests/test_signal.py +++ b/heat/tests/test_signal.py @@ -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() diff --git a/heat/tests/test_swift.py b/heat/tests/test_swift.py index 7f38ef92..879ac910 100644 --- a/heat/tests/test_swift.py +++ b/heat/tests/test_swift.py @@ -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')) diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py index 5a8bc77b..b599e111 100644 --- a/heat/tests/test_waitcondition.py +++ b/heat/tests/test_waitcondition.py @@ -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()) diff --git a/heat/tests/utils.py b/heat/tests/utils.py index bbd26459..01a285ed 100644 --- a/heat/tests/utils.py +++ b/heat/tests/utils.py @@ -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' }) -- 2.45.2