def testAllShardsAreDone(self):
    for i in range(3):
      shard_state = self.create_shard_state(self.mapreduce_id, i)
      shard_state.counters_map.increment(
          COUNTER_MAPPER_CALLS, i * 2 + 1)  # 1, 3, 5
      shard_state.active = False
      shard_state.result_status = model.ShardState.RESULT_SUCCESS
      shard_state.put()

    self.handler.post()

    mapreduce_state = model.MapreduceState.get_by_key_name(self.mapreduce_id)
    self.verify_mapreduce_state(
        mapreduce_state, processed=9, active=False, shard_count=3,
        result_status=model.MapreduceState.RESULT_SUCCESS)
    self.assertEquals(0, mapreduce_state.failed_shards)
    self.assertEquals(0, mapreduce_state.aborted_shards)

    tasks = self.taskqueue.GetTasks("default")
    # Finalize task should be spawned.
    self.assertEquals(1, len(tasks))
    self.assertEquals("/mapreduce/finalizejob_callback/" + self.mapreduce_id,
                      tasks[0]["url"])
    headers = dict(tasks[0]["headers"])
    self.assertEqual(self.mapreduce_id, headers[util._MR_ID_TASK_HEADER])
    self.assertEqual(self.host, headers["Host"])

    # Done Callback task should be spawned
    self.verify_done_task()

    self.assertEquals(3, len(list(
        model.ShardState.find_all_by_mapreduce_state(mapreduce_state))))
Mapreduce should become inactive when all shards have finished.
dataset/ETHPy150Open GoogleCloudPlatform/appengine-mapreduce/python/test/mapreduce/handlers_test.py/ControllerCallbackHandlerTest.testAllShardsAreDone