The validate_hierarchy function is responsible for validating the storage root hierarchy by checking objects within specified directories. The function will iterate over the paths returned by self.object_paths(), using a Validator instance to verify the integrity of each object. It has the following expected input and output behavior:
Inputs:
validate_objects: a boolean flag that indicates whether to perform object validation (default is True).
check_digests: a boolean flag that decides if digest checks should be performed (default is True).
show_warnings: a boolean flag that controls whether warnings are printed (default is False).
Outputs:
The function returns a tuple (num_objects, good_objects):
num_objects: total number of objects checked.
good_objects: number of objects found to be valid.
Edge cases to handle:
The method should handle scenarios where self.object_paths() may return an empty list gracefully, resulting in (0, 0) being returned.
It must ensure the Validator works correctly with the parameters provided, especially when show_warnings is set to True or False.
Adding appropriate logging when an object is invalid.
Note: The solution should be placed in /app/solution.py. The function must be importable as: from solution import validate_hierarchy