Esempio n. 1
0
def main():
  """The main controller."""
  options = get_options()
  deployer = validate_bom__deploy.make_deployer(options)
  test_controller = validate_bom__test.ValidateBomTestController(deployer)
  config_script = validate_bom__config.make_script(options)
  file_set = validate_bom__config.get_files_to_upload(options)

  try:
    deployer.deploy(config_script, file_set)
    test_controller.run_tests()
  finally:
    if sys.exc_info()[0] is not None:
      logging.error('Caught Exception')
      logging.exception('Caught Exception')
    if options.deploy_undeploy or options.deploy_always_collect_logs:
      deployer.collect_logs()
    if options.deploy_undeploy:
      deployer.undeploy()
    else:
      logging.info('Skipping undeploy because --deploy_undeploy=false')

    summary = build_report(test_controller)
    print summary

  return test_controller.exit_code
Esempio n. 2
0
def main(options, metrics):
    """The main controller."""
    outcome_success = False
    deployer = validate_bom__deploy.make_deployer(options, metrics)
    test_controller = validate_bom__test.ValidateBomTestController(deployer)
    init_script, config_script = validate_bom__config.make_scripts(options)
    file_set = validate_bom__config.get_files_to_upload(options)

    try:
        deployer.deploy(init_script, config_script, file_set)
        _, failed, _ = test_controller.run_tests()
        outcome_success = not failed
    finally:
        if sys.exc_info()[0] is not None:
            logging.error('Caught Exception')
            logging.exception('Caught Exception')
        if options.deploy_undeploy or options.deploy_always_collect_logs:
            deployer.collect_logs()
        if options.deploy_undeploy:
            deployer.undeploy()
        else:
            logging.info('Skipping undeploy because --deploy_undeploy=false')

        summary = build_report(test_controller)
        if summary:
            print summary

        if options.testing_enabled or not outcome_success:
            # Only record the outcome if we were testing
            # or if we failed [to deploy/undeploy].
            metrics.inc_counter('ValidationControllerOutcome',
                                {'success': outcome_success})

    logging.info('Exiting with code=%d', test_controller.exit_code)
    return test_controller.exit_code
Esempio n. 3
0
def main():
  """The main controller."""
  options = get_options()
  deployer = validate_bom__deploy.make_deployer(options)
  test_controller = validate_bom__test.ValidateBomTestController(deployer)
  init_script, config_script = validate_bom__config.make_scripts(options)
  file_set = validate_bom__config.get_files_to_upload(options)

  try:
    deployer.deploy(init_script, config_script, file_set)
    test_controller.run_tests()
  finally:
    if sys.exc_info()[0] is not None:
      logging.error('Caught Exception')
      logging.exception('Caught Exception')
    if options.deploy_undeploy or options.deploy_always_collect_logs:
      deployer.collect_logs()
    if options.deploy_undeploy:
      deployer.undeploy()
    else:
      logging.info('Skipping undeploy because --deploy_undeploy=false')

    summary = build_report(test_controller)
    print summary

  return test_controller.exit_code
Esempio n. 4
0
def main():
    """The main controller."""
    options = get_options()

    deployer = validate_bom__deploy.make_deployer(options)
    config_script = validate_bom__config.make_script(options)
    file_set = validate_bom__config.get_files_to_upload(options)

    try:
        deployer.deploy(config_script, file_set)

        test_controller = validate_bom__test.ValidateBomTestController(
            deployer)
        test_controller.run_tests()
    finally:
        if sys.exc_info()[0] is not None:
            logging.error('Caught Exception')
            logging.exception('Caught Exception')
        deployer.collect_logs()
        deployer.undeploy()
        build_report(options)

    def dump_list(name, entries):
        """Write out all the names from the test results."""
        if not entries:
            return
        print '{0}:'.format(name)
        for entry in entries:
            print '  * {0}'.format(entry[0])

    print '\nSummary:'
    dump_list('SKIPPED', test_controller.skipped)
    dump_list('PASSED', test_controller.passed)
    dump_list('FAILED', test_controller.failed)

    num_skipped = len(test_controller.skipped)
    num_passed = len(test_controller.passed)
    num_failed = len(test_controller.failed)

    print ''
    if num_failed:
        print 'FAILED {0} of {1}, skipped {2}'.format(
            num_failed, (num_failed + num_passed), num_skipped)
        return -1

    print 'PASSED {0}, skipped {1}'.format(num_passed, num_skipped)
    return 0
def main():
  """The main controller."""
  options = get_options()

  deployer = validate_bom__deploy.make_deployer(options)
  config_script = validate_bom__config.make_script(options)
  file_set = validate_bom__config.get_files_to_upload(options)

  try:
    deployer.deploy(config_script, file_set)

    test_controller = validate_bom__test.ValidateBomTestController(deployer)
    test_controller.run_tests()
  finally:
    if sys.exc_info()[0] is not None:
      logging.error('Caught Exception')
      logging.exception('Caught Exception')
    deployer.collect_logs()
    deployer.undeploy()
    build_report(options)

  def dump_list(name, entries):
    """Write out all the names from the test results."""
    if not entries:
      return
    print '{0}:'.format(name)
    for entry in entries:
      print '  * {0}'.format(entry[0])

  print '\nSummary:'
  dump_list('SKIPPED', test_controller.skipped)
  dump_list('PASSED', test_controller.passed)
  dump_list('FAILED', test_controller.failed)

  num_skipped = len(test_controller.skipped)
  num_passed = len(test_controller.passed)
  num_failed = len(test_controller.failed)

  print ''
  if num_failed:
    print 'FAILED {0} of {1}, skipped {2}'.format(
        num_failed, (num_failed + num_passed), num_skipped)
    return -1

  print 'PASSED {0}, skipped {1}'.format(num_passed, num_skipped)
  return 0
Esempio n. 6
0
def main():
    """The main controller."""
    options = get_options()
    deployer = validate_bom__deploy.make_deployer(options)
    test_controller = validate_bom__test.ValidateBomTestController(deployer)
    config_script = validate_bom__config.make_script(options)
    file_set = validate_bom__config.get_files_to_upload(options)

    try:
        deployer.deploy(config_script, file_set)
        test_controller.run_tests()
    finally:
        if sys.exc_info()[0] is not None:
            logging.error('Caught Exception')
            logging.exception('Caught Exception')
        deployer.collect_logs()
        deployer.undeploy()
        summary = build_report(test_controller)
        print summary

    return test_controller.exit_code