count-hybrid-cloud-test-progress 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. import os
  3. import pathlib
  4. from collections import defaultdict
  5. from sentry.runner import configure
  6. configure()
  7. from sentry.testutils.modelmanifest import ModelManifest
  8. _manifest_files_env = {
  9. "SENTRY_MODEL_MANIFEST_FILE_PATH": pathlib.Path(__file__).absolute().parent.parent,
  10. "GETSENTRY_MODEL_MANIFEST_FILE_PATH": pathlib.Path(__file__)
  11. .absolute()
  12. .parent.parent.parent.joinpath("getsentry"),
  13. }
  14. for manifest_file_env_name, root_path in _manifest_files_env.items():
  15. manifest_path = os.environ[manifest_file_env_name]
  16. print(f"For {manifest_path}:") # noqa
  17. manifest = ModelManifest.open(file_path=manifest_path)
  18. all_stable = set()
  19. by_model_counts = defaultdict(lambda: [0, 0])
  20. totals = [0, 0]
  21. for test_id, test_visitor in manifest.each_hybrid_cloud_test(root_path):
  22. test_visitor.load()
  23. if test_visitor.decorator_was_stable:
  24. totals[0] += 1
  25. totals[1] += 1
  26. for model_id in manifest.connections[test_id]:
  27. model_name = manifest.reverse_lookup[model_id]
  28. if test_visitor.decorator_was_stable:
  29. by_model_counts[model_name][0] += 1
  30. by_model_counts[model_name][1] += 1
  31. for model_name, counts in by_model_counts.items():
  32. print(f"\t{model_name}: {counts[0]}/{counts[1]}") # noqa
  33. print(f"Total: {totals[0]}/{totals[1]}") # noqa