issue_generator.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import random
  2. from glitchtip.test_utils.test_data import ENVIRONMENTS, RELEASES
  3. from issues.models import EventType, Issue
  4. def brower_tag_generator():
  5. return random.choice(BROWSER_TAGS)
  6. SDKS = [
  7. {
  8. "version": "1.5.1",
  9. "name": "sentry.python",
  10. "packages": [{"version": "1.5.1", "name": "pypi:sentry-sdk"}],
  11. "integrations": [],
  12. },
  13. {
  14. "name": "sentry.javascript.react",
  15. "version": "7.36.0",
  16. "packages": [{"name": "npm:@sentry/react", "version": "7.36.0"}],
  17. "integrations": [
  18. "InboundFilters",
  19. ],
  20. },
  21. {"name": "sentry.php.laravel", "version": "2.9.0"},
  22. ]
  23. EXCEPTIONS = [
  24. {
  25. "values": [
  26. {
  27. "type": "Error",
  28. "value": "A Generic Error 9371d7",
  29. "stacktrace": {
  30. "frames": [
  31. {
  32. "colno": 27,
  33. "filename": "http://localhost:4201/polyfills.js",
  34. "function": "globalZoneAwareCallback",
  35. "in_app": True,
  36. "lineno": 4864,
  37. },
  38. ]
  39. },
  40. }
  41. ]
  42. },
  43. {
  44. "values": [
  45. {
  46. "type": "System.DivideByZeroException",
  47. "value": "Attempted to divide by zero.",
  48. "module": "System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=1111111111111111",
  49. "thread_id": 1,
  50. "stacktrace": {
  51. "frames": [
  52. {
  53. "function": "Invoke",
  54. "module": "Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware",
  55. "in_app": False,
  56. "package": "Microsoft.AspNetCore.Diagnostics, Version=3.1.3.0, Culture=neutral, PublicKeyToken=111111",
  57. "instruction_offset": 130,
  58. },
  59. {
  60. "function": "InvokeHandlerMethodAsync",
  61. "module": "Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker",
  62. "in_app": False,
  63. "package": "Microsoft.AspNetCore.Mvc.RazorPages, Version=3.1.3.0, Culture=neutral, PublicKeyToken=111111",
  64. "instruction_offset": 202,
  65. },
  66. ]
  67. },
  68. }
  69. ]
  70. },
  71. ]
  72. BROWSER_TAGS = [
  73. {
  74. "device": "Desktop",
  75. "browser": "GlitchBot 1.2",
  76. "os.name": "Linux",
  77. "server_name": "glitch-server",
  78. "browser.name": "GlitchBot",
  79. },
  80. {
  81. "device": "Mobile",
  82. "browser": "Firefox 120",
  83. "os.name": "Android",
  84. "server_name": "glitch-server",
  85. "browser.name": "Firefox",
  86. },
  87. {
  88. "device": "Desktop",
  89. "browser": "bingbot 2.0",
  90. "os.name": "Other",
  91. "server_name": "cool-server",
  92. "browser.name": "bingbot",
  93. },
  94. {
  95. "browser": "Chrome 106.0.0",
  96. "os.name": "Windows",
  97. "release": "v1.0.0",
  98. "browser.name": "Chrome",
  99. },
  100. ]
  101. CULPRITS = [
  102. "/src/Controller/FunController.php in App\Controller\FunController::showFun",
  103. "blarg.php in ?",
  104. "subscriber.contract.view.modal.block.unblock",
  105. ]
  106. SERVER_TAGS = [
  107. {
  108. "os.name": ["Linux"],
  109. "server_name": ["ip-111-11-11-111.ec3.internal"],
  110. },
  111. {
  112. "server_name": ["11335c17-b136-1e4a-1241-e243221c1221"],
  113. },
  114. ]
  115. TAG_CHOICES = BROWSER_TAGS + SERVER_TAGS
  116. TITLE_CHOICES = [
  117. "The error has happened here",
  118. "ErrorException: Notice: Trying to access array offset on value of type null",
  119. "WorkerLostError: Worker exited prematurely: signal 15 (SIGTERM) Job: 1.",
  120. "ErrorException: Warning: filesize(): stat failed for /var/www/vhosts/example.com/private/me/data/1",
  121. "Project\Database\QueryException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type uuid: 12345",
  122. "OperationalError: ERROR: no more connections allowed (max_client_conn)",
  123. ]
  124. def generate_tag():
  125. tag = random.choice(TAG_CHOICES)
  126. if environment := random.choice(ENVIRONMENTS):
  127. tag["environment"] = environment
  128. release = random.choice(RELEASES)