Skip to content

Commit 68c2a36

Browse files
committed
Add failing tests for #1483
1 parent 601c102 commit 68c2a36

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[supervisord]
2+
loglevel=info ; log level; default info; others: debug,warn,trace
3+
logfile=/tmp/issue-1483a.log ; main log file; default $CWD/supervisord.log
4+
pidfile=/tmp/issue-1483a.pid ; supervisord pidfile; default supervisord.pid
5+
nodaemon=true ; start in foreground if true; default false
6+
7+
[rpcinterface:supervisor]
8+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
9+
10+
[unix_http_server]
11+
file=/tmp/issue-1483a.sock ; the path to the socket file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[supervisord]
2+
loglevel=info ; log level; default info; others: debug,warn,trace
3+
logfile=/tmp/issue-1483b.log ; main log file; default $CWD/supervisord.log
4+
pidfile=/tmp/issue-1483b.pid ; supervisord pidfile; default supervisord.pid
5+
nodaemon=true ; start in foreground if true; default false
6+
identifier=from_config_file
7+
8+
[rpcinterface:supervisor]
9+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
10+
11+
[unix_http_server]
12+
file=/tmp/issue-1483b.sock ; the path to the socket file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[supervisord]
2+
loglevel=info ; log level; default info; others: debug,warn,trace
3+
logfile=/tmp/issue-1483c.log ; main log file; default $CWD/supervisord.log
4+
pidfile=/tmp/issue-1483c.pid ; supervisord pidfile; default supervisord.pid
5+
nodaemon=true ; start in foreground if true; default false
6+
identifier=from_config_file
7+
8+
[rpcinterface:supervisor]
9+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
10+
11+
[unix_http_server]
12+
file=/tmp/issue-1483c.sock ; the path to the socket file

supervisor/tests/test_end_to_end.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,62 @@ def test_issue_1418_pidproxy_cmd_with_args(self):
363363
pidproxy.expect(pexpect.EOF)
364364
self.assertEqual(pidproxy.before.strip(), "1 2")
365365

366+
def test_issue_1483a_identifier_default(self):
367+
"""When no identifier is supplied on the command line or in the config
368+
file, the default is used."""
369+
filename = pkg_resources.resource_filename(__name__, 'fixtures/issue-1483a.conf')
370+
args = ['-m', 'supervisor.supervisord', '-c', filename]
371+
supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8')
372+
self.addCleanup(supervisord.kill, signal.SIGINT)
373+
supervisord.expect_exact('supervisord started with pid')
374+
375+
from supervisor.compat import xmlrpclib
376+
from supervisor.xmlrpc import SupervisorTransport
377+
transport = SupervisorTransport('', '', 'unix:///tmp/issue-1483a.sock')
378+
try:
379+
server = xmlrpclib.ServerProxy('http://transport.ignores.host/RPC2', transport)
380+
ident = server.supervisor.getIdentification()
381+
finally:
382+
transport.close()
383+
self.assertEqual(ident, "supervisor")
384+
385+
def test_issue_1483b_identifier_from_config_file(self):
386+
"""When the identifier is supplied in the config file only, that
387+
identifier is used instead of the default."""
388+
filename = pkg_resources.resource_filename(__name__, 'fixtures/issue-1483b.conf')
389+
args = ['-m', 'supervisor.supervisord', '-c', filename]
390+
supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8')
391+
self.addCleanup(supervisord.kill, signal.SIGINT)
392+
supervisord.expect_exact('supervisord started with pid')
393+
394+
from supervisor.compat import xmlrpclib
395+
from supervisor.xmlrpc import SupervisorTransport
396+
transport = SupervisorTransport('', '', 'unix:///tmp/issue-1483b.sock')
397+
try:
398+
server = xmlrpclib.ServerProxy('http://transport.ignores.host/RPC2', transport)
399+
ident = server.supervisor.getIdentification()
400+
finally:
401+
transport.close()
402+
self.assertEqual(ident, "from_config_file")
403+
404+
def test_issue_1483c_identifier_from_command_line(self):
405+
"""When an identifier is supplied in both the config file and on the
406+
command line, the one from the command line is used."""
407+
filename = pkg_resources.resource_filename(__name__, 'fixtures/issue-1483c.conf')
408+
args = ['-m', 'supervisor.supervisord', '-c', filename, '-i', 'from_command_line']
409+
supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8')
410+
self.addCleanup(supervisord.kill, signal.SIGINT)
411+
supervisord.expect_exact('supervisord started with pid')
412+
413+
from supervisor.compat import xmlrpclib
414+
from supervisor.xmlrpc import SupervisorTransport
415+
transport = SupervisorTransport('', '', 'unix:///tmp/issue-1483c.sock')
416+
try:
417+
server = xmlrpclib.ServerProxy('http://transport.ignores.host/RPC2', transport)
418+
ident = server.supervisor.getIdentification()
419+
finally:
420+
transport.close()
421+
self.assertEqual(ident, "from_command_line")
366422

367423
def test_suite():
368424
return unittest.findTestCases(sys.modules[__name__])

supervisor/tests/test_options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,16 @@ def record_usage(message):
11531153
self.assertEqual(len(recorder), 1)
11541154
self.assertEqual(recorder[0], "option --bad not recognized")
11551155

1156+
def test_realize_prefers_identifier_from_args(self):
1157+
text = lstrip("""
1158+
[supervisord]
1159+
identifier=from_config_file
1160+
""")
1161+
instance = self._makeOne()
1162+
instance.configfile = StringIO(text)
1163+
instance.realize(args=['-i', 'from_args'])
1164+
self.assertEqual(instance.identifier, "from_args")
1165+
11561166
def test_options_afunix(self):
11571167
instance = self._makeOne()
11581168
text = lstrip("""\

0 commit comments

Comments
 (0)