-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include current datetime in log files for memmon
- Loading branch information
Showing
2 changed files
with
56 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,13 +54,13 @@ def test_runforever_tick_programs(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 8) | ||
self.assertEqual(lines[0], 'Checking programs bar=0, baz_01=0, foo=0') | ||
self.assertEqual(lines[1], 'RSS of foo:foo is 2264064') | ||
self.assertEqual(lines[2], 'Restarting foo:foo') | ||
self.assertEqual(lines[3], 'RSS of bar:bar is 2265088') | ||
self.assertEqual(lines[4], 'Restarting bar:bar') | ||
self.assertEqual(lines[5], 'RSS of baz:baz_01 is 2265088') | ||
self.assertEqual(lines[6], 'Restarting baz:baz_01') | ||
self.assertIn('Checking programs bar=0, baz_01=0, foo=0', lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertIn('Restarting foo:foo', lines[2]) | ||
self.assertIn('RSS of bar:bar is 2265088', lines[3]) | ||
self.assertIn('Restarting bar:bar', lines[4]) | ||
self.assertIn('RSS of baz:baz_01 is 2265088', lines[5]) | ||
self.assertIn('Restarting baz:baz_01', lines[6]) | ||
self.assertEqual(lines[7], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -80,9 +80,9 @@ def test_runforever_tick_groups(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 4) | ||
self.assertEqual(lines[0], 'Checking groups foo=0') | ||
self.assertEqual(lines[1], 'RSS of foo:foo is 2264064') | ||
self.assertEqual(lines[2], 'Restarting foo:foo') | ||
self.assertIn('Checking groups foo=0', lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertIn('Restarting foo:foo', lines[2]) | ||
self.assertEqual(lines[3], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -102,13 +102,13 @@ def test_runforever_tick_any(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 8) | ||
self.assertEqual(lines[0], 'Checking any=0') | ||
self.assertEqual(lines[1], 'RSS of foo:foo is 2264064') | ||
self.assertEqual(lines[2], 'Restarting foo:foo') | ||
self.assertEqual(lines[3], 'RSS of bar:bar is 2265088') | ||
self.assertEqual(lines[4], 'Restarting bar:bar') | ||
self.assertEqual(lines[5], 'RSS of baz:baz_01 is 2265088') | ||
self.assertEqual(lines[6], 'Restarting baz:baz_01') | ||
self.assertIn('Checking any=0', lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertIn('Restarting foo:foo', lines[2]) | ||
self.assertIn('RSS of bar:bar is 2265088', lines[3]) | ||
self.assertIn('Restarting bar:bar', lines[4]) | ||
self.assertIn('RSS of baz:baz_01 is 2265088', lines[5]) | ||
self.assertIn('Restarting baz:baz_01', lines[6]) | ||
self.assertEqual(lines[7], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -123,12 +123,12 @@ def test_runforever_tick_programs_and_groups(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 7) | ||
self.assertEqual(lines[0], 'Checking programs baz_01=0') | ||
self.assertEqual(lines[1], 'Checking groups foo=0') | ||
self.assertEqual(lines[2], 'RSS of foo:foo is 2264064') | ||
self.assertEqual(lines[3], 'Restarting foo:foo') | ||
self.assertEqual(lines[4], 'RSS of baz:baz_01 is 2265088') | ||
self.assertEqual(lines[5], 'Restarting baz:baz_01') | ||
self.assertIn('Checking programs baz_01=0', lines[0]) | ||
self.assertIn('Checking groups foo=0', lines[1]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[2]) | ||
self.assertIn('Restarting foo:foo', lines[3]) | ||
self.assertIn('RSS of baz:baz_01 is 2265088', lines[4]) | ||
self.assertIn('Restarting baz:baz_01', lines[5]) | ||
self.assertEqual(lines[6], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -148,8 +148,8 @@ def test_runforever_tick_programs_norestart(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 3) | ||
self.assertEqual(lines[0], 'Checking programs foo=%s' % maxint) | ||
self.assertEqual(lines[1], 'RSS of foo:foo is 2264064') | ||
self.assertIn('Checking programs foo=%s' % maxint, lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertEqual(lines[2], '') | ||
self.assertEqual(memmon.mailed, False) | ||
|
||
|
@@ -163,8 +163,8 @@ def test_stopprocess_fault_tick_programs_norestart(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 3) | ||
self.assertEqual(lines[0], 'Checking programs foo=%s' % maxint) | ||
self.assertEqual(lines[1], 'RSS of foo:foo is 2264064') | ||
self.assertIn('Checking programs foo=%s' % maxint, lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertEqual(lines[2], '') | ||
self.assertEqual(memmon.mailed, False) | ||
|
||
|
@@ -192,17 +192,17 @@ def test_stopprocess_fails_to_stop(self): | |
self.assertRaises(xmlrpclib.Fault, memmon.runforever, True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 4) | ||
self.assertEqual(lines[0], 'Checking programs BAD_NAME=%s' % 0) | ||
self.assertEqual(lines[1], 'RSS of BAD_NAME:BAD_NAME is 2264064') | ||
self.assertEqual(lines[2], 'Restarting BAD_NAME:BAD_NAME') | ||
self.assertTrue(lines[3].startswith('Failed')) | ||
self.assertIn('Checking programs BAD_NAME=%s' % 0, lines[0]) | ||
self.assertIn('RSS of BAD_NAME:BAD_NAME is 2264064', lines[1]) | ||
self.assertIn('Restarting BAD_NAME:BAD_NAME', lines[2]) | ||
self.assertIn('Failed', lines[3]) | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
self.assertEqual(mailed[1], | ||
'Subject: memmon: failed to stop process BAD_NAME:BAD_NAME, exiting') | ||
self.assertEqual(mailed[2], '') | ||
self.assertTrue(mailed[3].startswith('Failed')) | ||
self.assertIn('Failed', mailed[3]) | ||
|
||
def test_subject_no_name(self): | ||
"""set the name to None to check if subject formats to: | ||
|
@@ -392,4 +392,3 @@ def test_argparser(self): | |
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|