def test_fetch(self): """Tests fetch() of GM results from actual-results.json .""" downloader = download_actuals.Download( actuals_base_url=url_utils.create_filepath_url( os.path.join(self.input_dir, 'gm-actuals')), gm_actuals_root_url=url_utils.create_filepath_url( os.path.join(self.input_dir, 'fake-gm-imagefiles'))) downloader.fetch( builder_name='Test-Android-GalaxyNexus-SGX540-Arm7-Release', dest_dir=self.output_dir_actual)
def __init__(self, configs, actuals_root=results.DEFAULT_ACTUALS_DIR, generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT, diff_base_url=None, builder_regex_list=None): """ Args: configs: (string, string) tuple; pair of configs to compare actuals_root: root directory containing all actual-results.json files generated_images_root: directory within which to create all pixel diffs; if this directory does not yet exist, it will be created diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of generated_images_root builder_regex_list: List of regular expressions specifying which builders we will process. If None, process all builders. """ super(ConfigComparisons, self).__init__() time_start = int(time.time()) if builder_regex_list != None: self.set_match_builders_pattern_list(builder_regex_list) self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) self._diff_base_url = ( diff_base_url or url_utils.create_filepath_url(generated_images_root)) self._actuals_root = actuals_root self._load_config_pairs(configs) self._timestamp = int(time.time()) logging.info('Results complete; took %d seconds.' % (self._timestamp - time_start))
def __init__( self, subdirs, actuals_root, generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT, image_base_url=DEFAULT_IMAGE_BASE_URL, diff_base_url=None, ): """ Args: actuals_root: root directory containing all render_pictures-generated JSON files subdirs: (string, string) tuple; pair of subdirectories within actuals_root to compare generated_images_root: directory within which to create all pixel diffs; if this directory does not yet exist, it will be created image_base_url: URL under which all render_pictures result images can be found; this will be used to read images for comparison within this code, and included in the ImagePairSet so its consumers know where to download the images from diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of generated_images_root """ time_start = int(time.time()) self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) self._image_base_url = image_base_url self._diff_base_url = diff_base_url or url_utils.create_filepath_url(generated_images_root) self._load_result_pairs(actuals_root, subdirs) self._timestamp = int(time.time()) logging.info("Results complete; took %d seconds." % (self._timestamp - time_start))
def __init__(self, image_diff_db, actuals_root=results.DEFAULT_ACTUALS_DIR, expected_root=DEFAULT_EXPECTATIONS_DIR, ignore_failures_file=DEFAULT_IGNORE_FAILURES_FILE, diff_base_url=None, builder_regex_list=None): """ Args: image_diff_db: instance of ImageDiffDB we use to cache the image diffs actuals_root: root directory containing all actual-results.json files expected_root: root directory containing all expected-results.json files ignore_failures_file: if a file with this name is found within expected_root, ignore failures for any tests listed in the file diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of image_diff_db's storage_root builder_regex_list: List of regular expressions specifying which builders we will process. If None, process all builders. """ time_start = int(time.time()) if builder_regex_list != None: self.set_match_builders_pattern_list(builder_regex_list) self._image_diff_db = image_diff_db self._diff_base_url = ( diff_base_url or url_utils.create_filepath_url(image_diff_db.storage_root)) self._actuals_root = actuals_root self._expected_root = expected_root self._ignore_failures_on_these_tests = [] if ignore_failures_file: self._ignore_failures_on_these_tests = ( ExpectationComparisons._read_noncomment_lines( os.path.join(expected_root, ignore_failures_file))) self._load_actual_and_expected() self._timestamp = int(time.time()) logging.info('Results complete; took %d seconds.' % (self._timestamp - time_start))
def __init__( self, configs, actuals_root=results.DEFAULT_ACTUALS_DIR, generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT, diff_base_url=None, builder_regex_list=None, ): """ Args: configs: (string, string) tuple; pair of configs to compare actuals_root: root directory containing all actual-results.json files generated_images_root: directory within which to create all pixel diffs; if this directory does not yet exist, it will be created diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of generated_images_root builder_regex_list: List of regular expressions specifying which builders we will process. If None, process all builders. """ time_start = int(time.time()) if builder_regex_list != None: self.set_match_builders_pattern_list(builder_regex_list) self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) self._diff_base_url = diff_base_url or url_utils.create_filepath_url(generated_images_root) self._actuals_root = actuals_root self._load_config_pairs(configs) self._timestamp = int(time.time()) logging.info("Results complete; took %d seconds." % (self._timestamp - time_start))
def __init__(self, image_diff_db, actuals_root=results.DEFAULT_ACTUALS_DIR, expected_root=DEFAULT_EXPECTATIONS_DIR, ignore_failures_file=DEFAULT_IGNORE_FAILURES_FILE, diff_base_url=None, builder_regex_list=None): """ Args: image_diff_db: instance of ImageDiffDB we use to cache the image diffs actuals_root: root directory containing all actual-results.json files expected_root: root directory containing all expected-results.json files ignore_failures_file: if a file with this name is found within expected_root, ignore failures for any tests listed in the file diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of image_diff_db's storage_root builder_regex_list: List of regular expressions specifying which builders we will process. If None, process all builders. """ super(ExpectationComparisons, self).__init__() time_start = int(time.time()) if builder_regex_list != None: self.set_match_builders_pattern_list(builder_regex_list) self._image_diff_db = image_diff_db self._diff_base_url = (diff_base_url or url_utils.create_filepath_url( image_diff_db.storage_root)) self._actuals_root = actuals_root self._expected_root = expected_root self._ignore_failures_on_these_tests = [] if ignore_failures_file: self._ignore_failures_on_these_tests = ( ExpectationComparisons._read_noncomment_lines( os.path.join(expected_root, ignore_failures_file))) self._load_actual_and_expected() self._timestamp = int(time.time()) logging.info('Results complete; took %d seconds.' % (self._timestamp - time_start))
def __init__(self, setA_dir, setB_dir, setA_section, setB_section, image_diff_db, image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, diff_base_url=None, setA_label=None, setB_label=None, gs=None, truncate_results=False, prefetch_only=False, download_all_images=False): """Constructor: downloads images and generates diffs. Once the object has been created (which may take a while), you can call its get_packaged_results_of_type() method to quickly retrieve the results... unless you have set prefetch_only to True, in which case we will asynchronously warm up the ImageDiffDB cache but not fill in self._results. Args: setA_dir: root directory to copy all JSON summaries from, and to use as setA within the comparisons. This directory may be specified as a gs:// URL, special "repo:" URL, or local filepath. setB_dir: root directory to copy all JSON summaries from, and to use as setB within the comparisons. This directory may be specified as a gs:// URL, special "repo:" URL, or local filepath. setA_section: which section within setA to examine; must be one of ALLOWED_SECTION_NAMES setB_section: which section within setB to examine; must be one of ALLOWED_SECTION_NAMES image_diff_db: ImageDiffDB instance image_base_gs_url: "gs://" URL pointing at the Google Storage bucket/dir under which all render_pictures result images can be found; this will be used to read images for comparison within this code, and included in the ImagePairSet (as an HTTP URL) so its consumers know where to download the images from diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of image_diff_db's storage_root setA_label: description to use for results in setA; if None, will be set to a reasonable default setB_label: description to use for results in setB; if None, will be set to a reasonable default gs: instance of GSUtils object we can use to download summary files truncate_results: FOR MANUAL TESTING: if True, truncate the set of images we process, to speed up testing. prefetch_only: if True, return the new object as quickly as possible with empty self._results (just queue up all the files to process, don't wait around for them to be processed and recorded); otherwise, block until the results have been assembled and recorded in self._results. download_all_images: if True, download all images, even if we don't need them to generate diffs. This will take much longer to complete, but is useful for warming up the bitmap cache on local disk. """ super(RenderedPicturesComparisons, self).__init__() self._image_diff_db = image_diff_db self._image_base_gs_url = image_base_gs_url self._diff_base_url = ( diff_base_url or url_utils.create_filepath_url(image_diff_db.storage_root)) self._gs = gs self.truncate_results = truncate_results self._prefetch_only = prefetch_only self._download_all_images = download_all_images # If we are comparing two different section types, we can use those # as the default labels for setA and setB. if setA_section != setB_section: self._setA_label = setA_label or setA_section self._setB_label = setB_label or setB_section else: self._setA_label = setA_label or 'setA' self._setB_label = setB_label or 'setB' tempdir = tempfile.mkdtemp() try: setA_root = os.path.join(tempdir, 'setA') setB_root = os.path.join(tempdir, 'setB') # TODO(stephana): There is a potential race condition here... we copy # the contents out of the source_dir, and THEN we get the commithash # of source_dir. If source_dir points at a git checkout, and that # checkout is updated (by a different thread/process) during this # operation, then the contents and commithash will be out of sync. self._copy_dir_contents(source_dir=setA_dir, dest_dir=setA_root) setA_repo_revision = self._get_repo_revision(source_dir=setA_dir) self._copy_dir_contents(source_dir=setB_dir, dest_dir=setB_root) setB_repo_revision = self._get_repo_revision(source_dir=setB_dir) self._setA_descriptions = { results.KEY__SET_DESCRIPTIONS__DIR: setA_dir, results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setA_repo_revision, results.KEY__SET_DESCRIPTIONS__SECTION: setA_section, } self._setB_descriptions = { results.KEY__SET_DESCRIPTIONS__DIR: setB_dir, results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setB_repo_revision, results.KEY__SET_DESCRIPTIONS__SECTION: setB_section, } time_start = int(time.time()) self._results = self._load_result_pairs( setA_root=setA_root, setB_root=setB_root, setA_section=setA_section, setB_section=setB_section) if self._results: self._timestamp = int(time.time()) logging.info('Number of download file collisions: %s' % imagediffdb.global_file_collisions) logging.info('Results complete; took %d seconds.' % (self._timestamp - time_start)) finally: shutil.rmtree(tempdir)
def __init__(self, setA_dir, setB_dir, setA_section, setB_section, image_diff_db, image_base_gs_url=DEFAULT_IMAGE_BASE_GS_URL, diff_base_url=None, setA_label=None, setB_label=None, gs=None, truncate_results=False, prefetch_only=False, download_all_images=False): """Constructor: downloads images and generates diffs. Once the object has been created (which may take a while), you can call its get_packaged_results_of_type() method to quickly retrieve the results... unless you have set prefetch_only to True, in which case we will asynchronously warm up the ImageDiffDB cache but not fill in self._results. Args: setA_dir: root directory to copy all JSON summaries from, and to use as setA within the comparisons. This directory may be specified as a gs:// URL, special "repo:" URL, or local filepath. setB_dir: root directory to copy all JSON summaries from, and to use as setB within the comparisons. This directory may be specified as a gs:// URL, special "repo:" URL, or local filepath. setA_section: which section within setA to examine; must be one of ALLOWED_SECTION_NAMES setB_section: which section within setB to examine; must be one of ALLOWED_SECTION_NAMES image_diff_db: ImageDiffDB instance image_base_gs_url: "gs://" URL pointing at the Google Storage bucket/dir under which all render_pictures result images can be found; this will be used to read images for comparison within this code, and included in the ImagePairSet (as an HTTP URL) so its consumers know where to download the images from diff_base_url: base URL within which the client should look for diff images; if not specified, defaults to a "file:///" URL representation of image_diff_db's storage_root setA_label: description to use for results in setA; if None, will be set to a reasonable default setB_label: description to use for results in setB; if None, will be set to a reasonable default gs: instance of GSUtils object we can use to download summary files truncate_results: FOR MANUAL TESTING: if True, truncate the set of images we process, to speed up testing. prefetch_only: if True, return the new object as quickly as possible with empty self._results (just queue up all the files to process, don't wait around for them to be processed and recorded); otherwise, block until the results have been assembled and recorded in self._results. download_all_images: if True, download all images, even if we don't need them to generate diffs. This will take much longer to complete, but is useful for warming up the bitmap cache on local disk. """ super(RenderedPicturesComparisons, self).__init__() self._image_diff_db = image_diff_db self._image_base_gs_url = image_base_gs_url self._diff_base_url = (diff_base_url or url_utils.create_filepath_url( image_diff_db.storage_root)) self._gs = gs self.truncate_results = truncate_results self._prefetch_only = prefetch_only self._download_all_images = download_all_images # If we are comparing two different section types, we can use those # as the default labels for setA and setB. if setA_section != setB_section: self._setA_label = setA_label or setA_section self._setB_label = setB_label or setB_section else: self._setA_label = setA_label or 'setA' self._setB_label = setB_label or 'setB' tempdir = tempfile.mkdtemp() try: setA_root = os.path.join(tempdir, 'setA') setB_root = os.path.join(tempdir, 'setB') # TODO(stephana): There is a potential race condition here... we copy # the contents out of the source_dir, and THEN we get the commithash # of source_dir. If source_dir points at a git checkout, and that # checkout is updated (by a different thread/process) during this # operation, then the contents and commithash will be out of sync. self._copy_dir_contents(source_dir=setA_dir, dest_dir=setA_root) setA_repo_revision = self._get_repo_revision(source_dir=setA_dir) self._copy_dir_contents(source_dir=setB_dir, dest_dir=setB_root) setB_repo_revision = self._get_repo_revision(source_dir=setB_dir) self._setA_descriptions = { results.KEY__SET_DESCRIPTIONS__DIR: setA_dir, results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setA_repo_revision, results.KEY__SET_DESCRIPTIONS__SECTION: setA_section, } self._setB_descriptions = { results.KEY__SET_DESCRIPTIONS__DIR: setB_dir, results.KEY__SET_DESCRIPTIONS__REPO_REVISION: setB_repo_revision, results.KEY__SET_DESCRIPTIONS__SECTION: setB_section, } time_start = int(time.time()) self._results = self._load_result_pairs(setA_root=setA_root, setB_root=setB_root, setA_section=setA_section, setB_section=setB_section) if self._results: self._timestamp = int(time.time()) logging.info('Number of download file collisions: %s' % imagediffdb.global_file_collisions) logging.info('Results complete; took %d seconds.' % (self._timestamp - time_start)) finally: shutil.rmtree(tempdir)