Faster cache lookup by removing a join with the ImagePlacementTable, removing the extra loop to add the locations and filtering the images looked up by the base image

This commit is contained in:
Joseph Schorr 2015-04-24 16:22:19 -04:00
parent fd65ca5916
commit e70343d849
3 changed files with 39 additions and 1 deletions

View file

@ -91,6 +91,27 @@ class TestImageTree(unittest.TestCase):
self.assertEquals('staging', tree.tag_containing_image(result[0]))
def test_longest_path_simple_repo_direct_lookup(self):
repository = model.get_repository(NAMESPACE, SIMPLE_REPO)
all_images = list(model.get_repository_images(NAMESPACE, SIMPLE_REPO))
all_tags = list(model.list_repository_tags(NAMESPACE, SIMPLE_REPO))
base_image = self._get_base_image(all_images)
tag_image = all_tags[0].image
def checker(index, image):
return True
filtered_images = model.get_repository_images_directly(repository, with_ancestor=base_image)
self.assertEquals(set([f.id for f in filtered_images]), set([a.id for a in all_images]))
tree = ImageTree(filtered_images, all_tags)
ancestors = tag_image.ancestors.split('/')[2:-1] # Skip the first image.
result = tree.find_longest_path(base_image.id, checker)
self.assertEquals(3, len(result))
self.assertEquals('latest', tree.tag_containing_image(result[-1]))
if __name__ == '__main__':
unittest.main()