Exemple #1
0
    def RunTests(self):
        # Affinitize the tests.
        self._SplitTestsByAffinity()
        if not self._test_buckets and not self._no_device_tests:
            raise local_device_test_run.NoTestsError()

        def run_perf_tests(shard_id):
            if shard_id is None:
                s = HostTestShard(self._env,
                                  self._test_instance,
                                  self._no_device_tests,
                                  retries=3,
                                  timeout=self._timeout)
            else:
                if device_status.IsBlacklisted(str(self._devices[shard_id]),
                                               self._env.blacklist):
                    logging.warning(
                        'Device %s is not active. Will not create shard %s.',
                        str(self._devices[shard_id]), shard_id)
                    return None
                s = DeviceTestShard(self._env,
                                    self._test_instance,
                                    self._devices[shard_id],
                                    shard_id,
                                    self._test_buckets[shard_id],
                                    retries=self._env.max_tries,
                                    timeout=self._timeout)
            return s.RunTestsOnShard()

        device_indices = range(min(len(self._devices),
                                   len(self._test_buckets)))
        if self._no_device_tests:
            device_indices.append(None)
        shards = parallelizer.Parallelizer(device_indices).pMap(run_perf_tests)
        return [x for x in shards.pGet(self._timeout) if x is not None]
    def RunTests(self):
        # Affinitize the tests.
        if self._test_instance.trace_output:
            assert not trace_event.trace_is_enabled(
            ), 'Tracing already running.'
            trace_event.trace_enable(self._test_instance.trace_output +
                                     '.json')
        self._SplitTestsByAffinity()
        if not self._test_buckets and not self._no_device_tests:
            raise local_device_test_run.NoTestsError()

        def run_no_devices_tests():
            if not self._no_device_tests:
                return []
            s = HostTestShard(self._env,
                              self._test_instance,
                              self._no_device_tests,
                              retries=3,
                              timeout=self._timeout)
            return [s.RunTestsOnShard()]

        def device_shard_helper(shard_id):
            if device_status.IsBlacklisted(str(self._devices[shard_id]),
                                           self._env.blacklist):
                logging.warning(
                    'Device %s is not active. Will not create shard %s.',
                    str(self._devices[shard_id]), shard_id)
                return None
            s = DeviceTestShard(self._env,
                                self._test_instance,
                                self._devices[shard_id],
                                shard_id,
                                self._test_buckets[shard_id],
                                retries=self._env.max_tries,
                                timeout=self._timeout)
            return s.RunTestsOnShard()

        def run_devices_tests():
            if not self._test_buckets:
                return []
            if self._devices is None:
                self._devices = self._GetAllDevices(
                    self._env.devices, self._test_instance.known_devices_file)

            device_indices = range(
                min(len(self._devices), len(self._test_buckets)))
            shards = parallelizer.Parallelizer(device_indices).pMap(
                device_shard_helper)
            return [x for x in shards.pGet(self._timeout) if x is not None]

        host_test_results, device_test_results = reraiser_thread.RunAsync(
            [run_no_devices_tests, run_devices_tests])
        if self._test_instance.trace_output:
            assert trace_event.trace_is_enabled(), 'Tracing not running.'
            trace_event.trace_disable()
            local_device_test_run.LocalDeviceTestRun._JsonToTrace(
                self._test_instance.trace_output + '.json',
                self._test_instance.trace_output)
        return host_test_results + device_test_results
Exemple #3
0
    def RunTests(self):
        def run_no_devices_tests():
            if not self._no_device_tests:
                return []
            s = HostTestShard(self._env,
                              self._test_instance,
                              self._no_device_tests,
                              retries=3,
                              timeout=self._timeout)
            return [s.RunTestsOnShard()]

        def device_shard_helper(shard_id):
            if device_status.IsBlacklisted(str(self._devices[shard_id]),
                                           self._env.blacklist):
                logging.warning(
                    'Device %s is not active. Will not create shard %s.',
                    str(self._devices[shard_id]), shard_id)
                return None
            s = DeviceTestShard(self._env,
                                self._test_instance,
                                self._devices[shard_id],
                                shard_id,
                                self._test_buckets[shard_id],
                                retries=self._env.max_tries,
                                timeout=self._timeout)
            return s.RunTestsOnShard()

        def run_devices_tests():
            if not self._test_buckets:
                return []
            if self._devices is None:
                self._devices = self._GetAllDevices(
                    self._env.devices, self._test_instance.known_devices_file)

            device_indices = range(
                min(len(self._devices), len(self._test_buckets)))
            shards = parallelizer.Parallelizer(device_indices).pMap(
                device_shard_helper)
            return [x for x in shards.pGet(self._timeout) if x is not None]

        # Run the tests.
        with contextlib_ext.Optional(self._env.Tracing(),
                                     self._env.trace_output):
            # Affinitize the tests.
            self._SplitTestsByAffinity()
            if not self._test_buckets and not self._no_device_tests:
                raise local_device_test_run.NoTestsError()
            host_test_results, device_test_results = reraiser_thread.RunAsync(
                [run_no_devices_tests, run_devices_tests])

        return host_test_results + device_test_results
Exemple #4
0
  def RunTests(self, results):
    def run_no_devices_tests():
      if not self._no_device_tests:
        return []
      s = HostTestShard(self._env, self._test_instance, self._no_device_tests,
                        retries=3, timeout=self._timeout)
      return [s.RunTestsOnShard()]

    def device_shard_helper(shard_id):
      if device_status.IsBlacklisted(
           str(self._devices[shard_id]), self._env.blacklist):
        logging.warning('Device %s is not active. Will not create shard %s.',
                        str(self._devices[shard_id]), shard_id)
        return None
      s = DeviceTestShard(self._env, self._test_instance,
                          self._devices[shard_id], shard_id,
                          self._test_buckets[shard_id],
                          retries=self._env.max_tries, timeout=self._timeout)
      return s.RunTestsOnShard()

    def run_devices_tests():
      if not self._test_buckets:
        return []
      if self._devices is None:
        self._devices = self._GetAllDevices(
            self._env.devices, self._test_instance.known_devices_file)

      device_indices = range(min(len(self._devices), len(self._test_buckets)))
      shards = parallelizer.Parallelizer(device_indices).pMap(
          device_shard_helper)
      return [x for x in shards.pGet(self._timeout) if x is not None]

    # Affinitize the tests.
    self._SplitTestsByAffinity()
    if not self._test_buckets and not self._no_device_tests:
      raise local_device_test_run.NoTestsError()
    host_test_results, device_test_results = reraiser_thread.RunAsync(
        [run_no_devices_tests, run_devices_tests])

    # Ideally, results would be populated as early as possible, so that in the
    # event of an exception or timeout, the caller will still have partially
    # populated results. This looks like it can be done prior to dispatching
    # tests, but will hold off on making this change unless it looks like it
    # might provide utility.
    results.extend(host_test_results + device_test_results)