Exemple #1
0
 def determine_source_repositories(self):
     """Determine which repositories are available to this SCM."""
     raise_and_log_error(
         UnexpectedError(self.__class__.__name__ +
                         ': Should only be applicable to BomSCM',
                         cause='NotReachable'))
Exemple #2
0
    def validate_test_requirements(self, test_name, spec, metric_labels):
        """Determine whether or not the test requirements are satisfied.

    If not, record the reason a skip or failure.
    This may throw exceptions, which are immediate failure.

    Args:
      test_name: [string] The name of the test.
      spec: [dict] The profile specification containing requirements.
            This argument will be pruned as values are consumed from it.

    Returns:
      True if requirements are satisfied, False if not.
    """
        if not 'api' in spec:
            raise_and_log_error(
                UnexpectedError(
                    'Test "{name}" is missing an "api" spec.'.format(
                        name=test_name)))

        requires = spec.pop('requires', {})
        configuration = requires.pop('configuration', {})
        our_config = vars(self.options)
        for key, value in configuration.items():
            if key not in our_config:
                message = (
                    'Unknown configuration key "{0}" for test "{1}"'.format(
                        key, test_name))
                raise_and_log_error(ConfigError(message))
            if value != our_config[key]:
                reason = ('Skipped test {name} because {key}={want} != {have}'.
                          format(name=test_name,
                                 key=key,
                                 want=value,
                                 have=our_config[key]))
                with self.__lock:
                    self.__record_skip_test(test_name, reason,
                                            'IncompatableConfig',
                                            metric_labels)
                return False

        services = set(
            replace_ha_services(requires.pop('services', []), self.options))

        services.add(
            self.__replace_ha_api_service(spec.pop('api'), self.options))

        if requires:
            raise_and_log_error(
                ConfigError(
                    'Unexpected fields in {name}.requires: {remaining}'.format(
                        name=test_name, remaining=requires)))
        if spec:
            raise_and_log_error(
                ConfigError(
                    'Unexpected fields in {name} specification: {remaining}'.
                    format(name=test_name, remaining=spec)))

        for service in self.__public_service_configs:
            self.__validate_service_base_url(service)

        if self.options.test_wait_on_services:

            def wait_on_services(services):
                thread_pool = ThreadPool(len(services))
                thread_pool.map(self.wait_on_service, services)
                thread_pool.terminate()

            self.__deployer.metrics.track_and_time_call(
                'WaitingOnServiceAvailability', metric_labels,
                self.__deployer.metrics.default_determine_outcome_labels,
                wait_on_services, services)
        else:
            logging.warning('Skipping waiting for services')

        return True
Exemple #3
0
 def determine_origin(self, name):
     """Determine the origin to use for the given repository."""
     if not self.__github_owner:
         raise_and_log_error(
             UnexpectedError('Not reachable', cause='NotReachable'))
     return self.determine_origin_for_owner(name, self.__github_owner)