Example #1
0
def _run_suites(test_driver_list, args, prepare_only=False):
    """Runs the indicated suites."""
    setup_output_directory(args.output_dir)

    suite_results.initialize(test_driver_list, args, prepare_only)

    if not test_driver_list:
        return False

    timeout = (args.total_timeout
               if args.total_timeout and not prepare_only else None)

    try:
        with concurrent.ThreadPoolExecutor(args.jobs, daemon=True) as executor:
            futures = [
                executor.submit(_run_driver, driver, args, prepare_only)
                for driver in test_driver_list
            ]
            done, not_done = concurrent.wait(futures, timeout,
                                             concurrent.FIRST_EXCEPTION)
            try:
                # Iterate over the results to propagate an exception if any of the tasks
                # aborted by an error in the test drivers. Since such an error is due to
                # broken script rather than normal failure in tests, we prefer just to
                # die similarly as when Python errors occurred in the main thread.
                for future in done:
                    future.result()

                # No exception was raised but some timed-out tasks are remaining.
                if not_done:
                    print '@@@STEP_TEXT@Integration test timed out@@@'
                    debug.write_frames(sys.stdout)
                    if args.warn_on_failure:
                        print '@@@STEP_WARNINGS@@@'
                    else:
                        print '@@@STEP_FAILURE@@@'
                    return False

                # All tests passed (or failed) in time.
                return True
            finally:
                if not_done:
                    _shutdown_unfinished_drivers_gracefully(
                        not_done, test_driver_list)
    finally:
        for driver in test_driver_list:
            driver.finalize(args)
Example #2
0
def _run_suites(test_driver_list, args, prepare_only=False):
  """Runs the indicated suites."""
  setup_output_directory(args.output_dir)

  suite_results.initialize(test_driver_list, args, prepare_only)

  if not test_driver_list:
    return False

  timeout = (
      args.total_timeout if args.total_timeout and not prepare_only else None)

  try:
    with concurrent.ThreadPoolExecutor(args.jobs, daemon=True) as executor:
      futures = [executor.submit(_run_driver, driver, args, prepare_only)
                 for driver in test_driver_list]
      done, not_done = concurrent.wait(futures, timeout,
                                       concurrent.FIRST_EXCEPTION)
      try:
        # Iterate over the results to propagate an exception if any of the tasks
        # aborted by an error in the test drivers. Since such an error is due to
        # broken script rather than normal failure in tests, we prefer just to
        # die similarly as when Python errors occurred in the main thread.
        for future in done:
          future.result()

        # No exception was raised but some timed-out tasks are remaining.
        if not_done:
          print '@@@STEP_TEXT@Integration test timed out@@@'
          debug.write_frames(sys.stdout)
          if args.warn_on_failure:
            print '@@@STEP_WARNINGS@@@'
          else:
            print '@@@STEP_FAILURE@@@'
          return False

        # All tests passed (or failed) in time.
        return True
      finally:
        if not_done:
          _shutdown_unfinished_drivers_gracefully(not_done, test_driver_list)
  finally:
    for driver in test_driver_list:
      driver.finalize(args)
Example #3
0
def _sigterm_handler(signum, frame):
  """Signal handler for the SIGTERM."""
  # First of all, on TERMINATE, print the stacktrace.
  assert signum == signal.SIGTERM
  logging.error('SIGTERM is received.')
  debug.write_frames(sys.stderr)

  # If we can send SIGTERM to child processes, we do not exit here,
  # with expecting the graceful shutdown.
  # Note that, although we do this in atexit handler, too, it is too late
  # (runs after all threads are terminated). So we need it here.
  # Note that, to avoid race conditions, the program must not poll or wait
  # on a non-main thread. Practically, it is almost safe, but there is
  # a small chance for un-related processes to be killed by SIGTERM
  # accidentally.
  _terminate_subprocess()

  # Then, terminate the script. Note that at the end of the interpreter,
  # functions registered by atexit.register() will run.
  sys.exit(1)
Example #4
0
def _sigterm_handler(signum, frame):
    """Signal handler for the SIGTERM."""
    # First of all, on TERMINATE, print the stacktrace.
    assert signum == signal.SIGTERM
    logging.error('SIGTERM is received.')
    debug.write_frames(sys.stderr)

    # If we can send SIGTERM to child processes, we do not exit here,
    # with expecting the graceful shutdown.
    # Note that, although we do this in atexit handler, too, it is too late
    # (runs after all threads are terminated). So we need it here.
    # Note that, to avoid race conditions, the program must not poll or wait
    # on a non-main thread. Practically, it is almost safe, but there is
    # a small chance for un-related processes to be killed by SIGTERM
    # accidentally.
    _terminate_subprocess()

    # Then, terminate the script. Note that at the end of the interpreter,
    # functions registered by atexit.register() will run.
    sys.exit(1)
Example #5
0
def foo(arg0, out):
  debug.write_frames(out)
  return arg0
Example #6
0
def foo(arg0, out):
    debug.write_frames(out)
    return arg0