Commit 39abb0a1 authored by Jérome Perrin's avatar Jérome Perrin

slap/standalone: normalize log files in supervisord

Because some programs did not have proper configuration for log files, they
were using automatically generated file names for log files. Correctly
define stdout_logfile configuration for all programs, used with
redirect_stderr=true, so that both stderr and stdout are in the same log
file.
parent 38888d8a
...@@ -140,12 +140,14 @@ class SupervisorConfigWriter(ConfigWriter): ...@@ -140,12 +140,14 @@ class SupervisorConfigWriter(ConfigWriter):
startretries = 0 startretries = 0
startsecs = 0 startsecs = 0
redirect_stderr = true redirect_stderr = true
stdout_logfile = {standalone_slapos._log_directory}/slapos-proxy.log
[program:slapos-instance-supervisord] [program:slapos-instance-supervisord]
command = supervisord --nodaemon --configuration {standalone_slapos._instance_root}/etc/supervisord.conf command = supervisord --nodaemon --configuration {standalone_slapos._instance_root}/etc/supervisord.conf
startretries = 0 startretries = 0
startsecs = 0 startsecs = 0
redirect_stderr = true redirect_stderr = true
stdout_logfile = {standalone_slapos._log_directory}/slapos-instance-supervisord.log
""").format(**locals()) """).format(**locals())
...@@ -154,8 +156,7 @@ class SupervisorConfigWriter(ConfigWriter): ...@@ -154,8 +156,7 @@ class SupervisorConfigWriter(ConfigWriter):
program, program,
program_config['command'].format( program_config['command'].format(
self=standalone_slapos, debug_args=''), self=standalone_slapos, debug_args=''),
stdout_logfile=program_config.get( stdout_logfile=program_config['stdout_logfile'].format(self=standalone_slapos))
'stdout_logfile', 'AUTO').format(self=standalone_slapos))
def writeConfig(self, path): def writeConfig(self, path):
with open(path, 'w') as f: with open(path, 'w') as f:
...@@ -342,7 +343,7 @@ class StandaloneSlapOS(object): ...@@ -342,7 +343,7 @@ class StandaloneSlapOS(object):
'slapos-node-report': { 'slapos-node-report': {
'command': 'command':
'slapos node report --cfg {self._slapos_config} {debug_args}', 'slapos node report --cfg {self._slapos_config} {debug_args}',
'log_file': 'stdout_logfile':
'{self._log_directory}/slapos-node-report.log', '{self._log_directory}/slapos-node-report.log',
} }
} }
......
...@@ -286,6 +286,29 @@ class SlapOSStandaloneTestCase(unittest.TestCase): ...@@ -286,6 +286,29 @@ class SlapOSStandaloneTestCase(unittest.TestCase):
self.standalone.format(1, SLAPOS_TEST_IPV4, SLAPOS_TEST_IPV6) self.standalone.format(1, SLAPOS_TEST_IPV4, SLAPOS_TEST_IPV6)
class TestSlapOSStandaloneLogFile(SlapOSStandaloneTestCase):
def test_log_files(self):
log_directory = self.standalone._log_directory
with open(os.path.join(log_directory, 'slapos-proxy.log')) as f:
self.assertIn("Running on http", f.read())
self.standalone.waitForSoftware()
with open(os.path.join(log_directory, 'slapos-node-software.log')) as f:
self.assertIn("Processing software releases", f.read())
self.standalone.waitForInstance()
with open(os.path.join(log_directory, 'slapos-node-instance.log')) as f:
self.assertIn("Processing computer partitions", f.read())
self.standalone.waitForReport()
with open(os.path.join(log_directory, 'slapos-node-report.log')) as f:
self.assertIn("Aggregating and sending usage reports", f.read())
self.assertTrue(
os.path.exists(
os.path.join(log_directory, 'slapos-instance-supervisord.log')))
class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase): class TestSlapOSStandaloneSoftware(SlapOSStandaloneTestCase):
def test_install_software(self): def test_install_software(self):
with tempfile.NamedTemporaryFile(suffix="-%s.cfg" % self.id()) as f: with tempfile.NamedTemporaryFile(suffix="-%s.cfg" % self.id()) as f:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment