Beispiel #1
0
 def test_6_send_a_message_to_every_queue(self):
     """Send a message to every queue configured in Django settings."""
     global stats
     for q in settings.CELERY_QUEUES:
         add.queue = q
         sum_result = get_result_of_task(add, 1, 2)
         pprint("Executing a task to add 1 + 2 for queue {0}.  Result: {1}".format(q, sum_result))
         self.assertEqual(
             sum_result,
             3,
             msg="Task to add 1 + 2 for queue {0} didn't execute successfully.  Result: {1}".format(q, sum_result),
         )
Beispiel #2
0
 def test_6_send_a_message_to_every_queue(self):
     """Send a message to every queue configured in Django settings."""
     global stats
     for q in settings.CELERY_QUEUES:
         add.queue = q
         sum_result = get_result_of_task(add, 1, 2)
         pprint("Executing a task to add 1 + 2 for queue {0}.  Result: {1}".
                format(q, sum_result))
         self.assertEqual(
             sum_result,
             3,
             msg=
             "Task to add 1 + 2 for queue {0} didn't execute successfully.  Result: {1}"
             .format(q, sum_result))
Beispiel #3
0
 def test_8_celery_logs(self):
     """Test celery logs by writing 'Sanity Check' to each log."""
     global stats
     worker_logs = []
     log_message = "Sanity Check"
     for workername in stats.iterkeys():
         if stats[workername]["log_file"]:
             worker_logs.append(stats[workername]["log_file"])
     worker_logs_distinct = set(worker_logs)
     try:
         celery_logs = worker_logs_distinct or settings.CELERYD_LOG_FILE
     except AttributeError:
         celery_logs = worker_logs_distinct
     self.assertFalse(
         not celery_logs,
         msg="Can't find any logs for celery in settings.CELERYD_LOG_FILE or for the celery workers.",
     )
     for f in celery_logs:
         pprint("Writing {0} to the the following log: {1}".format(log_message, f))
         result = get_result_of_task(write_to_file, f, log_message)
         self.assertTrue("Cannot" not in result, msg=result)
Beispiel #4
0
 def test_4_source_code_of_celery_workers(self):
     """Make sure that the celery workers are running the correct code by verifying that the code in the current directory matches the code
        that the celery workers are running.
     """
     global stats
     worker_code_paths = []
     for workername in stats.iterkeys():
         if stats[workername]['code_path']:
             worker_code_paths.append(stats[workername]['code_path'])
     worker_code_paths_distinct = set(worker_code_paths)
     for worker_code_path in worker_code_paths_distinct:
         shasum_for_current_directory = get_shasum_for_current_directory()
         shasum_for_celery_worker_code_path = get_result_of_task(
             get_shasum_for_celery_worker_code_path, worker_code_path)
         pprint(
             "Comparing the code in the current directory: {0} with a SHA of: {1} against the code that the celery workers are running: {2} with a SHA of {3}"
             .format(os.getcwd(), shasum_for_current_directory,
                     worker_code_path, shasum_for_celery_worker_code_path))
         message = "The code in the current directory: {0} with a SHA of: {1} is not the same as the code that the celery workers are running: {2} with a SHA of {3}".format(
             os.getcwd(), shasum_for_current_directory, worker_code_path,
             shasum_for_celery_worker_code_path)
         self.assertEqual(shasum_for_current_directory, \
         shasum_for_celery_worker_code_path, \
         msg=message)
Beispiel #5
0
 def test_4_source_code_of_celery_workers(self):
     """Make sure that the celery workers are running the correct code by verifying that the code in the current directory matches the code
        that the celery workers are running.
     """
     global stats
     worker_code_paths = []
     for workername in stats.iterkeys():
         if stats[workername]["code_path"]:
             worker_code_paths.append(stats[workername]["code_path"])
     worker_code_paths_distinct = set(worker_code_paths)
     for worker_code_path in worker_code_paths_distinct:
         shasum_for_current_directory = get_shasum_for_current_directory()
         shasum_for_celery_worker_code_path = get_result_of_task(
             get_shasum_for_celery_worker_code_path, worker_code_path
         )
         pprint(
             "Comparing the code in the current directory: {0} with a SHA of: {1} against the code that the celery workers are running: {2} with a SHA of {3}".format(
                 os.getcwd(), shasum_for_current_directory, worker_code_path, shasum_for_celery_worker_code_path
             )
         )
         message = "The code in the current directory: {0} with a SHA of: {1} is not the same as the code that the celery workers are running: {2} with a SHA of {3}".format(
             os.getcwd(), shasum_for_current_directory, worker_code_path, shasum_for_celery_worker_code_path
         )
         self.assertEqual(shasum_for_current_directory, shasum_for_celery_worker_code_path, msg=message)