def test_7_celerybeat(self): """Test Celery Beat by checking to see if a specific task has executed within the last 5 seconds.""" global stats worker_queues = [] celerybeat_tasks = {} celerybeat_tasks_delta = {} for workername in stats.iterkeys(): try: celerybeat_tasks.update({ workername: stats[workername]['total']['sanity.tasks.celerybeat_test'] }) except KeyError: pass sleep(5) stats_delta = get_celery_stats() for workername in stats_delta.iterkeys(): try: celerybeat_tasks_delta.update({ workername: stats_delta[workername]['total'] ['sanity.tasks.celerybeat_test'] }) except KeyError: pass for workername in celerybeat_tasks.iterkeys(): if celerybeat_tasks[workername] != celerybeat_tasks_delta[ workername]: return message = "Celery Beat has failed because it hasn't executed the sanity.tasks.celerybeat_test task in at least 5 seconds. Here are the stats of the number of times the sanity.tasks.celerybeat_test task was executed as of 5 seconds ago: %s and here are the stats taken 5 seconds after: %s " % ( celerybeat_tasks, celerybeat_tasks_delta) self.fail(msg=message)
def test_7_celerybeat(self): """Test Celery Beat by checking to see if a specific task has executed within the last 5 seconds.""" global stats worker_queues = [] celerybeat_tasks = {} celerybeat_tasks_delta = {} for workername in stats.iterkeys(): try: celerybeat_tasks.update({workername: stats[workername]["total"]["sanity.tasks.celerybeat_test"]}) except KeyError: pass sleep(5) stats_delta = get_celery_stats() for workername in stats_delta.iterkeys(): try: celerybeat_tasks_delta.update( {workername: stats_delta[workername]["total"]["sanity.tasks.celerybeat_test"]} ) except KeyError: pass for workername in celerybeat_tasks.iterkeys(): if celerybeat_tasks[workername] != celerybeat_tasks_delta[workername]: return message = ( "Celery Beat has failed because it hasn't executed the sanity.tasks.celerybeat_test task in at least 5 seconds. Here are the stats of the number of times the sanity.tasks.celerybeat_test task was executed as of 5 seconds ago: %s and here are the stats taken 5 seconds after: %s " % (celerybeat_tasks, celerybeat_tasks_delta) ) self.fail(msg=message)
def test_0_init(self): """Test the initialization of the test suite by retrieving and printing the celery stats.""" global stats stats = get_celery_stats() self.assertFalse(stats == -1, msg="The RabbitMQ server isn't running for this environment.") self.assertFalse(not stats, msg="There are no celery workers running for this environment.") pprint("=============Printing Celery Worker Stats=============") pprint("Number of worker nodes -> {0}".format(len(stats))) pprint(stats) print_django_celery_config()
def test_0_init(self): """Test the initialization of the test suite by retrieving and printing the celery stats.""" global stats stats = get_celery_stats() self.assertFalse( stats == -1, msg="The RabbitMQ server isn't running for this environment.") self.assertFalse( not stats, msg="There are no celery workers running for this environment.") pprint('=============Printing Celery Worker Stats=============') pprint('Number of worker nodes -> {0}'.format(len(stats))) pprint(stats) print_django_celery_config()