Browse Source

Ensure parent process messages still received after fork

opensearch
Jotham Apaloo 7 years ago
parent
commit
fcac03ae7f
1 changed files with 11 additions and 3 deletions
  1. +11
    -3
      tests/test_logzioSender.py

+ 11
- 3
tests/test_logzioSender.py View File

@ -109,13 +109,21 @@ class TestLogzioSender(TestCase):
def test_can_send_after_fork(self): def test_can_send_after_fork(self):
childpid = os.fork() childpid = os.fork()
log_message = 'logged from child process'
child_log_message = 'logged from child process'
parent_log_message = 'logged from parent process'
if childpid == 0: if childpid == 0:
# Log from the child process # Log from the child process
self.logger.info(log_message)
self.logger.info(child_log_message)
time.sleep(self.logs_drain_timeout * 2) time.sleep(self.logs_drain_timeout * 2)
os._exit(0) os._exit(0)
# Wait for the child process to finish # Wait for the child process to finish
os.waitpid(childpid, 0) os.waitpid(childpid, 0)
self.assertTrue(self.logzio_listener.find_log(log_message))
# log from the parent process
self.logger.info(parent_log_message)
time.sleep(self.logs_drain_timeout * 2)
# Ensure listener receive all log messages
self.assertTrue(self.logzio_listener.find_log(child_log_message))
self.assertTrue(self.logzio_listener.find_log(parent_log_message))

Loading…
Cancel
Save