#NEWLINE# def test_metrics_enqueue_sliding_window( self ) : #NEWLINE# #INDENT# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( len ( response [ 'enqueue_counts' ] . values ( ) ) , 10 ) #NEWLINE# self . assertEqual ( sum ( response [ 'enqueue_counts' ] . values ( ) ) , 0 ) #NEWLINE# self . assertEqual ( len ( global_response [ 'enqueue_counts' ] . values ( ) ) , 10 ) #NEWLINE# self . assertEqual ( sum ( global_response [ 'enqueue_counts' ] . values ( ) ) , 0 ) #NEWLINE# job_id = self . _get_job_id ( ) #NEWLINE# response = self . queue . enqueue ( payload = self . _test_payload_1 , interval = 10000 , job_id = job_id , queue_id = self . _test_queue_id , queue_type = self . _test_queue_type ) #NEWLINE# timestamp = int ( generate_epoch ( ) ) #NEWLINE# timestamp_minute = str ( int ( ( math . floor ( ( timestamp / 60000.0 ) ) * 60000 ) ) ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 1 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 1 ) #NEWLINE# job_id = self . _get_job_id ( ) #NEWLINE# response = self . queue . enqueue ( payload = self . _test_payload_1 , interval = 10000 , job_id = job_id , queue_id = self . _test_queue_id , queue_type = self . _test_queue_type ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 2 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 2 ) #NEWLINE# time . sleep ( 65 ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 2 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 2 ) #NEWLINE# old_1_timestamp_minute = timestamp_minute #NEWLINE# timestamp = int ( generate_epoch ( ) ) #NEWLINE# timestamp_minute = str ( int ( ( math . floor ( ( timestamp / 60000.0 ) ) * 60000 ) ) ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 0 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 0 ) #NEWLINE# job_id = self . _get_job_id ( ) #NEWLINE# response = self . queue . enqueue ( payload = self . _test_payload_1 , interval = 10000 , job_id = job_id , queue_id = self . _test_queue_id , queue_type = self . _test_queue_type ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 1 ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ old_1_timestamp_minute ] , 2 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 1 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ old_1_timestamp_minute ] , 2 ) #NEWLINE# time . sleep ( 65 ) #NEWLINE# old_2_timestamp_minute = timestamp_minute #NEWLINE# timestamp = int ( generate_epoch ( ) ) #NEWLINE# timestamp_minute = str ( int ( ( math . floor ( ( timestamp / 60000.0 ) ) * 60000 ) ) ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 0 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 0 ) #NEWLINE# job_id = self . _get_job_id ( ) #NEWLINE# response = self . queue . enqueue ( payload = self . _test_payload_1 , interval = 10000 , job_id = job_id , queue_id = self . _test_queue_id , queue_type = self . _test_queue_type ) #NEWLINE# response = self . queue . metrics ( queue_type = self . _test_queue_type , queue_id = self . _test_queue_id ) #NEWLINE# global_response = self . queue . metrics ( ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ timestamp_minute ] , 1 ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ old_1_timestamp_minute ] , 2 ) #NEWLINE# self . assertEqual ( response [ 'enqueue_counts' ] [ old_2_timestamp_minute ] , 1 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ timestamp_minute ] , 1 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ old_1_timestamp_minute ] , 2 ) #NEWLINE# self . assertEqual ( global_response [ 'enqueue_counts' ] [ old_2_timestamp_minute ] , 1 )