tiaf_driver.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. #
  4. # SPDX-License-Identifier: Apache-2.0 OR MIT
  5. #
  6. #
  7. import argparse
  8. from tiaf import TestImpact
  9. import sys
  10. import os
  11. import datetime
  12. import json
  13. import socket
  14. def parse_args():
  15. def file_path(value):
  16. if os.path.isfile(value):
  17. return value
  18. else:
  19. raise FileNotFoundError(value)
  20. def timout_type(value):
  21. value = int(value)
  22. if value <= 0:
  23. raise ValueError("Timer values must be positive integers")
  24. return value
  25. def test_failure_policy(value):
  26. if value == "continue" or value == "abort" or value == "ignore":
  27. return value
  28. else:
  29. raise ValueError("Test failure policy must be 'abort', 'continue' or 'ignore'")
  30. parser = argparse.ArgumentParser()
  31. parser.add_argument('--config', dest="config", type=file_path, help="Path to the test impact analysis framework configuration file", required=True)
  32. parser.add_argument('--destBranch', dest="dst_branch", help="For PR builds, the destination branch to be merged to, otherwise empty")
  33. parser.add_argument('--branchesOfTruth', dest="branches_of_truth", type=lambda arg: arg.split(','), help="Comma separated branches that seeding will occur on", required=True)
  34. parser.add_argument('--pipeline', dest="pipeline", help="Pipeline the test impact analysis framework is running on", required=True)
  35. parser.add_argument('--pipelinesOfTruth', dest="pipelines_of_truth", type=lambda arg: arg.split(','), help="Comma separated pipeline that seeding will occur on", required=True)
  36. parser.add_argument('--destCommit', dest="dst_commit", help="Commit to run test impact analysis on (ignored when seeding)", required=True)
  37. parser.add_argument('--suite', dest="suite", help="Test suite to run", required=True)
  38. parser.add_argument('--testFailurePolicy', dest="test_failure_policy", type=test_failure_policy, help="Test failure policy for regular and test impact sequences (ignored when seeding)", required=True)
  39. parser.add_argument('--safeMode', dest="safe_mode", action='store_true', help="Run impact analysis tests in safe mode (ignored when seeding)")
  40. parser.add_argument('--testTimeout', dest="test_timeout", type=timout_type, help="Maximum run time (in seconds) of any test target before being terminated", required=False)
  41. parser.add_argument('--globalTimeout', dest="global_timeout", type=timout_type, help="Maximum run time of the sequence before being terminated", required=False)
  42. parser.set_defaults(test_timeout=None)
  43. parser.set_defaults(global_timeout=None)
  44. args = parser.parse_args()
  45. return args
  46. if __name__ == "__main__":
  47. try:
  48. args = parse_args()
  49. tiaf = TestImpact(args.config, args.dst_commit, args.dst_branch, args.pipeline, args.branches_of_truth, args.pipelines_of_truth)
  50. return_code = tiaf.run(args.suite, args.test_failure_policy, args.safe_mode, args.test_timeout, args.global_timeout)
  51. # Non-gating will be removed from this script and handled at the job level in SPEC-7413
  52. #sys.exit(return_code)
  53. sys.exit(0)
  54. except:
  55. # Non-gating will be removed from this script and handled at the job level in SPEC-7413
  56. sys.exit(0)