Beispiel #1
0
 def test_update_heartbeat_one_worker(self):
     test_workers = []
     # Create one worker and it to a list for bookkeeping
     test_workers.append(api.create_worker())
     # Get the original heartbeat of the only worker
     previous_heartbeats = []
     previous_heartbeats.append(test_workers[0].heartbeat)
     # Old heartbeat is before checkpoint, new heartbeat should be after
     checkpoint1 = datetime.now()
     api.update_heartbeat(test_workers[0])
     workers_list = []
     workers_list = api.get_workers()
     checkpoint2 = datetime.now()
     # Verify that the heartbeat has been updated correctly and previous
     # heartbeat was not an unexpected value
     check_heartbeat_value(self, workers_list[0], previous_heartbeats,
                           checkpoint1, checkpoint2, 0)
Beispiel #2
0
 def test_update_heartbeat_one_worker(self):
     test_workers = []
     # Create one worker and it to a list for bookkeeping
     test_workers.append(api.create_worker())
     # Get the original heartbeat of the only worker
     previous_heartbeats = []
     previous_heartbeats.append(test_workers[0].heartbeat)
     # Old heartbeat is before checkpoint, new heartbeat should be after
     checkpoint1 = datetime.now()
     api.update_heartbeat(test_workers[0])
     workers_list = []
     workers_list = api.get_workers()
     checkpoint2 = datetime.now()
     # Verify that the heartbeat has been updated correctly and previous
     # heartbeat was not an unexpected value
     check_heartbeat_value(self, workers_list[0], previous_heartbeats,
                           checkpoint1, checkpoint2, 0)
Beispiel #3
0
 def test_update_heartbeat_one_worker_many_requests(self):
     num_of_requests = MANY
     test_workers = []
     # Create many workers and them to a list for bookkeeping
     test_workers.append(api.create_worker())
     # Get the original heartbeat of the only worker
     previous_heartbeats = []
     previous_heartbeats.append(test_workers[0].heartbeat)
     checkpoint1 = datetime.now()
     workers_list = []
     for request in range(num_of_requests):
         api.update_heartbeat(test_workers[0])
         workers_list = api.get_workers()
         checkpoint2 = datetime.now()
         # Verify that the heartbeat has been updated correctly and previous
         # heartbeat was not an unexpected value
         check_heartbeat_value(self, workers_list[0], previous_heartbeats,
                               checkpoint1, checkpoint2, 0)
Beispiel #4
0
 def test_update_heartbeat_one_worker_many_requests(self):
     num_of_requests = MANY
     test_workers = []
     # Create many workers and them to a list for bookkeeping
     test_workers.append(api.create_worker())
     # Get the original heartbeat of the only worker
     previous_heartbeats = []
     previous_heartbeats.append(test_workers[0].heartbeat)
     checkpoint1 = datetime.now()
     workers_list = []
     for request in range(num_of_requests):
         api.update_heartbeat(test_workers[0])
         workers_list = api.get_workers()
         checkpoint2 = datetime.now()
         # Verify that the heartbeat has been updated correctly and previous
         # heartbeat was not an unexpected value
         check_heartbeat_value(self, workers_list[0], previous_heartbeats,
                               checkpoint1, checkpoint2, 0)
Beispiel #5
0
 def test_update_heartbeat_many_workers_random_worker(self):
     # Number of workers and floor(requests) + ceiling(requests) are equal 
     num_of_workers = MANY
     test_workers = []
     previous_heartbeats = []
     # Create many workers and them to a list for bookkeeping
     for worker in range(num_of_workers):
         test_workers.append(api.create_worker())
     # Get the original heartbeat of each worker
     checkpoint1 = datetime.now()
     for worker in test_workers:
         previous_heartbeats.append(worker.heartbeat)
         random_worker = random.randrange(num_of_workers)
     api.update_heartbeat(test_workers[random_worker])
     workers_list = []
     workers_list = api.get_workers()
     checkpoint2 = datetime.now()
     # Verify that the random worker's heartbeat has been updated correctly
     # and its previous heartbeat was not an unexpected value
     check_heartbeat_value(self, workers_list[random_worker], 
     previous_heartbeats, checkpoint1, checkpoint2, random_worker)
Beispiel #6
0
 def test_update_heartbeat_many_workers_random_worker(self):
     # Number of workers and floor(requests) + ceiling(requests) are equal
     num_of_workers = MANY
     test_workers = []
     previous_heartbeats = []
     # Create many workers and them to a list for bookkeeping
     for worker in range(num_of_workers):
         test_workers.append(api.create_worker())
     # Get the original heartbeat of each worker
     checkpoint1 = datetime.now()
     for worker in test_workers:
         previous_heartbeats.append(worker.heartbeat)
         random_worker = random.randrange(num_of_workers)
     api.update_heartbeat(test_workers[random_worker])
     workers_list = []
     workers_list = api.get_workers()
     checkpoint2 = datetime.now()
     # Verify that the random worker's heartbeat has been updated correctly
     # and its previous heartbeat was not an unexpected value
     check_heartbeat_value(self, workers_list[random_worker],
                           previous_heartbeats, checkpoint1, checkpoint2,
                           random_worker)
Beispiel #7
0
 def test_update_heartbeat_many_workers_many_requests(self):
     num_of_workers = MANY
     test_workers = []
     previous_heartbeats = []
     # Create many workers and them to a list for bookkeeping
     for worker in range(num_of_workers):
         test_workers.append(api.create_worker())
     # Get the original heartbeat of each worker
     for worker in test_workers:
         previous_heartbeats.append(worker.heartbeat)
     checkpoint1 = datetime.now()
     for worker in test_workers:
         api.update_heartbeat(worker)
     workers_list = []
     workers_list = api.get_workers()
     checkpoint2 = datetime.now()
     # Verify that the heartbeats have been updated correctly and previous
     # heartbeats were not an unexpected value
     current = 0
     for worker in workers_list:
         check_heartbeat_value(self, worker, previous_heartbeats,
                               checkpoint1, checkpoint2, current)
         current += 1
Beispiel #8
0
 def test_update_heartbeat_many_workers_many_requests(self):
     num_of_workers = MANY
     test_workers = []
     previous_heartbeats = []
     # Create many workers and them to a list for bookkeeping
     for worker in range(num_of_workers):
         test_workers.append(api.create_worker())
     # Get the original heartbeat of each worker
     for worker in test_workers:
         previous_heartbeats.append(worker.heartbeat)
     checkpoint1 = datetime.now()
     for worker in test_workers:
         api.update_heartbeat(worker)
     workers_list = []
     workers_list = api.get_workers()
     checkpoint2 = datetime.now()
     # Verify that the heartbeats have been updated correctly and previous
     # heartbeats were not an unexpected value
     current = 0
     for worker in workers_list:
         check_heartbeat_value(self, worker, previous_heartbeats,
                               checkpoint1, checkpoint2, current)
         current += 1