Skip to content

Commit 3b3b90c

Browse files
committed
Add failing test for %(host_node_name)s in include=
Refs #737
1 parent 4987ae6 commit 3b3b90c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

supervisor/tests/test_options.py

+29
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,35 @@ def test_read_config_include_extra_file_malformed(self):
960960
finally:
961961
shutil.rmtree(dirname, ignore_errors=True)
962962

963+
def test_read_config_include_expands_host_node_name(self):
964+
dirname = tempfile.mkdtemp()
965+
conf_d = os.path.join(dirname, "conf.d")
966+
os.mkdir(conf_d)
967+
968+
supervisord_conf = os.path.join(dirname, "supervisord.conf")
969+
text = lstrip("""\
970+
[supervisord]
971+
972+
[include]
973+
files=%s/conf.d/%s.conf
974+
""" % (dirname, "%(host_node_name)s"))
975+
with open(supervisord_conf, 'w') as f:
976+
f.write(text)
977+
978+
conf_file = os.path.join(conf_d, "%s.conf" % platform.node())
979+
with open(conf_file, 'w') as f:
980+
f.write("[inet_http_server]\nport=8000\n")
981+
982+
instance = self._makeOne()
983+
try:
984+
instance.read_config(supervisord_conf)
985+
finally:
986+
shutil.rmtree(dirname, ignore_errors=True)
987+
options = instance.configroot.supervisord
988+
self.assertEqual(len(options.server_configs), 1)
989+
msg = 'Included extra file "%s" during parsing' % conf_file
990+
self.assertTrue(msg in instance.parse_infos)
991+
963992
def test_read_config_include_expands_here(self):
964993
conf = os.path.join(
965994
os.path.abspath(os.path.dirname(__file__)), 'fixtures',

0 commit comments

Comments
 (0)