def test_image_tags_extraction(self): entities = [ # ({'Image': image_name}, [expected_image_name, expected_image_tag]) ({ 'Image': 'nginx:latest' }, [['nginx'], ['latest']]), ({ 'Image': 'localhost/nginx:latest' }, [['localhost/nginx'], ['latest']]), ({ 'Image': 'localhost:5000/nginx:latest' }, [['localhost:5000/nginx'], ['latest']]), ({ 'RepoTags': ['redis:latest'] }, [['redis'], ['latest']]), ({ 'RepoTags': ['localhost/redis:latest'] }, [['localhost/redis'], ['latest']]), ({ 'RepoTags': ['localhost:5000/redis:latest'] }, [['localhost:5000/redis'], ['latest']]), ({ 'RepoTags': ['localhost:5000/redis:latest', 'localhost:5000/redis:v1.1'] }, [['localhost:5000/redis'], ['latest', 'v1.1']]), ] for entity in entities: self.assertEqual(sorted(image_tag_extractor(entity[0], 0)), sorted(entity[1][0])) self.assertEqual(sorted(image_tag_extractor(entity[0], 1)), sorted(entity[1][1]))
def test_image_tags_extraction(self): entities = [ # ({'Image': image_name}, [expected_image_name, expected_image_tag]) ({'Image': 'nginx:latest'}, [['nginx'], ['latest']]), ({'Image': 'localhost/nginx:latest'}, [['localhost/nginx'], ['latest']]), ({'Image': 'localhost:5000/nginx:latest'}, [['localhost:5000/nginx'], ['latest']]), ({'RepoTags': ['redis:latest']}, [['redis'], ['latest']]), ({'RepoTags': ['localhost/redis:latest']}, [['localhost/redis'], ['latest']]), ({'RepoTags': ['localhost:5000/redis:latest']}, [['localhost:5000/redis'], ['latest']]), ({'RepoTags': ['localhost:5000/redis:latest', 'localhost:5000/redis:v1.1']}, [['localhost:5000/redis'], ['latest', 'v1.1']]), ] for entity in entities: self.assertEqual(sorted(image_tag_extractor(entity[0], 0)), sorted(entity[1][0])) self.assertEqual(sorted(image_tag_extractor(entity[0], 1)), sorted(entity[1][1]))
"image_name", "image_tag", ] DEFAULT_PERFORMANCE_TAGS = [ "container_name", "docker_image", "image_name", "image_tag", ] DEFAULT_IMAGE_TAGS = ['image_name', 'image_tag'] TAG_EXTRACTORS = { "docker_image": lambda c: [c["Image"]], "image_name": lambda c: image_tag_extractor(c, 0), "image_tag": lambda c: image_tag_extractor(c, 1), "container_command": lambda c: [c["Command"]], "container_name": container_name_extractor, } CONTAINER = "container" PERFORMANCE = "performance" FILTERED = "filtered" IMAGE = "image" def get_mountpoints(docker_root): mountpoints = {} for metric in CGROUP_METRICS: mountpoints[metric["cgroup"]] = find_cgroup(metric["cgroup"],
DEFAULT_PERFORMANCE_TAGS = [ "container_name", "docker_image", "image_name", "image_tag", ] DEFAULT_IMAGE_TAGS = [ 'image_name', 'image_tag' ] TAG_EXTRACTORS = { "docker_image": lambda c: [c["Image"]], "image_name": lambda c: image_tag_extractor(c, 0), "image_tag": lambda c: image_tag_extractor(c, 1), "container_command": lambda c: [c["Command"]], "container_name": container_name_extractor, } CONTAINER = "container" PERFORMANCE = "performance" FILTERED = "filtered" IMAGE = "image" def get_mountpoints(docker_root): mountpoints = {} for metric in CGROUP_METRICS: mountpoints[metric["cgroup"]] = find_cgroup(metric["cgroup"], docker_root)