|
@@ -40,7 +40,6 @@ class TestHostname(TestCase):
|
|
|
os.chmod(tmpname, os.stat(tmpname).st_mode | stat.S_IXUSR)
|
|
|
|
|
|
tmpfile = file(tmpname, "w+")
|
|
|
-
|
|
|
config = AmbariConfig.config
|
|
|
try:
|
|
|
tmpfile.write("#!/bin/sh\n\necho 'test.example.com'")
|
|
@@ -55,5 +54,29 @@ class TestHostname(TestCase):
|
|
|
|
|
|
pass
|
|
|
|
|
|
+ def test_public_hostname_override(self):
|
|
|
+ fd = tempfile.mkstemp(text=True)
|
|
|
+ tmpname = fd[1]
|
|
|
+ os.close(fd[0])
|
|
|
+ os.chmod(tmpname, os.stat(tmpname).st_mode | stat.S_IXUSR)
|
|
|
+
|
|
|
+ tmpfile = file(tmpname, "w+")
|
|
|
+
|
|
|
+ config = AmbariConfig.config
|
|
|
+ try:
|
|
|
+ tmpfile.write("#!/bin/sh\n\necho 'test.example.com'")
|
|
|
+ tmpfile.close()
|
|
|
+
|
|
|
+ config.set('agent', 'public_hostname_script', tmpname)
|
|
|
+
|
|
|
+ self.assertEquals(hostname.public_hostname(), 'test.example.com',
|
|
|
+ "expected hostname 'test.example.com'")
|
|
|
+ finally:
|
|
|
+ os.remove(tmpname)
|
|
|
+ config.remove_option('agent', 'public_hostname_script')
|
|
|
+
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|